From 794075754e1caa1eb5cc5f9b91180371db7112be Mon Sep 17 00:00:00 2001 From: Vince Au Date: Sat, 3 Oct 2020 12:02:06 +1000 Subject: [PATCH 01/19] Add Dolphin connection support for SlpLiveStream --- package.json | 2 +- src/stream/slpLiveStream.ts | 15 ++++++++++----- yarn.lock | 14 ++++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index bb31290..7d9b53b 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "realtime" ], "dependencies": { - "@slippi/slippi-js": "^5.0.5", + "@slippi/slippi-js": "^5.1.0-beta.0", "chokidar": "^3.3.1", "fs-extra": "^8.1.0", "lodash": "^4.17.19", diff --git a/src/stream/slpLiveStream.ts b/src/stream/slpLiveStream.ts index fd7e094..a08086f 100644 --- a/src/stream/slpLiveStream.ts +++ b/src/stream/slpLiveStream.ts @@ -1,8 +1,8 @@ import { RxSlpStream } from "./rxSlpStream"; -import { ConsoleConnection, ConnectionStatus, ConnectionEvent } from "@slippi/slippi-js"; +import { Connection, ConsoleConnection, DolphinConnection, ConnectionStatus, ConnectionEvent } from "@slippi/slippi-js"; // Re-export these for ease-of-use -export { ConsoleConnection, ConnectionStatus } from "@slippi/slippi-js"; +export { ConnectionEvent, ConsoleConnection, ConnectionStatus } from "@slippi/slippi-js"; const SLIPPI_CONNECTION_TIMEOUT_MS = 5000; @@ -20,10 +20,15 @@ export class SlpLiveStream extends RxSlpStream { * * @memberof SlpLiveStream */ - public connection = new ConsoleConnection(); + public connection: Connection; - constructor() { + constructor(connectionType?: "dolphin" | "console") { super(); + if (connectionType === "dolphin") { + this.connection = new DolphinConnection(); + } else { + this.connection = new ConsoleConnection(); + } this.connection.on(ConnectionEvent.HANDSHAKE, (data) => { this.updateSettings({ consoleNickname: data.consoleNickname }); }); @@ -64,7 +69,7 @@ export class SlpLiveStream extends RxSlpStream { try { // Actually try to connect - this.connection.connect(address, port, SLIPPI_CONNECTION_TIMEOUT_MS); + this.connection.connect(address, port); } catch (err) { reject(err); } diff --git a/yarn.lock b/yarn.lock index d8dfe10..a7492eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -458,12 +458,13 @@ resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5" integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ== -"@slippi/slippi-js@^5.0.5": - version "5.0.5" - resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.0.5.tgz#abb86b598451d100519a8cb7cddc048e58e2f9e2" - integrity sha512-iVFhJz1njibZf55KCSk8egRpuc85EnkWQtARnNLzzE6nzffMbUwZip5dHwhuH2PI8BRnPmN2M0d9Ri5QdTaZ/g== +"@slippi/slippi-js@^5.1.0-beta.0": + version "5.1.0-beta.0" + resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.1.0-beta.0.tgz#69ba00212866e0e45cdd71be68d5ebada2b7aa5e" + integrity sha512-Jcw0EzL+swzLqxQdt4XqUNczru7d1/pENkeCCo0/bwy1XTaKNWAptCO3rMqdY7tmRkAdu8+1H4svkEq6MD4lgQ== dependencies: "@shelacek/ubjson" "^1.0.1" + enet "^0.2.9" iconv-lite "^0.6.2" lodash "^4.17.19" moment "^2.27.0" @@ -1426,6 +1427,11 @@ end-of-stream@^1.1.0: dependencies: once "^1.4.0" +enet@^0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/enet/-/enet-0.2.9.tgz#d7fd68a0bf8bb3891408ea465e26ed6955822a1a" + integrity sha1-1/1ooL+Ls4kUCOpGXibtaVWCKho= + error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" From bf2e0b14328bace705a8ec6958369ec3487ae8e9 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Sat, 3 Oct 2020 12:11:59 +1000 Subject: [PATCH 02/19] 3.1.0-beta.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d9b53b..edee2b3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@vinceau/slp-realtime", "description": "Realtime slp parsing", "license": "MIT", - "version": "3.0.2", + "version": "3.1.0-beta.0", "repository": "vinceau/slp-realtime", "engines": { "node": ">=10" From 1f2b224d8b6c4c11b806bda15286613a96adc788 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Wed, 7 Oct 2020 17:53:09 +1100 Subject: [PATCH 03/19] Update slippi-js dependency --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index edee2b3..8a8dd82 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "realtime" ], "dependencies": { - "@slippi/slippi-js": "^5.1.0-beta.0", + "@slippi/slippi-js": "^5.1.0-beta.3", "chokidar": "^3.3.1", "fs-extra": "^8.1.0", "lodash": "^4.17.19", diff --git a/yarn.lock b/yarn.lock index a7492eb..a431b2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -458,10 +458,10 @@ resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5" integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ== -"@slippi/slippi-js@^5.1.0-beta.0": - version "5.1.0-beta.0" - resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.1.0-beta.0.tgz#69ba00212866e0e45cdd71be68d5ebada2b7aa5e" - integrity sha512-Jcw0EzL+swzLqxQdt4XqUNczru7d1/pENkeCCo0/bwy1XTaKNWAptCO3rMqdY7tmRkAdu8+1H4svkEq6MD4lgQ== +"@slippi/slippi-js@^5.1.0-beta.3": + version "5.1.0-beta.3" + resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.1.0-beta.3.tgz#54cf6a85d22a1e465eca01143ec5d7cb82500034" + integrity sha512-DSK69x4C6yNredQkOgRtFGqC2U1kKq9C3n/R+yWg3DCmyWAdb/Bac3HDq5j83Mo/uwOgvYmpMXgNLlnIEvUbaA== dependencies: "@shelacek/ubjson" "^1.0.1" enet "^0.2.9" From 67ba8db3bc6deab1f9b7871619b10ca0dfd70b36 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Wed, 7 Oct 2020 17:57:49 +1100 Subject: [PATCH 04/19] Fix tests --- src/stream/rxSlpStream.ts | 8 +------- src/stream/slpFolderStream.ts | 10 +++------- test/buttonPress.spec.ts | 4 ++-- test/combo.spec.ts | 20 ++++++++++---------- test/config/combo.config.spec.ts | 11 ++++++----- test/config/game.config.spec.ts | 4 ++-- test/config/input.config.spec.ts | 6 +++--- test/config/player.config.spec.ts | 2 +- test/config/stock.config.spec.ts | 2 +- test/realtime.spec.ts | 4 ++-- test/slpStream.spec.ts | 4 ++-- test/winner.spec.ts | 2 +- 12 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/stream/rxSlpStream.ts b/src/stream/rxSlpStream.ts index 2418372..db7e088 100644 --- a/src/stream/rxSlpStream.ts +++ b/src/stream/rxSlpStream.ts @@ -10,7 +10,6 @@ import { GameEndType, SlpFileWriter, SlpFileWriterOptions, - SlpStreamSettings, } from "@slippi/slippi-js"; import { Subject, fromEvent } from "rxjs"; import { share } from "rxjs/operators"; @@ -41,17 +40,12 @@ export class RxSlpStream extends SlpFileWriter { * @param {WritableOptions} [opts] * @memberof SlpStream */ - public constructor( - options?: Partial, - slpOptions?: Partial, - opts?: WritableOptions, - ) { + public constructor(options?: Partial, opts?: WritableOptions) { super( { ...options, outputFiles: options && options.outputFiles === true, // Don't write out files unless manually specified }, - slpOptions, opts, ); diff --git a/src/stream/slpFolderStream.ts b/src/stream/slpFolderStream.ts index c071003..ae189ba 100644 --- a/src/stream/slpFolderStream.ts +++ b/src/stream/slpFolderStream.ts @@ -3,7 +3,7 @@ import path from "path"; import chokidar from "chokidar"; import tailstream, { TailStream } from "tailstream"; import { RxSlpStream } from "./rxSlpStream"; -import { SlpFileWriterOptions, SlpStreamSettings, SlpStreamMode } from "@slippi/slippi-js"; +import { SlpFileWriterOptions, SlpStreamMode } from "@slippi/slippi-js"; import { WritableOptions } from "stream"; import { Subject, Observable, fromEvent } from "rxjs"; import { map, switchMap, share, takeUntil } from "rxjs/operators"; @@ -30,12 +30,8 @@ export class SlpFolderStream extends RxSlpStream { private newFile$: Observable; private readStream: TailStream | null = null; - public constructor( - options?: Partial, - slpOptions?: Partial, - opts?: WritableOptions, - ) { - super(options, { ...slpOptions, mode: SlpStreamMode.MANUAL }, opts); + public constructor(options?: Partial, opts?: WritableOptions) { + super({ ...options, mode: SlpStreamMode.MANUAL }, opts); this.newFile$ = this.startRequested$.pipe( switchMap(([slpFolder, includeSubfolders]) => { // End any existing read streams diff --git a/test/buttonPress.spec.ts b/test/buttonPress.spec.ts index ebc8afb..85ae2b0 100644 --- a/test/buttonPress.spec.ts +++ b/test/buttonPress.spec.ts @@ -1,6 +1,6 @@ import sinon from "sinon"; -import { pipeFileContents, SlpRealTime, RxSlpStream, ComboFilter, throttleInputButtons } from "../src"; +import { pipeFileContents, SlpRealTime, RxSlpStream, ComboFilter, throttleInputButtons, SlpStreamMode } from "../src"; import { Subscription } from "rxjs"; describe("combo calculation", () => { @@ -23,7 +23,7 @@ describe("combo calculation", () => { it("correctly finds button combinations", async () => { const comboSpy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); diff --git a/test/combo.spec.ts b/test/combo.spec.ts index 48ae6ef..d5a942f 100644 --- a/test/combo.spec.ts +++ b/test/combo.spec.ts @@ -1,6 +1,6 @@ import sinon from "sinon"; -import { pipeFileContents, SlippiGame, SlpRealTime, RxSlpStream, ComboFilter, Character } from "../src"; +import { pipeFileContents, SlippiGame, SlpRealTime, RxSlpStream, ComboFilter, Character, SlpStreamMode } from "../src"; import { Subscription } from "rxjs"; describe("combo calculation", () => { @@ -23,7 +23,7 @@ describe("combo calculation", () => { it("correctly matches combo criteria", async () => { const comboSpy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); @@ -50,7 +50,7 @@ describe("combo calculation", () => { bowserOnlyFilter.updateSettings({ characterFilter: [Character.BOWSER] }); excludesBowserFilter.updateSettings({ characterFilter: [Character.CAPTAIN_FALCON] }); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); @@ -77,7 +77,7 @@ describe("combo calculation", () => { const comboSpy = sinon.spy(); filter.updateSettings({ minComboPercent: 20 }); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); @@ -98,7 +98,7 @@ describe("combo calculation", () => { it("emits the correct number of conversions", async () => { const conversionSpy = sinon.spy(); filter.updateSettings({ minComboPercent: 20 }); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); subscriptions.push( @@ -119,7 +119,7 @@ describe("combo calculation", () => { const filename = "slp/200306_2258_Falco_v_Fox_PS.slp"; filter.updateSettings({ minComboPercent: 50 }); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); realtime.setStream(slpStream); subscriptions.push( realtime.combo.conversion$.subscribe((payload) => { @@ -146,7 +146,7 @@ describe("combo calculation", () => { nameTags: ["fizzi"], fuzzyNameTagMatching: false, }); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); realtime.setStream(slpStream); subscriptions.push( realtime.combo.end$.subscribe((payload) => { @@ -169,7 +169,7 @@ describe("combo calculation", () => { const metadata = game.getMetadata(); filter.updateSettings({ minComboPercent: 40, nameTags: ["Fizzi"] }); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); realtime.setStream(slpStream); subscriptions.push( realtime.combo.end$.subscribe((payload) => { @@ -205,7 +205,7 @@ describe("combo calculation", () => { nameTags: ["CptPiplup"], }); - const slpStream = new RxSlpStream(undefined, { suppressErrors: false }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL, suppressErrors: false }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); @@ -266,7 +266,7 @@ describe("combo calculation", () => { fuzzyNameTagMatching: true, }); - const slpStream = new RxSlpStream(undefined, { suppressErrors: false }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL, suppressErrors: false }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); diff --git a/test/config/combo.config.spec.ts b/test/config/combo.config.spec.ts index a156e0f..2eac4f7 100644 --- a/test/config/combo.config.spec.ts +++ b/test/config/combo.config.spec.ts @@ -8,6 +8,7 @@ import { EventManager, EventManagerConfig, ComboEvent, + SlpStreamMode, } from "../../src"; import { Subscription } from "rxjs"; @@ -26,7 +27,7 @@ describe("combo config", () => { const allComboSpy = sinon.spy(); const comboSpy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); realtime.setStream(slpStream); @@ -96,7 +97,7 @@ describe("combo config", () => { }, ], }; - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); const eventManager = new EventManager(realtime); @@ -124,7 +125,7 @@ describe("combo config", () => { it("can filter by min combo percent config", async () => { const comboSpy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); eventManager.updateConfig({ @@ -158,7 +159,7 @@ describe("combo config", () => { it("emits the correct number of conversions", async () => { const conversionSpy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); eventManager.updateConfig({ @@ -190,7 +191,7 @@ describe("combo config", () => { const comboSpy = sinon.spy(); const filename = "slp/200306_2258_Falco_v_Fox_PS.slp"; - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); diff --git a/test/config/game.config.spec.ts b/test/config/game.config.spec.ts index 0909fd4..e78fded 100644 --- a/test/config/game.config.spec.ts +++ b/test/config/game.config.spec.ts @@ -20,7 +20,7 @@ describe("game config", () => { const isTeamsGameStartSpy = sinon.spy(); const gameEndSpy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); realtime.setStream(slpStream); @@ -91,7 +91,7 @@ describe("game config", () => { const player2WinSpy = sinon.spy(); const player4WinSpy = sinon.spy(); - const slpStream = new RxSlpStream(undefined, { mode: SlpStreamMode.MANUAL }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); realtime.setStream(slpStream); diff --git a/test/config/input.config.spec.ts b/test/config/input.config.spec.ts index ae2f77d..5d9fc96 100644 --- a/test/config/input.config.spec.ts +++ b/test/config/input.config.spec.ts @@ -1,7 +1,7 @@ import sinon from "sinon"; import { Subscription } from "rxjs"; -import { pipeFileContents, SlpRealTime, RxSlpStream, EventManager, EventManagerConfig } from "../../src"; +import { pipeFileContents, SlpRealTime, RxSlpStream, EventManager, EventManagerConfig, SlpStreamMode } from "../../src"; describe("input config", () => { let subscriptions: Array; @@ -40,7 +40,7 @@ describe("input config", () => { const p3Spy = sinon.spy(); const p4Spy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); realtime.setStream(slpStream); @@ -115,7 +115,7 @@ describe("input config", () => { it("can find the correct number of combos", async () => { const buttonPresses = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); realtime.setStream(slpStream); diff --git a/test/config/player.config.spec.ts b/test/config/player.config.spec.ts index 3ea3d31..26a7ba6 100644 --- a/test/config/player.config.spec.ts +++ b/test/config/player.config.spec.ts @@ -20,7 +20,7 @@ describe("player variables config", () => { const playerSpy2 = sinon.spy(); const opponentSpy2 = sinon.spy(); - const slpStream = new RxSlpStream(undefined, { mode: SlpStreamMode.MANUAL }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); realtime.setStream(slpStream); diff --git a/test/config/stock.config.spec.ts b/test/config/stock.config.spec.ts index 3678d6e..e55eef3 100644 --- a/test/config/stock.config.spec.ts +++ b/test/config/stock.config.spec.ts @@ -18,7 +18,7 @@ describe("stock config", () => { const playerSpawnSpy = sinon.spy(); const playerDeathSpy = sinon.spy(); - const slpStream = new RxSlpStream(undefined, { mode: SlpStreamMode.MANUAL }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); const eventManager = new EventManager(realtime); realtime.setStream(slpStream); diff --git a/test/realtime.spec.ts b/test/realtime.spec.ts index 195cb6a..1aeaed9 100644 --- a/test/realtime.spec.ts +++ b/test/realtime.spec.ts @@ -1,6 +1,6 @@ import sinon from "sinon"; -import { pipeFileContents, SlpRealTime, RxSlpStream } from "../src"; +import { pipeFileContents, SlpRealTime, RxSlpStream, SlpStreamMode } from "../src"; import { Subscription } from "rxjs"; describe("SlpRealTime", () => { @@ -20,7 +20,7 @@ describe("SlpRealTime", () => { const stockSpawnSpy = sinon.spy(); const stockDeathSpy = sinon.spy(); - const slpStream = new RxSlpStream(); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); diff --git a/test/slpStream.spec.ts b/test/slpStream.spec.ts index be9e44f..4bbc61a 100644 --- a/test/slpStream.spec.ts +++ b/test/slpStream.spec.ts @@ -20,7 +20,7 @@ describe("SlpStream", () => { const gameStartSpy = sinon.spy(); const gameEndSpy = sinon.spy(); - const slpStream = new RxSlpStream(undefined, { mode: SlpStreamMode.MANUAL }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const unsubGameStart = slpStream.gameStart$.subscribe(gameStartSpy); const unsubGameEnd = slpStream.gameEnd$.subscribe(gameEndSpy); subscriptions.push(unsubGameStart, unsubGameEnd); @@ -38,7 +38,7 @@ describe("SlpStream", () => { const gameStartSpy = sinon.spy(); const gameEndSpy = sinon.spy(); - const slpStream = new RxSlpStream(undefined, { mode: SlpStreamMode.MANUAL }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const unsubGameStart = slpStream.gameStart$.subscribe(gameStartSpy); const unsubGameEnd = slpStream.gameEnd$.subscribe(gameEndSpy); subscriptions.push(unsubGameStart, unsubGameEnd); diff --git a/test/winner.spec.ts b/test/winner.spec.ts index 9d06586..aedf363 100644 --- a/test/winner.spec.ts +++ b/test/winner.spec.ts @@ -15,7 +15,7 @@ describe("when determining the winner", () => { it("correctly determines winner", async () => { let winner = -1; - const slpStream = new RxSlpStream(undefined, { mode: SlpStreamMode.MANUAL }); + const slpStream = new RxSlpStream({ mode: SlpStreamMode.MANUAL }); const realtime = new SlpRealTime(); realtime.setStream(slpStream); From 44c1c039396a73568287f9ac178d99b7abb02649 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Wed, 7 Oct 2020 18:00:13 +1100 Subject: [PATCH 05/19] 3.1.0-beta.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8a8dd82..da63eb3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@vinceau/slp-realtime", "description": "Realtime slp parsing", "license": "MIT", - "version": "3.1.0-beta.0", + "version": "3.1.0-beta.1", "repository": "vinceau/slp-realtime", "engines": { "node": ">=10" From 6a4b45c7cbf55ad90beb42935a98de8ae3637285 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Thu, 8 Oct 2020 12:12:44 +1100 Subject: [PATCH 06/19] Reset parser on message size command --- src/stream/rxSlpStream.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/stream/rxSlpStream.ts b/src/stream/rxSlpStream.ts index db7e088..2bacd8a 100644 --- a/src/stream/rxSlpStream.ts +++ b/src/stream/rxSlpStream.ts @@ -51,17 +51,18 @@ export class RxSlpStream extends SlpFileWriter { this.on(SlpStreamEvent.COMMAND, (data: SlpCommandEventPayload) => { const { command, payload } = data; - try { - this.parser.handleCommand(command, payload); - } catch (err) { - console.error(`Error processing command ${command}: ${err}`); - } - switch (command) { case Command.MESSAGE_SIZES: + this.parser.reset(); this.messageSizeSource.next(payload as MessageSizes); break; } + + try { + this.parser.handleCommand(command, payload); + } catch (err) { + console.error(`Error processing command ${command}: ${err}`); + } }); } From 4ed84c16b0d782903a13e3ed4fe97634a5e92bef Mon Sep 17 00:00:00 2001 From: Vince Au Date: Thu, 8 Oct 2020 13:07:05 +1100 Subject: [PATCH 07/19] 3.1.0-beta.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da63eb3..9a0af56 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@vinceau/slp-realtime", "description": "Realtime slp parsing", "license": "MIT", - "version": "3.1.0-beta.1", + "version": "3.1.0-beta.2", "repository": "vinceau/slp-realtime", "engines": { "node": ">=10" From d3caa5a079b1d626e2503cd521469e9fb25dc0a3 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Thu, 26 Nov 2020 16:32:39 +1100 Subject: [PATCH 08/19] Stop using default exports --- src/index.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1c103f2..e870cea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,6 @@ -import { SlpRealTime } from "./realtime"; - export * from "./manager"; export * from "./operators"; export * from "./realtime"; export * from "./stream"; export * from "./utils"; - export * from "./types"; - -export default SlpRealTime; From 9fc470b88560195b2e2163076c8e0313dde633fd Mon Sep 17 00:00:00 2001 From: Vince Au Date: Thu, 26 Nov 2020 16:35:15 +1100 Subject: [PATCH 09/19] Use Stage and Character exports from slippi-js --- package.json | 2 +- src/utils/melee/characters.ts | 33 ++++----------------------------- src/utils/melee/stages.ts | 35 +++-------------------------------- yarn.lock | 8 ++++---- 4 files changed, 12 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index 9a0af56..ba8cf65 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "realtime" ], "dependencies": { - "@slippi/slippi-js": "^5.1.0-beta.3", + "@slippi/slippi-js": "^5.1.0", "chokidar": "^3.3.1", "fs-extra": "^8.1.0", "lodash": "^4.17.19", diff --git a/src/utils/melee/characters.ts b/src/utils/melee/characters.ts index 8beb71f..45c9adc 100644 --- a/src/utils/melee/characters.ts +++ b/src/utils/melee/characters.ts @@ -1,33 +1,8 @@ -export type CharacterColor = string; +import { Character } from "@slippi/slippi-js"; -export enum Character { - CAPTAIN_FALCON = 0, - DONKEY_KONG = 1, - FOX = 2, - GAME_AND_WATCH = 3, - KIRBY = 4, - BOWSER = 5, - LINK = 6, - LUIGI = 7, - MARIO = 8, - MARTH = 9, - MEWTWO = 10, - NESS = 11, - PEACH = 12, - PIKACHU = 13, - ICE_CLIMBERS = 14, - JIGGLYPUFF = 15, - SAMUS = 16, - YOSHI = 17, - ZELDA = 18, - SHEIK = 19, - FALCO = 20, - YOUNG_LINK = 21, - DR_MARIO = 22, - ROY = 23, - PICHU = 24, - GANONDORF = 25, -} +export { Character } from "@slippi/slippi-js"; + +export type CharacterColor = string; export interface CharacterInfo { id: number; diff --git a/src/utils/melee/stages.ts b/src/utils/melee/stages.ts index 2e6611d..8ce8c42 100644 --- a/src/utils/melee/stages.ts +++ b/src/utils/melee/stages.ts @@ -1,35 +1,6 @@ -export enum Stage { - FOUNTAIN_OF_DREAMS = 2, - POKEMON_STADIUM = 3, - PEACHS_CASTLE = 4, - KONGO_JUNGLE = 5, - BRINSTAR = 6, - CORNERIA = 7, - YOSHIS_STORY = 8, - ONETT = 9, - MUTE_CITY = 10, - RAINBOW_CRUISE = 11, - JUNGLE_JAPES = 12, - GREAT_BAY = 13, - HYRULE_TEMPLE = 14, - BRINSTAR_DEPTHS = 15, - YOSHIS_ISLAND = 16, - GREEN_GREENS = 17, - FOURSIDE = 18, - MUSHROOM_KINGDOM = 19, - MUSHROOM_KINGDOM_2 = 20, - VENOM = 22, - POKE_FLOATS = 23, - BIG_BLUE = 24, - ICICLE_MOUNTAIN = 25, - ICETOP = 26, - FLAT_ZONE = 27, - DREAMLAND = 28, - YOSHIS_ISLAND_N64 = 29, - KONGO_JUNGLE_N64 = 30, - BATTLEFIELD = 31, - FINAL_DESTINATION = 32, -} +import { Stage } from "@slippi/slippi-js"; + +export { Stage } from "@slippi/slippi-js"; export interface StageInfo { id: Stage; diff --git a/yarn.lock b/yarn.lock index a431b2c..eb4b23c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -458,10 +458,10 @@ resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5" integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ== -"@slippi/slippi-js@^5.1.0-beta.3": - version "5.1.0-beta.3" - resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.1.0-beta.3.tgz#54cf6a85d22a1e465eca01143ec5d7cb82500034" - integrity sha512-DSK69x4C6yNredQkOgRtFGqC2U1kKq9C3n/R+yWg3DCmyWAdb/Bac3HDq5j83Mo/uwOgvYmpMXgNLlnIEvUbaA== +"@slippi/slippi-js@^5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.1.0.tgz#ec523179d07b48fde94036080c4abd1b6eab4cc4" + integrity sha512-u9RWxFU8oDzv5COCmA2lSnQzcgFwEliFNKijDfzKRlnQ68AuIFz/RFOaP+YwWegvarTYVU29RdDtnD1+oAjlpw== dependencies: "@shelacek/ubjson" "^1.0.1" enet "^0.2.9" From b7a2f1bee7e1cf0ca2a020ca6f47b0ed883ad0c1 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Thu, 26 Nov 2020 16:47:55 +1100 Subject: [PATCH 10/19] Only store stage short names --- src/utils/melee/stages.ts | 144 ++++---------------------------------- 1 file changed, 14 insertions(+), 130 deletions(-) diff --git a/src/utils/melee/stages.ts b/src/utils/melee/stages.ts index 8ce8c42..0ccdbc6 100644 --- a/src/utils/melee/stages.ts +++ b/src/utils/melee/stages.ts @@ -1,4 +1,4 @@ -import { Stage } from "@slippi/slippi-js"; +import { Stage, stages as stageUtils } from "@slippi/slippi-js"; export { Stage } from "@slippi/slippi-js"; @@ -8,140 +8,24 @@ export interface StageInfo { shortName?: string; } -const stagesMap = new Map() - .set(Stage.FOUNTAIN_OF_DREAMS, { - id: Stage.FOUNTAIN_OF_DREAMS, - name: "Fountain of Dreams", - shortName: "FoD", - }) - .set(Stage.POKEMON_STADIUM, { - id: Stage.POKEMON_STADIUM, - name: "Pokémon Stadium", - shortName: "PS", - }) - .set(Stage.PEACHS_CASTLE, { - id: Stage.PEACHS_CASTLE, - name: "Princess Peach's Castle", - }) - .set(Stage.KONGO_JUNGLE, { - id: Stage.KONGO_JUNGLE, - name: "Kongo Jungle", - }) - .set(Stage.BRINSTAR, { - id: Stage.BRINSTAR, - name: "Brinstar", - }) - .set(Stage.CORNERIA, { - id: Stage.CORNERIA, - name: "Corneria", - }) - .set(Stage.YOSHIS_STORY, { - id: Stage.YOSHIS_STORY, - name: "Yoshi's Story", - shortName: "YS", - }) - .set(Stage.ONETT, { - id: Stage.ONETT, - name: "Onett", - }) - .set(Stage.MUTE_CITY, { - id: Stage.MUTE_CITY, - name: "Mute City", - }) - .set(Stage.RAINBOW_CRUISE, { - id: Stage.RAINBOW_CRUISE, - name: "Rainbow Cruise", - }) - .set(Stage.JUNGLE_JAPES, { - id: Stage.JUNGLE_JAPES, - name: "Jungle Japes", - }) - .set(Stage.GREAT_BAY, { - id: Stage.GREAT_BAY, - name: "Great Bay", - }) - .set(Stage.HYRULE_TEMPLE, { - id: Stage.HYRULE_TEMPLE, - name: "Hyrule Temple", - }) - .set(Stage.BRINSTAR_DEPTHS, { - id: Stage.BRINSTAR_DEPTHS, - name: "Brinstar Depths", - }) - .set(Stage.YOSHIS_ISLAND, { - id: Stage.YOSHIS_ISLAND, - name: "Yoshi's Island", - }) - .set(Stage.GREEN_GREENS, { - id: Stage.GREEN_GREENS, - name: "Green Greens", - }) - .set(Stage.FOURSIDE, { - id: Stage.FOURSIDE, - name: "Fourside", - }) - .set(Stage.MUSHROOM_KINGDOM, { - id: Stage.MUSHROOM_KINGDOM, - name: "Mushroom Kingdom I", - }) - .set(Stage.MUSHROOM_KINGDOM_2, { - id: Stage.MUSHROOM_KINGDOM_2, - name: "Mushroom Kingdom II", - }) - .set(Stage.VENOM, { - id: Stage.VENOM, - name: "Venom", - }) - .set(Stage.POKE_FLOATS, { - id: Stage.POKE_FLOATS, - name: "Poké Floats", - }) - .set(Stage.BIG_BLUE, { - id: Stage.BIG_BLUE, - name: "Big Blue", - }) - .set(Stage.ICICLE_MOUNTAIN, { - id: Stage.ICICLE_MOUNTAIN, - name: "Icicle Mountain", - }) - .set(Stage.ICETOP, { - id: Stage.ICETOP, - name: "Icetop", - }) - .set(Stage.FLAT_ZONE, { - id: Stage.FLAT_ZONE, - name: "Flat Zone", - }) - .set(Stage.DREAMLAND, { - id: Stage.DREAMLAND, - name: "Dream Land N64", - shortName: "DL", - }) - .set(Stage.YOSHIS_ISLAND_N64, { - id: Stage.YOSHIS_ISLAND_N64, - name: "Yoshi's Island N64", - }) - .set(Stage.KONGO_JUNGLE_N64, { - id: Stage.KONGO_JUNGLE_N64, - name: "Kongo Jungle N64", - }) - .set(Stage.BATTLEFIELD, { - id: Stage.BATTLEFIELD, - name: "Battlefield", - shortName: "BF", - }) - .set(Stage.FINAL_DESTINATION, { - id: Stage.FINAL_DESTINATION, - name: "Final Destination", - shortName: "FD", - }); +const shortNames = new Map() + .set(Stage.FOUNTAIN_OF_DREAMS, "FoD") + .set(Stage.POKEMON_STADIUM, "PS") + .set(Stage.YOSHIS_STORY, "YS") + .set(Stage.DREAMLAND, "DL") + .set(Stage.BATTLEFIELD, "BF") + .set(Stage.FINAL_DESTINATION, "FD"); export function getStageInfo(stageId: number): StageInfo { - const s = stagesMap.get(stageId); + const s = stageUtils.getStageInfo(stageId); if (!s) { throw new Error(`Invalid stage with id ${stageId}`); } - return s; + const shortName = shortNames.get(stageId); + return { + ...s, + shortName, + }; } export function getStageName(stageId: number): string { From 2ab6165f5f8c5f87b1d2b5cbbf62b1c08523f86c Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 11:40:22 +1100 Subject: [PATCH 11/19] Update slippi-js dependency --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ba8cf65..d42914c 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "realtime" ], "dependencies": { - "@slippi/slippi-js": "^5.1.0", + "@slippi/slippi-js": "^5.1.1", "chokidar": "^3.3.1", "fs-extra": "^8.1.0", "lodash": "^4.17.19", diff --git a/yarn.lock b/yarn.lock index eb4b23c..74e4ba7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -458,10 +458,10 @@ resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5" integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ== -"@slippi/slippi-js@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.1.0.tgz#ec523179d07b48fde94036080c4abd1b6eab4cc4" - integrity sha512-u9RWxFU8oDzv5COCmA2lSnQzcgFwEliFNKijDfzKRlnQ68AuIFz/RFOaP+YwWegvarTYVU29RdDtnD1+oAjlpw== +"@slippi/slippi-js@^5.1.1": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-5.1.1.tgz#63dc0ba131019fcaf9fe01417c6ecbe53db095aa" + integrity sha512-5iutrhwfjQNA2Ri9vzWM30wsAY43MVzSWT/hW/CkqS3jEU/I8PIpn5kMVLz2gESYnYOjOSTCB4sqEQJBLrBBSA== dependencies: "@shelacek/ubjson" "^1.0.1" enet "^0.2.9" From 0866fb3995bae9be352b0f825215bdfd2938d412 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 11:58:11 +1100 Subject: [PATCH 12/19] Update tsconfig to target es2018 --- tsconfig.json | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 4d0404a..80a0239 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,18 +2,16 @@ "compilerOptions": { "declaration": true, "declarationDir": "./dist", - "module": "es6", + "module": "esnext", "noImplicitAny": true, "moduleResolution": "node", "outDir": "./dist", - "target": "es5", + "target": "es2018", "esModuleInterop": true, - "downlevelIteration": true + "downlevelIteration": true, + "sourceMap": true, + "lib": ["esnext"] }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "include": ["src/**/*"], + "exclude": ["node_modules"] +} From 9864af3a09a5f1b35994c6729916f42eb635d56d Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 11:40:31 +1100 Subject: [PATCH 13/19] 3.1.0-beta.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d42914c..07ee0cf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@vinceau/slp-realtime", "description": "Realtime slp parsing", "license": "MIT", - "version": "3.1.0-beta.2", + "version": "3.1.0-beta.3", "repository": "vinceau/slp-realtime", "engines": { "node": ">=10" From 91a749dd08700436b993de860d9ee1ec6a308ef2 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 16:22:53 +1100 Subject: [PATCH 14/19] Read Dolphin playback events by default --- src/utils/dolphin/launcher.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/dolphin/launcher.ts b/src/utils/dolphin/launcher.ts index e23d72a..165bc65 100644 --- a/src/utils/dolphin/launcher.ts +++ b/src/utils/dolphin/launcher.ts @@ -9,6 +9,7 @@ const defaultDolphinLauncherOptions = { meleeIsoPath: "", // Path to Melee iso batch: false, // Quit Dolphin when playback queue ends disableSeekBar: false, // Disable the Dolphin seek bar + readEvents: true, // Track the Dolphin playback events over stdout startBuffer: 1, // Sometimes Dolphin misses the start frame so start from the following frame endBuffer: 1, // Match the start frame because why not }; @@ -62,6 +63,9 @@ export class DolphinLauncher { if (this.options.meleeIsoPath) { params.push("-e", this.options.meleeIsoPath); } + if (this.options.readEvents) { + params.push("-c"); + } if (this.options.batch) { params.push("-b"); } From 00c40dbc2362b74091d2528e61dece6428180bd9 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 16:23:02 +1100 Subject: [PATCH 15/19] 3.1.0-beta.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 07ee0cf..08c94af 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@vinceau/slp-realtime", "description": "Realtime slp parsing", "license": "MIT", - "version": "3.1.0-beta.3", + "version": "3.1.0-beta.4", "repository": "vinceau/slp-realtime", "engines": { "node": ">=10" From 74aeeda67af2794a3d02dbe942e0dc6a07f27dc0 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 16:32:52 +1100 Subject: [PATCH 16/19] Stop auto-pushing post-publish --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 08c94af..c184a48 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "minor": "npm version minor && npm publish", "major": "npm version major && npm publish", "prepublishOnly": "yarn run lint && yarn run test && yarn run build", - "postpublish": "git push origin master --follow-tags", "docs": "yarn typedoc --excludePrivate --excludeNotExported --exclude \"**/*+(.spec).ts\"", "postdocs": "touch docs/.nojekyll" }, From 69395f4ad861d22eedefd70d566d52d3522b28e2 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 22:55:20 +1100 Subject: [PATCH 17/19] Fix incorrect dolphin parameter --- src/utils/dolphin/launcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/dolphin/launcher.ts b/src/utils/dolphin/launcher.ts index 165bc65..11a64f5 100644 --- a/src/utils/dolphin/launcher.ts +++ b/src/utils/dolphin/launcher.ts @@ -64,7 +64,7 @@ export class DolphinLauncher { params.push("-e", this.options.meleeIsoPath); } if (this.options.readEvents) { - params.push("-c"); + params.push("-co"); } if (this.options.batch) { params.push("-b"); From af6d9019c78017d977d6b4224d979a759191a7f5 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Fri, 27 Nov 2020 22:55:38 +1100 Subject: [PATCH 18/19] 3.1.0-beta.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c184a48..b43e3b6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@vinceau/slp-realtime", "description": "Realtime slp parsing", "license": "MIT", - "version": "3.1.0-beta.4", + "version": "3.1.0-beta.5", "repository": "vinceau/slp-realtime", "engines": { "node": ">=10" From 97907522c7a1809fbd73ef79436f69638e7bf328 Mon Sep 17 00:00:00 2001 From: Vince Au Date: Thu, 10 Dec 2020 12:38:15 +1100 Subject: [PATCH 19/19] 3.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b43e3b6..c97f41b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@vinceau/slp-realtime", "description": "Realtime slp parsing", "license": "MIT", - "version": "3.1.0-beta.5", + "version": "3.1.0", "repository": "vinceau/slp-realtime", "engines": { "node": ">=10"