Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Convert frontend javascript to typescript and refactor. #63

Merged
merged 304 commits into from
Feb 7, 2023

Conversation

lukehb
Copy link
Contributor

@lukehb lukehb commented Jan 18, 2023

This PR addresses. #9.


The reference frontend code that ships in this repository is intended to act as a starting point that developers can modify and extend to suit the needs of their Pixel Streaming applications. Unfortunately, the structure of the existing JavaScript code does not enforce a clean separation between the base code and any custom modifications, intermingling everything in a way that makes it difficult to change either the base code or the modifications in isolation. This makes the process of porting customisations from one version of the frontend to another a tedious and labour-intensive process, significantly hindering developers' ability to update their code when new versions of the frontend are released. This is particularly problematic when considering the fact that new releases of web browsers can break the frontend (and this has happened multiple times in the past), so the ability to consume updates as quickly and easily as possible is critical to ensuring that Pixel Streaming applications remain accessible to all users when deployed in a production environment.

To address these limitations, this pull request draws on code from the TypeScript frontend implementation used by Scalable Pixel Streaming and merges it into the upstream reference implementation, with additional changes and improvements to ensure parity with the functionality present in the existing JavaScript implementation. The Scalable Pixel Streaming frontend code was contributed by my colleagues Adam Rehn, Adrian Zahra, Daniel Holden and David MacPherson from TensorWorks.

The new TypeScript library is a modular and extensible package that has been explicitly designed to ensure a clean separation between the base code and any custom modifications. The new TypeScript implementation acts as a drop-in replacement for the existing JavaScript implementation and introduces the following benefits:

  • Works with modern web development workflows: once the accompanying GitHub Actions CI/CD workflows are in place, the TypeScript library will be provided as both an NPM package through GitHub Packages and a UMD module through this repository's releases, making it easy to consume the library from either TypeScript code or plain JavaScript code using modern web development tools and workflows.

  • Easy to integrate with frontend web frameworks: all of the core logic in the library can be overridden by extending the base Application class and providing alternate implementations for the relevant methods. This makes it straightforward to write derived implementations that integrate the library with anything from plain DOM APIs all the way through to complex frontend web frameworks. The library ships with a default implementation that demonstrates the use of the base Application class with its default behaviour, which can be used as a drop-in replacement for the existing HTML, CSS and JavaScript shipped in this repository.

  • Easy to update: the clean separation between the core logic and custom derived implementations allows developers to rapidly update to new releases of the frontend and stay on top of any WebRTC changes in new web browser updates. Simply update the dependency version where you reference the library (e.g. build configuration files or a <script> tag) and you're good to go.

  • Supports custom protocol extensions: the TypeScript library makes it possible to extend the WebSocket protocol used to communicate with the Pixel Streaming signalling server, by providing hooks for registering custom message types. This allows downstream projects that use custom signalling servers (e.g. Scalable Pixel Streaming) to consume the reference frontend library whilst still retaining support for their specific protocol extensions.

adrianZahra and others added 30 commits June 21, 2022 12:24
lukehb and others added 2 commits January 23, 2023 08:44
Add missing typescript dependency.

Co-authored-by: hmuurine <hmuurine@users.noreply.github.com>
Signed-off-by: Luke Bermingham <1215582+lukehb@users.noreply.github.com>
Add missing typescripe and webpack dependencies.

Co-authored-by: hmuurine <hmuurine@users.noreply.github.com>
Signed-off-by: Luke Bermingham <1215582+lukehb@users.noreply.github.com>
Copy link
Collaborator

@hmuurine hmuurine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decoupling the default UI from the business logic and providing the functionality as a library might not be in the scope of this PR, so maybe those should be left for the future. The main thing here was Typescript conversion, which looks good to me! 👍

(Maybe could reword the title of this PR before merge?)

@lukehb lukehb changed the title Move frontend code from monolithic javascript file to a typescript library. Convert frontend javascript to typescript and refactor. Feb 2, 2023
@lukehb lukehb merged commit 61e8273 into EpicGames:master Feb 7, 2023
@lukehb
Copy link
Contributor Author

lukehb commented Feb 7, 2023

As @hmuurine mentioned, there is additional work of decoupling the UI from the core library. This is a separate issue - as tracked here: #66

Users should expect that decoupling work to land later (some time before (or a bit after) UE 5.2).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants