Skip to content

Commit

Permalink
Merge pull request #355 from mcottontensor/more_ts_options
Browse files Browse the repository at this point in the history
Enabled a few more ts compiler options
  • Loading branch information
mcottontensor authored Dec 11, 2024
2 parents c34a955 + cf6f1bf commit 601810b
Show file tree
Hide file tree
Showing 40 changed files with 7,152 additions and 5,802 deletions.
14 changes: 7 additions & 7 deletions Common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@types/jest": "27.5.1",
"@types/jest": "^29.5.14",
"@types/webxr": "^0.5.1",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"cspell": "^4.1.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-tsdoc": "^0.2.17",
"jest": "^27.5.1",
"jest-environment-jsdom": "27.5.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "3.3.3",
"rimraf": "^5.0.5",
"ts-jest": "27.1.5",
"ts-jest": "^29.2.5",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.2",
"typedoc": "^0.25.8",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^4.9.4"
"typedoc": "^0.27.4",
"typedoc-plugin-markdown": "^4.3.2",
"typescript": "^5.0.0"
},
"author": "Epic Games",
"license": "MIT",
Expand Down
8 changes: 6 additions & 2 deletions Common/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"noImplicitAny": true,
"esModuleInterop": true,
"target": "ES6",
"moduleResolution": "nodenext",
"sourceMap": true,
"allowJs": true,
"strict": true
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitOverride": false, // generated code breaks this
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true
},
"include": ["./src/*.ts"],
"typedocOptions": {
Expand Down
3 changes: 2 additions & 1 deletion Common/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./build/esm",
"module": "es2015"
"module": "nodenext",
"moduleResolution": "nodenext",
}
}
9 changes: 8 additions & 1 deletion Extras/FrontendTests/tests/extras.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Page } from 'playwright';
import { Streamer, DataProtocol } from '@epicgames-ps/js-streamer';
import { PixelStreaming } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.5';
import { delay } from './helpers';

declare global {
interface Window {
Expand Down Expand Up @@ -82,10 +83,16 @@ export function getCapturedEvents(streamerPage: Page): Promise<Record<string, Da
});
}

export async function getEventsFor(streamerPage: Page, performAction: () => Promise<void>): Promise<Record<string, DataChannelEvent[]>> {
export async function getEventSetFrom(streamerPage: Page, performAction: () => Promise<void>): Promise<Record<string, DataChannelEvent[]>> {
await setupEventCapture(streamerPage);
await performAction();
await delay(5); // just give a little time for the events to come through
await teardownEventCapture(streamerPage);
return await getCapturedEvents(streamerPage);
}

export function getEvents(eventSet: Record<string, DataChannelEvent[]>, playerId?: string): DataChannelEvent[] {
playerId = playerId || Object.keys(eventSet)[0];
return eventSet[playerId];
}

4 changes: 2 additions & 2 deletions Extras/FrontendTests/tests/keyboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from './matchers';
import {
PSEventTypes,
DataChannelEvent,
getEventsFor,
getEventSetFrom,
} from './extras';
import * as helpers from './helpers';

Expand All @@ -27,7 +27,7 @@ test('Test keyboard events', {
// of codes that varied per browser and other odd behaviour. If we DO want to do that we will need
// to figure out how to unify what the browser sends and what we're looking for.
const expectedActions: DataChannelEvent[] = [];
const events = await getEventsFor(streamerPage, async () => {
const events = await getEventSetFrom(streamerPage, async () => {
const startCode = 'A'.charCodeAt(0);
const endCode = 'Z'.charCodeAt(0);
for (let c = startCode; c <= endCode; c++) {
Expand Down
7 changes: 5 additions & 2 deletions Extras/FrontendTests/tests/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const expect = baseExpect.extend({
const assertionName = 'toContainActions';
let pass: boolean = false;
let actionIndex = 0;
if (expected.length > 0) {
if (received && expected.length > 0) {
for (const event of received) {
if (dataChannelActionMatches(expected[actionIndex], event)) {
actionIndex += 1;
Expand All @@ -41,11 +41,14 @@ export const expect = baseExpect.extend({
}

const message = () => {
if (!received) {
return `received null`;
}
if (expected.length == 0) {
return `expected is empty.`;
}
if (!pass) {
return `Could not find action ${actionIndex} : ${JSON.stringify(expected[actionIndex])} in ${JSON.stringify(received)}
return `Could not find action ${actionIndex} : ${JSON.stringify(expected[actionIndex])} in received.
\r\n Expected: ${JSON.stringify(expected)}
\r\n Received: ${JSON.stringify(received)};`
}
Expand Down
24 changes: 12 additions & 12 deletions Extras/FrontendTests/tests/mouse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from './matchers';
import {
PSEventTypes,
DataChannelEvent,
getEventsFor,
getEventSetFrom,
} from './extras';
import * as helpers from './helpers';
import { InputCoordTranslator, TranslatedCoordUnsigned } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.5';
Expand Down Expand Up @@ -33,7 +33,7 @@ test('Test mouse enter/leave', {
expect(playerBox).not.toBeNull();

// perform the actions
const events = await getEventsFor(streamerPage, async () => {
const events = await getEventSetFrom(streamerPage, async () => {
// start outside the view
await page.mouse.move(200, 200);
// move to the top left of the video
Expand Down Expand Up @@ -78,7 +78,7 @@ test('Test mouse wheel', {

// perform the actions
const expectedActions: DataChannelEvent[] = [];
const events = await getEventsFor(streamerPage, async () => {
const events = await getEventSetFrom(streamerPage, async () => {
await page.mouse.wheel(0, 10);
expectedActions.push({ type: PSEventTypes.MouseWheel, delta: (n: number) => { return n < 0 } });
await page.mouse.wheel(0, -15);
Expand Down Expand Up @@ -110,9 +110,9 @@ test('Test locked mouse movement', {
// console.log("Streamer: ", ...args);
// });
//
helpers.attachToConsoleEvents(page, (...args: any[]) => {
console.log("Player: ", ...args);
});
// helpers.attachToConsoleEvents(page, (...args: any[]) => {
// console.log("Player: ", ...args);
// });

await page.goto(`/?StreamerId=${streamerId}&MatchViewportRes=true&HoveringMouse=false`);
await page.getByText('Click to start').click();
Expand Down Expand Up @@ -152,15 +152,15 @@ test('Test locked mouse movement', {
let events : Record<string, DataChannelEvent[]>;

if(browserName == 'firefox') {
events = await getEventsFor(streamerPage, async () => {
events = await getEventSetFrom(streamerPage, async () => {
for (const movement of movements) {
await page.mouse.move(anchor.x + movement.x, anchor.y + movement.y);
const translated = coordConverter.translateSigned(movement.x, movement.y);
expectedActions.push({ type: PSEventTypes.MouseMove, deltaX: Math.trunc(translated.x), deltaY: Math.trunc(translated.y) });
}
});
} else {
events = await getEventsFor(streamerPage, async () => {
events = await getEventSetFrom(streamerPage, async () => {
let mousePos = anchor;
for (const movement of movements) {
mousePos.x += movement.x;
Expand Down Expand Up @@ -217,7 +217,7 @@ test('Test hovering mouse movement', {
];

// perform the actions
const events = await getEventsFor(streamerPage, async () => {
const events = await getEventSetFrom(streamerPage, async () => {
for (const movement of movements) {
await page.mouse.move(movement.x, movement.y);
const translated = coordConverter.translateUnsigned(movement.x, movement.y);
Expand Down Expand Up @@ -275,7 +275,7 @@ test('Test mouse input after resizing. Hover mouse.', {
];

// perform the actions
const events = await getEventsFor(streamerPage, async () => {
const events = await getEventSetFrom(streamerPage, async () => {
for (const movement of movements) {
await page.mouse.move(movement.x, movement.y);
const translated = coordConverter.translateUnsigned(movement.x, movement.y);
Expand Down Expand Up @@ -354,15 +354,15 @@ test('Test mouse input after resizing. locked mouse.', {
let events : Record<string, DataChannelEvent[]>;

if(browserName == 'firefox') {
events = await getEventsFor(streamerPage, async () => {
events = await getEventSetFrom(streamerPage, async () => {
for (const movement of movements) {
await page.mouse.move(anchor.x + movement.x, anchor.y + movement.y);
const translated = coordConverter.translateSigned(movement.x, movement.y);
expectedActions.push({ type: PSEventTypes.MouseMove, deltaX: Math.trunc(translated.x), deltaY: Math.trunc(translated.y) });
}
});
} else {
events = await getEventsFor(streamerPage, async () => {
events = await getEventSetFrom(streamerPage, async () => {
let mousePos = anchor;
for (const movement of movements) {
mousePos.x += movement.x;
Expand Down
13 changes: 6 additions & 7 deletions Extras/FrontendTests/tests/resolution_changes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { expect } from './matchers';
import {
PSEventTypes,
DataChannelEvent,
getEventsFor,
getEventSetFrom,
getEvents,
} from './extras';
import * as helpers from './helpers';

Expand All @@ -16,15 +17,14 @@ test('Test resolution changes with match viewport on.', {
await page.getByText('Click to start').click();
await helpers.waitForVideo(page);

const events = await getEventsFor(streamerPage, async () => {
const events = await getEventSetFrom(streamerPage, async () => {
await page.setViewportSize({ width: 100, height: 100 });
await helpers.delay(1000);
await page.setViewportSize({ width: 800, height: 600 });
await helpers.delay(1000);
});

const firstPlayerId = Object.keys(events)[0];
const singlePlayerEvents = events[firstPlayerId];
const singlePlayerEvents = getEvents(events);
const expectedActions: DataChannelEvent[] = [
{ type: PSEventTypes.Command, command: '{\"Resolution.Width\":100,\"Resolution.Height\":100}' },
{ type: PSEventTypes.Command, command: '{\"Resolution.Width\":800,\"Resolution.Height\":600}' },
Expand All @@ -43,15 +43,14 @@ test('Test resolution changes with match viewport off.', {
await helpers.waitForVideo(page);
await page.click("#streamingVideo");

const events = await getEventsFor(streamerPage, async () => {
const events = await getEventSetFrom(streamerPage, async () => {
await page.setViewportSize({ width: 100, height: 100 });
await helpers.delay(1000);
await page.setViewportSize({ width: 800, height: 600 });
await helpers.delay(1000);
});

const firstPlayerId = Object.keys(events)[0];
const singlePlayerEvents = events[firstPlayerId];
const singlePlayerEvents = getEvents(events);
const expectedActions: DataChannelEvent[] = [
{ type: PSEventTypes.Command, command: '{\"Resolution.Width\":100,\"Resolution.Height\":100}' },
{ type: PSEventTypes.Command, command: '{\"Resolution.Width\":800,\"Resolution.Height\":600}' },
Expand Down
2 changes: 1 addition & 1 deletion Extras/JSStreamer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"nodemon": "^3.1.4",
"prettier": "3.3.3",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"typescript": "^5.0.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4",
"webpack-node-externals": "^3.0.0"
Expand Down
6 changes: 3 additions & 3 deletions Frontend/implementations/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"html-webpack-plugin": "^5.5.0",
"path": "^0.12.7",
"terser-webpack-plugin": "^5.3.10",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"ts-loader": "^9.5.1",
"typescript": "^5.0.0",
"webpack": "^5.94.0",
"webpack-cli": "^5.0.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.11.1"
},
"dependencies": {
Expand Down
14 changes: 7 additions & 7 deletions Frontend/library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
"spellcheck": "cspell \"{README.md,.github/*.md,src/**/*.ts}\""
},
"devDependencies": {
"@types/jest": "27.5.1",
"@types/jest": "^29.5.14",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"cspell": "^4.1.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^27.5.1",
"jest-environment-jsdom": "27.5.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "3.3.3",
"ts-jest": "27.1.5",
"typedoc": "^0.23.24",
"typescript": "^4.9.4"
"ts-jest": "^29.2.5",
"typedoc": "^0.27.4",
"typescript": "^5.0.0"
},
"dependencies": {
"@types/webxr": "^0.5.1",
"@epicgames-ps/lib-pixelstreamingcommon-ue5.5": "^0.1.3",
"@types/webxr": "^0.5.1",
"sdp": "^3.1.0"
},
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions Frontend/library/src/Config/SettingFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { SettingBase } from './SettingBase';
* A boolean flag setting object with a text label.
*/
export class SettingFlag<CustomIds extends string = FlagsIds> extends SettingBase {
id: FlagsIds | CustomIds;
onChangeEmit: (changedValue: boolean) => void;
override id: FlagsIds | CustomIds;
override onChangeEmit: (changedValue: boolean) => void;

constructor(
id: FlagsIds | CustomIds,
Expand All @@ -33,7 +33,7 @@ export class SettingFlag<CustomIds extends string = FlagsIds> extends SettingBas
this.useUrlParams = useUrlParams;
}

protected getValueAsString(): string {
protected override getValueAsString(): string {
return this.flag ? 'true' : 'false';
}

Expand Down
6 changes: 3 additions & 3 deletions Frontend/library/src/Config/SettingNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export class SettingNumber<CustomIds extends string = NumericParametersIds> exte
_min: number | null;
_max: number | null;

id: NumericParametersIds | CustomIds;
onChangeEmit: (changedValue: number) => void;
override id: NumericParametersIds | CustomIds;
override onChangeEmit: (changedValue: number) => void;

constructor(
id: NumericParametersIds | CustomIds,
Expand Down Expand Up @@ -41,7 +41,7 @@ export class SettingNumber<CustomIds extends string = NumericParametersIds> exte
this.useUrlParams = useUrlParams;
}

protected getValueAsString(): string {
protected override getValueAsString(): string {
return this.number.toString();
}

Expand Down
6 changes: 3 additions & 3 deletions Frontend/library/src/Config/SettingOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { SettingBase } from './SettingBase';
* An Option setting object with a text label. Allows you to specify an array of options and select one of them.
*/
export class SettingOption<CustomIds extends string = OptionParametersIds> extends SettingBase {
id: OptionParametersIds | CustomIds;
onChangeEmit: (changedValue: string) => void;
override id: OptionParametersIds | CustomIds;
override onChangeEmit: (changedValue: string) => void;
_options: Array<string>;

/* Transforms the url parameter value into something else, by default no transformation is made, the url param is returned as-is. */
Expand Down Expand Up @@ -45,7 +45,7 @@ export class SettingOption<CustomIds extends string = OptionParametersIds> exten
this.useUrlParams = useUrlParams;
}

protected getValueAsString(): string {
protected override getValueAsString(): string {
return this.selected;
}

Expand Down
Loading

0 comments on commit 601810b

Please sign in to comment.