Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v20
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ request. It's not mandatory at all, but feel free to open an issue to present yo

To start working on the Genymotion device web player, all you need if an HTML page to instanciate a player from your
local copy of this repository.

Build the player in dev mode:

```sh
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ A Modern, WebRTC compatible, Web browser:

## 📦 Installation

### 📥 Install via NPM / Yarn
### 📥 Install via NPM / Yarn

**Node.js 20 or later is required.**

Using yarn:

Expand Down
2 changes: 1 addition & 1 deletion doc/assets/ic_camera.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15,261 changes: 0 additions & 15,261 deletions package-lock.json

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
],
"types": "dist/index.d.ts",
"engines": {
"node": ">=16"
"node": ">=20"
},

"scripts": {
"test": "vitest run",
"test:ui": "vitest --ui",
Expand Down Expand Up @@ -43,6 +44,7 @@
"@babel/preset-env": "^7.18.6",
"@fullhuman/postcss-purgecss": "5.0.0",
"@vitest/ui": "^4.0.15",
"@vitejs/plugin-basic-ssl": "^2.1.0",
"autoprefixer": "10.4.14",
"babel-eslint": "^10.1.0",
"eslint": "^7.32.0",
Expand Down
36 changes: 31 additions & 5 deletions src/DeviceRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export default class DeviceRenderer {
// Event callbacks
this.callbacks = {};

// Plugins/Widgets registry
this.widgets = [];

// Event listeners
this.allListeners = [];

Expand All @@ -77,10 +80,6 @@ export default class DeviceRenderer {
this.signalingDataChannel = null;
this.cameraSender = null;
this.microphoneSender = null;
this.sdpConstraints = {
offerToReceiveAudio: true,
offerToReceiveVideo: true,
};

// last accessed x/y position
this.x = 0;
Expand Down Expand Up @@ -435,7 +434,8 @@ export default class DeviceRenderer {
}
// creating SDP offer
try {
const description = await this.peerConnection.createOffer(this.sdpConstraints);
const description = await this.peerConnection.createOffer();
log.debug('Generated SDP Offer:', description.sdp);
this.setLocalDescription(description);
} catch (error) {
this.onWebRTCConnectionError(error);
Expand Down Expand Up @@ -470,6 +470,7 @@ export default class DeviceRenderer {

const config = {
iceServers: iceServers,
bundlePolicy: 'max-compat',
};

if (!this.peerConnection) {
Expand All @@ -488,6 +489,13 @@ export default class DeviceRenderer {
this.useWebsocketAsDataChannel = true;
}

/*
* Add transceivers to receive audio and video (VM screen/audio)
* This replaces the legacy offerToReceiveAudio/Video constraints
*/
this.peerConnection.addTransceiver('audio', {direction: 'recvonly'});
this.peerConnection.addTransceiver('video', {direction: 'recvonly'});

this.peerConnection.onicecandidate = (event) => {
if (typeof event.candidate === 'undefined') {
// Nothing we can do
Expand Down Expand Up @@ -971,6 +979,24 @@ export default class DeviceRenderer {
return;
}

// Cleanup specific widget resources dynamically
this.widgets.forEach((widget) => {
if (widget && typeof widget.destroy === 'function') {
widget.destroy();
}
});

if (this.store && this.store.destroy) {
this.store.destroy();
}

if (this.fileUploaderWorkerBlobSRC) {
URL.revokeObjectURL(this.fileUploaderWorkerBlobSRC);
this.fileUploaderWorkerBlobSRC = null;
}

this.emit('destroyed');

this.removeAllListeners();
this.disconnect();
this.peerConnectionStats?.destroy();
Expand Down
9 changes: 3 additions & 6 deletions src/DeviceRendererFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ const defaultOptions = {
* Setup & create instances of the device renderer
*/
export default class DeviceRendererFactory {
constructor() {
this.instances = [];
}
constructor() {}

/**
* Setup a device renderer instance in the given dom element, for the device instance identified by its instanceWebRTCUrl.
Expand Down Expand Up @@ -170,8 +168,6 @@ export default class DeviceRendererFactory {
instance.toolbarManager = new ToolbarManager(instance);
instance.tooltipManager = new TooltipManager(instance);

this.instances.push(instance);

this.loadPlugins(instance);
this.loadToolbar(instance);
instance.onWebRTCReady();
Expand Down Expand Up @@ -253,7 +249,8 @@ export default class DeviceRendererFactory {
}
// eslint-disable-next-line no-unused-expressions
if (plugin.class) {
new plugin.class(instance, ...args);
const widget = new plugin.class(instance, ...args);
instance.widgets.push(widget);
}
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/assets/images/ic_camera_disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/assets/images/ic_camera_mic.svg

This file was deleted.

5 changes: 4 additions & 1 deletion src/components/GmDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ export class GmDropdown extends HTMLElement {
* Supported formats:
* - String: 'Item Label'
* - Object (Rich HTML): { element: HTMLElement, value: 'val' }
* - Object (Plain): { value: 'val', valueToDisplay: 'Display Text' }
* Re-renders the options and clears the value if it's no longer present.
* @param {Array<string|{element: HTMLElement, value: any}>} newItems - List of items.
* @param {Array<string|{element: HTMLElement, value: any}|{value: any, valueToDisplay: string}>} newItems - List of items.
*/
set items(newItems) {
this.#items = newItems;
Expand Down Expand Up @@ -224,6 +225,8 @@ export class GmDropdown extends HTMLElement {
optionDiv.innerHTML = item;
} else if (item.element instanceof HTMLElement) {
optionDiv.appendChild(item.element);
} else if (item.valueToDisplay) {
optionDiv.textContent = item.valueToDisplay;
} else {
return;
}
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* Import main SCSS file for webpack to process and bundle styles
* This ensures all styles are included in the final build
Expand Down
Loading