Skip to content

Commit 94f3d11

Browse files
committed
chore: update version to 5.1.5, enhance Minicap and Scrcpy integration with prebuilt packages, and clean up unused code
1 parent 94f2c42 commit 94f3d11

File tree

8 files changed

+44
-57
lines changed

8 files changed

+44
-57
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ package-lock.json
88
*.log
99
parcel.txt
1010
tasks/*encoder*/
11-
bench/.DS_Store
11+
**/.DS_Store

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## V5.1.4 (2025-07-06)
4+
* use new prebuilt package
5+
36
## V5.1.3 (2025-07-04)
47
* fix import issue with protobufjs in nodeJS with nodeJS runtime
58

bin/scrcpy-server-v1.20.jar

-36.3 KB
Binary file not shown.

bin/scrcpy-server-v1.24.jar

-40.2 KB
Binary file not shown.

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@u4/adbkit",
3-
"version": "5.1.3",
3+
"version": "5.1.5",
44
"description": "A Typescript client for the Android Debug Bridge.",
55
"type": "module",
66
"keywords": [
@@ -64,12 +64,11 @@
6464
"dependencies": {
6565
"@u4/adbkit-logcat": "2.1.2",
6666
"@u4/adbkit-monkey": "^1.0.5",
67-
"@u4/minicap-prebuilt": "^1.0.0",
67+
"@u4/minicap-prebuilt": "^1.1.2",
6868
"@xmldom/xmldom": "^0.9.8",
6969
"commander": "14.0.0",
7070
"debug": "~4.4.1",
7171
"get-port": "7.1.0",
72-
"import-meta-resolve": "^4.1.0",
7372
"node-forge": "^1.3.1",
7473
"promise-duplex": "^8.0.0",
7574
"promise-readable": "^8.0.1",
@@ -108,8 +107,5 @@
108107
"files": [
109108
"dist",
110109
"bin"
111-
],
112-
"optionalDependencies": {
113-
"@devicefarmer/minicap-prebuilt": "^2.7.3"
114-
}
110+
]
115111
}

pnpm-lock.yaml

Lines changed: 5 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/adb/thirdparty/minicap/Minicap.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import PromiseDuplex from 'promise-duplex';
88
import ThirdUtils from "../ThirdUtils.js";
99
import Utils from '../../utils.js';
1010
import Stats from '../../sync/stats.js';
11-
import { resolve } from 'import-meta-resolve';
12-
11+
// import { resolve } from 'import-meta-resolve';
12+
import prebuilds from "@u4/minicap-prebuilt";
1313
/**
1414
* Application binary interface known CPU
1515
*/
@@ -32,21 +32,21 @@ interface IEmissions {
3232
disconnect: (cause: string) => void
3333
}
3434
// fs.ReadStream |
35-
function getResource(path: string): string | null {
36-
try {
37-
return require.resolve(path);
38-
} catch (e) {
39-
try {
40-
if (e instanceof Error && e.message.includes('require is not defined')) {
41-
const url = resolve(path, import.meta.url);
42-
return new URL(url).pathname;
43-
}
44-
} catch (e) {
45-
return null;
46-
}
47-
return null;
48-
}
49-
}
35+
// function getResource(path: string): string | null {
36+
// try {
37+
// return require.resolve(path);
38+
// } catch (e) {
39+
// try {
40+
// if (e instanceof Error && e.message.includes('require is not defined')) {
41+
// const url = resolve(path, import.meta.url);
42+
// return new URL(url).pathname;
43+
// }
44+
// } catch (e) {
45+
// return null;
46+
// }
47+
// return null;
48+
// }
49+
// }
5050

5151
export default class Minicap extends EventEmitter {
5252
private config: MinicapOptions;
@@ -148,21 +148,24 @@ export default class Minicap extends EventEmitter {
148148
const props = await this.client.getProperties();
149149
const abi = props['ro.product.cpu.abi'] as ABI_CPU;
150150
const sdkLevel = parseInt(props['ro.build.version.sdk']);
151-
const minicapName = (sdkLevel >= 16) ? 'minicap' : 'minicap-nopie';
151+
// const minicapName = (sdkLevel >= 16) ? 'minicap' : 'minicap-nopie';
152152

153153
let binFile: string | null = null;
154154
let soFile: string | null = null;
155155

156156

157-
binFile = getResource(`@devicefarmer/minicap-prebuilt/prebuilt/${abi}/bin/${minicapName}`);
157+
binFile = prebuilds.getMinicapBin(abi, sdkLevel);// getResource(`@devicefarmer/minicap-prebuilt/prebuilt/${abi}/bin/${minicapName}`);
158158
if (!binFile)
159159
throw Error(`minicap not found in @devicefarmer/minicap-prebuilt/prebuilt/${abi}/bin/ please install @devicefarmer/minicap-prebuilt to use minicap`);
160-
161-
if (sdkLevel === 32) {
162-
soFile = getResource(`@u4/minicap-prebuilt/prebuilt/${abi}/lib/android-${sdkLevel}/minicap.so`);
163-
} else {
164-
soFile = getResource(`@devicefarmer/minicap-prebuilt/prebuilt/${abi}/lib/android-${sdkLevel}/minicap.so`);
160+
if (!fs.existsSync(binFile)) {
161+
throw Error(`minicap binary not found in ${binFile}, please install @devicefarmer/minicap-prebuilt to use minicap`);
165162
}
163+
soFile = prebuilds.getMinicapSO(abi, sdkLevel);
164+
// if (sdkLevel === 32) {
165+
// soFile = getResource(`@u4/minicap-prebuilt/prebuilt/${abi}/lib/android-${sdkLevel}/minicap.so`);
166+
// } else {
167+
// soFile = getResource(`@devicefarmer/minicap-prebuilt/prebuilt/${abi}/lib/android-${sdkLevel}/minicap.so`);
168+
// }
166169

167170
if (!soFile) {
168171
throw Error(`minicap.so for your device check for @devicefarmer/minicap-prebuilt update that support android-${sdkLevel}, ${soFile} is missing`);

src/adb/thirdparty/scrcpy/Scrcpy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import { Duplex } from 'node:stream';
1010
import { type MotionEvent, MotionEventMap, OrientationMap, ControlMessageMap } from './ScrcpyConst.js';
1111
import { KeyCodes } from '../../keycode.js';
1212
import { BufWrite } from '../minicap/BufWrite.js';
13-
import ThirdUtils from '../ThirdUtils.js';
13+
// import ThirdUtils from '../ThirdUtils.js';
1414
import Stats from '../../sync/stats.js';
1515
import { parse_sequence_parameter_set } from './sps.js';
1616
import { Point, ScrcpyOptions, H264Configuration, VideoStreamFramePacket } from './ScrcpyModels.js';
17+
import prebuilds from "@u4/minicap-prebuilt";
1718

1819
const debug = Utils.debug('adb:scrcpy');
1920

@@ -312,7 +313,9 @@ export default class Scrcpy extends EventEmitter {
312313
return this;
313314
const jarDest = '/data/local/tmp/scrcpy-server.jar';
314315
// Transfer server...
315-
const jar = ThirdUtils.getResourcePath(`scrcpy-server-v1.${this.config.version}.jar`);
316+
const jar = prebuilds.getScrcpyJar(`1.${this.config.version}`);
317+
// ThirdUtils.getResourcePath(`scrcpy-server-v1.${this.config.version}.jar`);
318+
316319
const srcStat: fs.Stats | null = await fs.promises.stat(jar).catch(() => null);
317320
const dstStat: Stats | null = await this.client.stat(jarDest).catch(() => null);
318321
if (!srcStat)

0 commit comments

Comments
 (0)