Skip to content
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

Update deps #218

Merged
merged 3 commits into from
Aug 4, 2022
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
21,392 changes: 5,903 additions & 15,489 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Web client for scrcpy and more",
"scripts": {
"clean": "npx rimraf dist",
"dist:dev": "webpack --config webpack/ws-scrcpy.dev.ts --env.config_override='./build.config.override.json'",
"dist:prod": "webpack --config webpack/ws-scrcpy.prod.ts --env.config_override='./build.config.override.json'",
"dist:dev": "webpack --config webpack/ws-scrcpy.dev.ts --stats-error-details",
"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",
"script:dist:start": "node ./index.js",
Expand All @@ -16,7 +16,7 @@
"author": "Sergey Volkov <[email protected]>",
"license": "MIT",
"dependencies": {
"@devicefarmer/adbkit": "^2.11.3",
"@dead50f7/adbkit": "^2.11.4",
"express": "^4.17.3",
"ios-device-lib": "^0.9.2",
"node-mjpeg-proxy": "^0.3.2",
Expand All @@ -27,14 +27,13 @@
"yaml": "^2.0.0"
},
"devDependencies": {
"@dead50f7/generate-package-json-webpack-plugin": "^2.6.1",
"@types/bluebird": "^3.5.36",
"@types/dom-webcodecs": "^0.1.3",
"@types/express": "^4.17.13",
"@types/mini-css-extract-plugin": "^0.9.1",
"@types/node": "^12.20.47",
"@types/node-forge": "^0.10.0",
"@types/npmlog": "^4.1.4",
"@types/webpack": "^4.41.32",
"@types/webpack-node-externals": "^2.5.3",
"@types/ws": "^7.4.7",
"@typescript-eslint/eslint-plugin": "^5.18.0",
Expand All @@ -47,23 +46,23 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-progress": "0.0.1",
"file-loader": "^6.2.0",
"generate-package-json-webpack-plugin": "^2.6.0",
"h264-converter": "^0.1.4",
"html-webpack-plugin": "^4.5.2",
"html-webpack-plugin": "^5.5.0",
"ifdef-loader": "^2.3.2",
"mini-css-extract-plugin": "^0.11.2",
"mini-css-extract-plugin": "^2.6.1",
"mkdirp": "^1.0.4",
"path-browserify": "^1.0.1",
"prettier": "^2.6.2",
"recursive-copy": "^2.0.14",
"rimraf": "^3.0.0",
"svg-inline-loader": "^0.8.2",
"sylvester.js": "^0.1.1",
"tinyh264": "^0.0.7",
"ts-loader": "^8.3.0",
"ts-node": "^9.1.1",
"typescript": "^3.9.10",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"ts-loader": "^9.3.1",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-node-externals": "^2.5.2",
"worker-loader": "^3.0.8",
"xterm": "^4.5.0",
Expand Down
53 changes: 45 additions & 8 deletions src/app/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,44 @@ export default class Util {
return 'udid_' + udid.replace(/[. :]/g, '_');
}

public static parseBooleanEnv(input: string | string[] | boolean | undefined): boolean | undefined {
public static parse(params: URLSearchParams, name: string, required?: boolean): string | null {
const value = params.get(name);
if (required && value === null) {
throw TypeError(`Missing required parameter "${name}"`);
}
return value;
}

public static parseString(params: URLSearchParams, name: string, required?: boolean): string {
const value = params.get(name);
if (required && value === null) {
throw TypeError(`Missing required parameter "${name}"`);
}
return value || '';
}

public static parseBoolean(params: URLSearchParams, name: string, required?: boolean): boolean {
const value = this.parse(params, name, required);
return value === '1' || (!!value && value.toString() === 'true');
}

public static parseInt(params: URLSearchParams, name: string, required?: boolean): number {
const value = this.parse(params, name, required);
if (value === null) {
return 0;
}
const int = parseInt(value, 10);
if (isNaN(int)) {
return 0;
}
return int;
}

public static parseBooleanEnv(input: string | string[] | boolean | undefined | null): boolean | undefined {
if (typeof input === 'boolean') {
return input;
}
if (typeof input === 'undefined') {
if (typeof input === 'undefined' || input === null) {
return undefined;
}
if (Array.isArray(input)) {
Expand All @@ -42,20 +75,20 @@ export default class Util {
return input === '1' || input.toLowerCase() === 'true';
}

public static parseStringEnv(input: string | string[] | undefined): string {
if (typeof input === 'undefined') {
return '';
public static parseStringEnv(input: string | string[] | undefined | null): string | undefined {
if (typeof input === 'undefined' || input === null) {
return undefined;
}
if (Array.isArray(input)) {
input = input[input.length - 1];
}
return input;
}
public static parseIntEnv(input: string | string[] | number | undefined): number | undefined {
public static parseIntEnv(input: string | string[] | number | undefined | null): number | undefined {
if (typeof input === 'number') {
return input;
}
if (typeof input === 'undefined') {
if (typeof input === 'undefined' || input === null) {
return undefined;
}
if (Array.isArray(input)) {
Expand Down Expand Up @@ -172,11 +205,15 @@ export default class Util {
window.addEventListener('testPassive', null, opts);
// @ts-ignore
window.removeEventListener('testPassive', null, opts);
} catch (e) {}
} catch (error: any) {}

return Util.supportsPassiveValue = supportsPassive;

// Use our detect's results. passive applied if supported, capture will be false either way.
// elem.addEventListener('touchstart', fn, supportsPassive ? { passive: true } : false);
}

static setImmediate(fn: () => any): void {
Promise.resolve().then(fn);
}
}
13 changes: 6 additions & 7 deletions src/app/applDevice/client/StreamClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { SimpleInteractionHandler } from '../../interactionHandler/SimpleInterac
import { BasePlayer, PlayerClass } from '../../player/BasePlayer';
import ScreenInfo from '../../ScreenInfo';
import { WdaProxyClient } from './WdaProxyClient';
import { ParsedUrlQuery, ParsedUrlQueryInput } from 'querystring';
import { ACTION } from '../../../common/Action';
import { ApplMoreBox } from '../toolbox/ApplMoreBox';
import { ApplToolBox } from '../toolbox/ApplToolBox';
Expand Down Expand Up @@ -71,7 +70,7 @@ export abstract class StreamClient<T extends ParamsStream> extends BaseClient<T,
playerTd.classList.add(blockClass);
playerTd.setAttribute(DeviceTracker.AttributePlayerFullName, encodeURIComponent(playerFullName));
playerTd.setAttribute(DeviceTracker.AttributePlayerCodeName, encodeURIComponent(playerCodeName));
const q: ParsedUrlQueryInput = {
const q: any = {
action: this.ACTION,
player: playerCodeName,
udid: descriptor.udid,
Expand Down Expand Up @@ -104,7 +103,7 @@ export abstract class StreamClient<T extends ParamsStream> extends BaseClient<T,
protected moreBox?: HTMLElement;
protected player?: BasePlayer;

protected constructor(params: ParsedUrlQuery | T) {
protected constructor(params: T) {
super(params);
this.udid = this.params.udid;
this.wdaProxy = new WdaProxyClient({ ...this.params, action: ACTION.PROXY_WDA });
Expand All @@ -114,11 +113,11 @@ export abstract class StreamClient<T extends ParamsStream> extends BaseClient<T,
this.setWdaStatusNotification(WdaStatus.STARTING);
}

public get action(): string {
public static get action(): string {
return StreamClient.ACTION;
}

public parseParameters(params: ParsedUrlQuery): ParamsStream {
public static parseParameters(params: URLSearchParams): ParamsStream {
const typedParams = super.parseParameters(params);
const { action } = typedParams;
if (action !== this.action) {
Expand All @@ -127,8 +126,8 @@ export abstract class StreamClient<T extends ParamsStream> extends BaseClient<T,
return {
...typedParams,
action,
udid: Util.parseStringEnv(params.udid),
player: Util.parseStringEnv(params.player),
udid: Util.parseString(params, 'udid', true),
player: Util.parseString(params, 'player', true),
};
}

Expand Down
7 changes: 3 additions & 4 deletions src/app/applDevice/client/StreamClientMJPEG.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ParamsStream } from '../../../types/ParamsStream';
import { ACTION } from '../../../common/Action';
import { ParsedUrlQuery } from 'querystring';
import { StreamClient } from './StreamClient';
import { BasePlayer, PlayerClass } from '../../player/BasePlayer';
import { WdaStatus } from '../../../common/WdaStatus';
Expand All @@ -12,11 +11,11 @@ export class StreamClientMJPEG extends StreamClient<ParamsStream> {
public static ACTION = ACTION.STREAM_MJPEG;
protected static players: Map<string, PlayerClass> = new Map<string, PlayerClass>();

public static start(params: ParsedUrlQuery | ParamsStream): StreamClientMJPEG {
public static start(params: ParamsStream): StreamClientMJPEG {
return new StreamClientMJPEG(params);
}

constructor(params: ParsedUrlQuery | ParamsStream) {
constructor(params: ParamsStream) {
super(params);
this.name = `[${TAG}:${this.udid}]`;
this.udid = this.params.udid;
Expand All @@ -33,7 +32,7 @@ export class StreamClientMJPEG extends StreamClient<ParamsStream> {
});
}

public get action(): string {
public static get action(): string {
return StreamClientMJPEG.ACTION;
}

Expand Down
7 changes: 3 additions & 4 deletions src/app/applDevice/client/StreamClientQVHack.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { StreamReceiver } from '../../client/StreamReceiver';
import { BasePlayer, PlayerClass } from '../../player/BasePlayer';
import { ACTION } from '../../../common/Action';
import { ParsedUrlQuery } from 'querystring';
import { StreamReceiverQVHack } from './StreamReceiverQVHack';
import { StreamClient } from './StreamClient';
import { ParamsStream } from '../../../types/ParamsStream';
Expand All @@ -12,13 +11,13 @@ export class StreamClientQVHack extends StreamClient<ParamsStream> {
public static ACTION = ACTION.STREAM_WS_QVH;
protected static players: Map<string, PlayerClass> = new Map<string, PlayerClass>();

public static start(params: ParsedUrlQuery | ParamsStream): StreamClientQVHack {
public static start(params: ParamsStream): StreamClientQVHack {
return new StreamClientQVHack(params);
}

private readonly streamReceiver: StreamReceiver<ParamsStream>;

constructor(params: ParsedUrlQuery | ParamsStream) {
constructor(params: ParamsStream) {
super(params);

this.name = `[${TAG}:${this.udid}]`;
Expand All @@ -35,7 +34,7 @@ export class StreamClientQVHack extends StreamClient<ParamsStream> {
this.setBodyClass('stream');
}

public get action(): string {
public static get action(): string {
return StreamClientQVHack.ACTION;
}

Expand Down
7 changes: 3 additions & 4 deletions src/app/applDevice/client/StreamReceiverQVHack.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { StreamReceiver } from '../../client/StreamReceiver';
import { ParsedUrlQuery } from 'querystring';
import { ACTION } from '../../../common/Action';
import Util from '../../Util';
import { ParamsStream } from '../../../types/ParamsStream';
import { ChannelCode } from '../../../common/ChannelCode';

export class StreamReceiverQVHack extends StreamReceiver<ParamsStream> {
public parseParameters(params: ParsedUrlQuery): ParamsStream {
public static parseParameters(params: URLSearchParams): ParamsStream {
const typedParams = super.parseParameters(params);
const { action } = typedParams;
if (action !== ACTION.STREAM_WS_QVH) {
Expand All @@ -15,8 +14,8 @@ export class StreamReceiverQVHack extends StreamReceiver<ParamsStream> {
return {
...typedParams,
action,
player: Util.parseStringEnv(params.player),
udid: Util.parseStringEnv(params.udid),
player: Util.parseString(params, 'player', true),
udid: Util.parseString(params, 'udid', true),
};
}

Expand Down
20 changes: 10 additions & 10 deletions src/app/applDevice/client/WdaProxyClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { MessageRunWdaResponse } from '../../../types/MessageRunWdaResponse';
import { Message } from '../../../types/Message';
import { ControlCenterCommand } from '../../../common/ControlCenterCommand';
import { ParamsWdaProxy } from '../../../types/ParamsWdaProxy';
import { ParsedUrlQuery } from 'querystring';
import { ACTION } from '../../../common/Action';
import Util from '../../Util';
import { ChannelCode } from '../../../common/ChannelCode';
Expand Down Expand Up @@ -43,7 +42,8 @@ const TAG = '[WdaProxyClient]';

export class WdaProxyClient
extends ManagerClient<ParamsWdaProxy, WdaProxyClientEvents>
implements TouchHandlerListener {
implements TouchHandlerListener
{
public static calculatePhysicalPoint(
screenInfo: ScreenInfo,
screenWidth: number,
Expand Down Expand Up @@ -85,35 +85,35 @@ export class WdaProxyClient
private commands: string[] = [];
private hasSession = false;
private messageId = 0;
private wait: Map<number, { resolve: (m: Message) => void; reject: () => void }> = new Map();
private wait: Map<number, { resolve: (m: Message) => void; reject: (error: any) => void }> = new Map();

constructor(params: ParamsWdaProxy) {
super(params);
this.openNewConnection();
this.udid = params.udid;
}

public parseParameters(params: ParsedUrlQuery): ParamsWdaProxy {
public static parseParameters(params: URLSearchParams): ParamsWdaProxy {
const typedParams = super.parseParameters(params);
const { action } = typedParams;
if (action !== ACTION.PROXY_WDA) {
throw Error('Incorrect action');
}
return { ...typedParams, action, udid: Util.parseStringEnv(params.udid) };
return { ...typedParams, action, udid: Util.parseString(params, 'udid', true) };
}

protected onSocketClose(e: CloseEvent): void {
protected onSocketClose(event: CloseEvent): void {
this.emit('connected', false);
console.log(TAG, `Connection closed: ${e.reason}`);
console.log(TAG, `Connection closed: ${event.reason}`);
if (!this.stopped) {
setTimeout(() => {
this.openNewConnection();
}, 2000);
}
}

protected onSocketMessage(e: MessageEvent): void {
new Response(e.data)
protected onSocketMessage(event: MessageEvent): void {
new Response(event.data)
.text()
.then((text: string) => {
const json = JSON.parse(text) as Message;
Expand All @@ -134,7 +134,7 @@ export class WdaProxyClient
})
.catch((error: Error) => {
console.error(TAG, error.message);
console.log(TAG, e.data);
console.log(TAG, event.data);
});
}

Expand Down
Loading