Skip to content

Feature/device ss #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1237121
responsive and android mockup
50calDhruv Feb 19, 2025
0feba8f
handled bigger displays
50calDhruv Feb 19, 2025
87296c5
added resize listener
50calDhruv Feb 20, 2025
66ae486
handled screen rotation and removed 3 dots menu
50calDhruv Feb 24, 2025
c3d7a01
adjusted touch layer
50calDhruv Feb 24, 2025
df3fec3
respositioning
50calDhruv Feb 25, 2025
1a11748
added development script and improved device filtering with logging
himanshkukreja Feb 26, 2025
cf3a610
refactor device tracking logic and enhance logging for better state m…
himanshkukreja Feb 27, 2025
ab5c7ce
fix: emit device event for connected devices in ControlCenter
himanshkukreja Feb 27, 2025
d302b49
added mockup frame
50calDhruv Mar 3, 2025
ddc0475
adjusted margins
50calDhruv Mar 3, 2025
236c5af
refactor: remove commented-out console logs for cleaner code
himanshkukreja Mar 3, 2025
cb9d369
Merge branch 'master' of https://github.com/AutoFlowLabs/ws-scrcpy
himanshkukreja Mar 3, 2025
0740682
removed a couple logs
50calDhruv Mar 3, 2025
67dd411
Merge branch 'master' of https://github.com/AutoFlowLabs/ws-scrcpy
50calDhruv Mar 3, 2025
8bfd000
refactor: comment out deviceList logging for cleaner output
himanshkukreja Mar 4, 2025
32f0681
adjusted touch-layer, video-layer and mock frame
50calDhruv Mar 4, 2025
1bc928a
Merge branch 'master' of https://github.com/AutoFlowLabs/ws-scrcpy
50calDhruv Mar 4, 2025
49de923
feat: add basic authentication and logout functionality
himanshkukreja Mar 7, 2025
46f56fa
feat: enhance request handling with logging and authentication middle…
himanshkukreja Mar 7, 2025
0c1dd31
refactor: comment out logging statements for cleaner output
himanshkukreja Mar 7, 2025
0e52fbf
feat: add styled logout button to the main interface
himanshkukreja Mar 7, 2025
cbad37d
fix: reposition logout button to the left side of the interface
himanshkukreja Mar 7, 2025
d58c668
feat: dynamically create and append logout button on index page
himanshkukreja Mar 7, 2025
b4f7f9a
feat: implement HMAC-SHA256 signature verification for secure requests
himanshkukreja Mar 8, 2025
8076254
fix: use Buffer.from for SECRET_KEY in HMAC-SHA256 signature calculation
himanshkukreja Mar 8, 2025
7267ee9
fix: update signature verification to use base64url encoding for HMAC…
himanshkukreja Mar 8, 2025
4cd758a
feat: add logging for signature verification process in HMAC-SHA256
himanshkukreja Mar 8, 2025
448c4d8
feat: enhance signature verification by logging full URL and received…
himanshkukreja Mar 8, 2025
9513879
fix: enforce HTTPS protocol in full URL construction for requests
himanshkukreja Mar 8, 2025
b123be0
fix: revert base64url conversion in signature comparison logic
himanshkukreja Mar 8, 2025
f906b68
fix: update signature comparison to use base64url encoding
himanshkukreja Mar 8, 2025
5769111
feat: remove debug logging for signature verification process
himanshkukreja Mar 8, 2025
1a5a0fc
fix: adjust protocol selection for localhost in URL construction
himanshkukreja Mar 8, 2025
8294559
fix: remove debug logging for SECRET_KEY in signature verification
himanshkukreja Mar 8, 2025
c90631b
updated for inactivity tracking
50calDhruv Mar 17, 2025
f281033
Merge branch 'master' of https://github.com/AutoFlowLabs/ws-scrcpy
50calDhruv Mar 17, 2025
c270cc7
updated for full screen
50calDhruv Mar 18, 2025
ffa4efa
added listener to capture and send back device ss
50calDhruv Mar 25, 2025
33c17f2
added origin check when responding to ss request
50calDhruv Mar 25, 2025
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
14 changes: 11 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dist:prod": "webpack --config webpack/ws-scrcpy.prod.ts --stats-error-details",
"dist": "npm run dist:prod",
"start": "npm run dist && cd dist && npm start",
"dev": "npm run dist:dev && cd dist && npm start",
"script:dist:start": "node ./index.js",
"lint": "eslint src/ --ext .ts",
"format": "eslint src/ --fix --ext .ts",
Expand All @@ -18,6 +19,7 @@
"dependencies": {
"@dead50f7/adbkit": "^2.11.4",
"express": "^4.21.2",
"express-basic-auth": "^1.2.1",
"ios-device-lib": "^0.9.2",
"node-mjpeg-proxy": "^0.3.2",
"node-pty": "^0.10.1",
Expand Down
10 changes: 9 additions & 1 deletion src/app/DisplayInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ export class DisplayInfo {
public readonly rotation: number,
public readonly layerStack: number,
public readonly flags: number,
) {}
) {
const deviceViewElem = document.getElementsByClassName('device-view')[0] as HTMLElement;
if( rotation && deviceViewElem ){
deviceViewElem.style.maxWidth = "none";
}
else if( deviceViewElem ){
deviceViewElem.style.maxWidth = "460px";
}
}

public toBuffer(): Buffer {
const temp = Buffer.alloc(DisplayInfo.BUFFER_LENGTH);
Expand Down
6 changes: 6 additions & 0 deletions src/app/client/BaseDeviceTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,19 @@ export abstract class BaseDeviceTracker<DD extends BaseDeviceDescriptor, TE exte

protected buildDeviceTable(): void {
const data = this.descriptors;
// console.log(TAG, 'Building table for', data);
const devices = this.getOrCreateTableHolder();
const tbody = this.getOrBuildTableBody(devices);

const block = this.getOrCreateTrackerBlock(tbody, this.trackerName);
// Refresh the page
// console.log('Refreshing the page');
// window.location.reload();
data.forEach((item) => {
// console.log(TAG, 'Building row (after initiating refresh)', item);
this.buildDeviceRow(block, item);
});

}

private setNameValue(parent: Element | null, name: string): void {
Expand Down
2 changes: 2 additions & 0 deletions src/app/client/StreamReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type DisplayCombinedInfo = {
interface StreamReceiverEvents {
video: ArrayBuffer;
deviceMessage: DeviceMessage;
rotated: any;
displayInfo: DisplayCombinedInfo[];
clientsStats: ClientsStats;
encoders: string[];
Expand Down Expand Up @@ -67,6 +68,7 @@ export class StreamReceiver<P extends ParamsStream> extends ManagerClient<Params
for (let i = 0; i < displaysCount; i++) {
const displayInfoBuffer = rest.slice(0, DisplayInfo.BUFFER_LENGTH);
const displayInfo = DisplayInfo.fromBuffer(displayInfoBuffer);
this.emit("rotated", displayInfo.rotation);
const { displayId } = displayInfo;
this.displayInfoMap.set(displayId, displayInfo);
rest = rest.slice(DisplayInfo.BUFFER_LENGTH);
Expand Down
2 changes: 2 additions & 0 deletions src/app/googDevice/client/DeviceTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ export class DeviceTracker extends BaseDeviceTracker<GoogDeviceDescriptor, never
}

protected buildDeviceRow(tbody: Element, device: GoogDeviceDescriptor): void {
// console.log('buildDeviceRow:', device);
let selectedInterfaceUrl = '';
let selectedInterfaceName = '';
const blockClass = 'desc-block';
const fullName = `${this.id}_${Util.escapeUdid(device.udid)}`;
const isActive = device.state === DeviceState.DEVICE;
// console.log('isActive:', isActive);
let hasPid = false;
const servicesId = `device_services_${fullName}`;
const row = html`<div class="device ${isActive ? 'active' : 'not-active'}">
Expand Down
7 changes: 7 additions & 0 deletions src/app/googDevice/client/StreamClientScrcpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ACTION } from '../../../common/Action';
import { StreamReceiverScrcpy } from './StreamReceiverScrcpy';
import { ParamsDeviceTracker } from '../../../types/ParamsDeviceTracker';
import { ScrcpyFilePushStream } from '../filePush/ScrcpyFilePushStream';
import genericAndroid from "../../../common/generic_android.png"

type StartParams = {
udid: string;
Expand Down Expand Up @@ -320,6 +321,11 @@ export class StreamClientScrcpy
deviceView.appendChild(this.controlButtons);
const video = document.createElement('div');
video.className = 'video';
const genericAndroidMockup = document.createElement("img");
genericAndroidMockup.src = genericAndroid;
genericAndroidMockup.id = "generic-android-mockup";
genericAndroidMockup.style.height = "";
video.appendChild(genericAndroidMockup);
deviceView.appendChild(video);
deviceView.appendChild(moreBox);
player.setParent(video);
Expand All @@ -340,6 +346,7 @@ export class StreamClientScrcpy

const streamReceiver = this.streamReceiver;
streamReceiver.on('deviceMessage', this.OnDeviceMessage);
streamReceiver.on('rotated', ()=>{ this.player?.reOrientScreen(true, this.player) });
streamReceiver.on('video', this.onVideo);
streamReceiver.on('clientsStats', this.onClientsStats);
streamReceiver.on('displayInfo', this.onDisplayInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/app/googDevice/toolbox/GoogToolBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class GoogToolBox extends ToolBox {
const element = el.getElement();
moreBox.style.display = element.checked ? 'block' : 'none';
});
elements.unshift(more);
// elements.unshift(more);
}
return new GoogToolBox(elements);
}
Expand Down
17 changes: 16 additions & 1 deletion src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@ import { StreamClientScrcpy } from './googDevice/client/StreamClientScrcpy';
import { HostTracker } from './client/HostTracker';
import { Tool } from './client/Tool';


window.onload = async function (): Promise<void> {
// Redirect if the URL contains a hash fragment
const hash = location.hash.replace(/^#!/, '');
const parsedQuery = new URLSearchParams(hash);
if (hash) {

const parsedQuery = new URLSearchParams(hash);

// Add `hasHash=true` to the query parameters
parsedQuery.set('hasHash', 'true');

// Redirect to a query-based URL
window.location.href = `/?${parsedQuery.toString()}`;
return; // Stop further execution
}

// If no hash fragment, proceed with the rest of the logic
const parsedQuery = new URLSearchParams(location.search); // Use query parameters instead of hash
const action = parsedQuery.get('action');

/// #if USE_BROADWAY
Expand Down
Loading