@mcesystems/apple-kit 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -250
- package/dist/index.js +304 -174
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +303 -173
- package/dist/index.mjs.map +4 -4
- package/dist/resources/bin/darwin/idevice_id +0 -0
- package/dist/resources/bin/darwin/idevicedebug +0 -0
- package/dist/resources/bin/darwin/idevicediagnostics +0 -0
- package/dist/resources/bin/darwin/ideviceinfo +0 -0
- package/dist/resources/bin/darwin/ideviceinstaller +0 -0
- package/dist/resources/bin/darwin/idevicename +0 -0
- package/dist/resources/bin/darwin/idevicepair +0 -0
- package/dist/resources/bin/darwin/idevicescreenshot +0 -0
- package/dist/resources/bin/darwin/idevicesyslog +0 -0
- package/dist/resources/bin/darwin/iproxy +0 -0
- package/dist/resources/bin/darwin/libcrypto.3.dylib +0 -0
- package/dist/resources/bin/darwin/libimobiledevice-1.0.6.dylib +0 -0
- package/dist/resources/bin/darwin/libimobiledevice-glue-1.0.0.dylib +0 -0
- package/dist/resources/bin/darwin/liblzma.5.dylib +0 -0
- package/dist/resources/bin/darwin/libplist-2.0.4.dylib +0 -0
- package/dist/resources/bin/darwin/libssl.3.dylib +0 -0
- package/dist/resources/bin/darwin/libusbmuxd-2.0.7.dylib +0 -0
- package/dist/resources/bin/darwin/libzip.5.dylib +0 -0
- package/dist/resources/bin/darwin/libzstd.1.dylib +0 -0
- package/{resources → dist/resources}/licenses/LGPL-2.1.txt +33 -33
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic/actions/device.d.ts.map +1 -1
- package/dist/types/logic/actions/proxy.d.ts.map +1 -1
- package/dist/types/logic/appleDeviceKit.d.ts +2 -7
- package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
- package/package.json +7 -4
- package/scripts/README.md +209 -0
- package/scripts/build-windows.sh.template +134 -0
- package/scripts/export-resources.ts +444 -0
- package/dist/types/utils/portManager.d.ts +0 -68
- package/dist/types/utils/portManager.d.ts.map +0 -1
- package/resources/bin/windows/bz2.dll +0 -0
- package/resources/bin/windows/getopt.dll +0 -0
- package/resources/bin/windows/iconv-2.dll +0 -0
- package/resources/bin/windows/idevice_id.exe +0 -0
- package/resources/bin/windows/ideviceactivation.exe +0 -0
- package/resources/bin/windows/idevicedebug.exe +0 -0
- package/resources/bin/windows/ideviceinfo.exe +0 -0
- package/resources/bin/windows/ideviceinstaller.exe +0 -0
- package/resources/bin/windows/idevicepair.exe +0 -0
- package/resources/bin/windows/imobiledevice.dll +0 -0
- package/resources/bin/windows/iproxy.exe +0 -0
- package/resources/bin/windows/libcrypto-1_1-x64.dll +0 -0
- package/resources/bin/windows/libcurl.dll +0 -0
- package/resources/bin/windows/libideviceactivation-1.0.dll +0 -0
- package/resources/bin/windows/libimobiledevice-1.0.dll +0 -0
- package/resources/bin/windows/libimobiledevice-glue-1.0.dll +0 -0
- package/resources/bin/windows/libplist-2.0.dll +0 -0
- package/resources/bin/windows/libssl-1_1-x64.dll +0 -0
- package/resources/bin/windows/libusb-1.0.dll +0 -0
- package/resources/bin/windows/libusb0.dll +0 -0
- package/resources/bin/windows/libusbmuxd-2.0.dll +0 -0
- package/resources/bin/windows/libxml2.dll +0 -0
- package/resources/bin/windows/lzma.dll +0 -0
- package/resources/bin/windows/pcre.dll +0 -0
- package/resources/bin/windows/pcreposix.dll +0 -0
- package/resources/bin/windows/plist.dll +0 -0
- package/resources/bin/windows/pthreadVC3.dll +0 -0
- package/resources/bin/windows/readline.dll +0 -0
- package/resources/bin/windows/usbmuxd.dll +0 -0
- package/resources/bin/windows/usbmuxd.exe +0 -0
- package/resources/bin/windows/vcruntime140.dll +0 -0
- package/resources/bin/windows/zip.dll +0 -0
- package/resources/bin/windows/zlib1.dll +0 -0
- package/resources/lib/include/libimobiledevice/afc.h +0 -413
- package/resources/lib/include/libimobiledevice/bt_packet_logger.h +0 -156
- package/resources/lib/include/libimobiledevice/companion_proxy.h +0 -212
- package/resources/lib/include/libimobiledevice/debugserver.h +0 -272
- package/resources/lib/include/libimobiledevice/diagnostics_relay.h +0 -228
- package/resources/lib/include/libimobiledevice/file_relay.h +0 -166
- package/resources/lib/include/libimobiledevice/heartbeat.h +0 -137
- package/resources/lib/include/libimobiledevice/house_arrest.h +0 -180
- package/resources/lib/include/libimobiledevice/installation_proxy.h +0 -505
- package/resources/lib/include/libimobiledevice/libimobiledevice.h +0 -444
- package/resources/lib/include/libimobiledevice/lockdown.h +0 -577
- package/resources/lib/include/libimobiledevice/misagent.h +0 -168
- package/resources/lib/include/libimobiledevice/mobile_image_mounter.h +0 -275
- package/resources/lib/include/libimobiledevice/mobileactivation.h +0 -192
- package/resources/lib/include/libimobiledevice/mobilebackup.h +0 -246
- package/resources/lib/include/libimobiledevice/mobilebackup2.h +0 -214
- package/resources/lib/include/libimobiledevice/mobilesync.h +0 -359
- package/resources/lib/include/libimobiledevice/notification_proxy.h +0 -202
- package/resources/lib/include/libimobiledevice/ostrace.h +0 -198
- package/resources/lib/include/libimobiledevice/preboard.h +0 -187
- package/resources/lib/include/libimobiledevice/property_list_service.h +0 -184
- package/resources/lib/include/libimobiledevice/restore.h +0 -179
- package/resources/lib/include/libimobiledevice/reverse_proxy.h +0 -213
- package/resources/lib/include/libimobiledevice/sbservices.h +0 -175
- package/resources/lib/include/libimobiledevice/screenshotr.h +0 -118
- package/resources/lib/include/libimobiledevice/service.h +0 -202
- package/resources/lib/include/libimobiledevice/syslog_relay.h +0 -184
- package/resources/lib/include/libimobiledevice/webinspector.h +0 -137
- package/resources/lib/include/plist/Array.h +0 -80
- package/resources/lib/include/plist/Boolean.h +0 -48
- package/resources/lib/include/plist/Data.h +0 -50
- package/resources/lib/include/plist/Date.h +0 -54
- package/resources/lib/include/plist/Dictionary.h +0 -73
- package/resources/lib/include/plist/Integer.h +0 -54
- package/resources/lib/include/plist/Key.h +0 -49
- package/resources/lib/include/plist/Node.h +0 -57
- package/resources/lib/include/plist/Real.h +0 -48
- package/resources/lib/include/plist/String.h +0 -52
- package/resources/lib/include/plist/Structure.h +0 -62
- package/resources/lib/include/plist/Uid.h +0 -48
- package/resources/lib/include/plist/plist++.h +0 -39
- package/resources/lib/include/plist/plist.h +0 -1448
- package/resources/lib/libimobiledevice-1.0.dll +0 -0
- package/resources/lib/libimobiledevice-1.0.dll.a +0 -0
- package/resources/lib/libplist-2.0.dll +0 -0
- package/resources/lib/libplist-2.0.dll.a +0 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Export libimobiledevice resources to a specified path
|
|
4
|
+
*
|
|
5
|
+
* This script exports the libimobiledevice binaries and their dependencies
|
|
6
|
+
* to a target directory. The resources can then be used by applications
|
|
7
|
+
* that depend on apple-kit.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* npx tsx export-resources.ts <target-path>
|
|
11
|
+
*
|
|
12
|
+
* Example:
|
|
13
|
+
* npx tsx export-resources.ts /path/to/my-app/resources/apple-kit
|
|
14
|
+
*
|
|
15
|
+
* Platform support:
|
|
16
|
+
* - macOS: Copies binaries from Homebrew installation
|
|
17
|
+
* - Windows: Builds from source using MSYS2/MinGW (requires manual setup)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { exec } from "node:child_process";
|
|
21
|
+
import {
|
|
22
|
+
chmodSync,
|
|
23
|
+
copyFileSync,
|
|
24
|
+
existsSync,
|
|
25
|
+
mkdirSync,
|
|
26
|
+
readFileSync,
|
|
27
|
+
readlinkSync,
|
|
28
|
+
writeFileSync,
|
|
29
|
+
} from "node:fs";
|
|
30
|
+
import path from "node:path";
|
|
31
|
+
import { fileURLToPath } from "node:url";
|
|
32
|
+
import { promisify } from "node:util";
|
|
33
|
+
|
|
34
|
+
// Get the directory of this script
|
|
35
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
36
|
+
const __dirname = path.dirname(__filename);
|
|
37
|
+
|
|
38
|
+
const execAsync = promisify(exec);
|
|
39
|
+
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Configuration
|
|
42
|
+
// ============================================================================
|
|
43
|
+
|
|
44
|
+
// Tools we need to bundle
|
|
45
|
+
const REQUIRED_TOOLS = [
|
|
46
|
+
"idevice_id",
|
|
47
|
+
"ideviceinfo",
|
|
48
|
+
"idevicepair",
|
|
49
|
+
"idevicename",
|
|
50
|
+
"idevicedebug",
|
|
51
|
+
"ideviceinstaller",
|
|
52
|
+
"iproxy",
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
// Optional tools (won't fail if not found)
|
|
56
|
+
const OPTIONAL_TOOLS = [
|
|
57
|
+
"ideviceactivation",
|
|
58
|
+
"idevicesyslog",
|
|
59
|
+
"idevicescreenshot",
|
|
60
|
+
"idevicediagnostics",
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
// Homebrew paths on macOS
|
|
64
|
+
const HOMEBREW_ARM_PATH = "/opt/homebrew";
|
|
65
|
+
const HOMEBREW_INTEL_PATH = "/usr/local";
|
|
66
|
+
|
|
67
|
+
// MSYS2 paths on Windows
|
|
68
|
+
const MSYS2_DEFAULT_PATH = "C:\\msys64";
|
|
69
|
+
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// Utility Functions
|
|
72
|
+
// ============================================================================
|
|
73
|
+
|
|
74
|
+
function printUsage(): void {
|
|
75
|
+
console.log(`
|
|
76
|
+
Usage: npx tsx export-resources.ts <target-path>
|
|
77
|
+
|
|
78
|
+
Arguments:
|
|
79
|
+
target-path Directory where resources will be exported
|
|
80
|
+
|
|
81
|
+
Examples:
|
|
82
|
+
npx tsx export-resources.ts ./my-app/resources/apple-kit
|
|
83
|
+
npx tsx export-resources.ts /absolute/path/to/resources
|
|
84
|
+
|
|
85
|
+
The script will create the following structure:
|
|
86
|
+
<target-path>/
|
|
87
|
+
bin/
|
|
88
|
+
darwin/ (macOS binaries and dylibs)
|
|
89
|
+
windows/ (Windows binaries and DLLs)
|
|
90
|
+
licenses/
|
|
91
|
+
LGPL-2.1.txt
|
|
92
|
+
`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function resolveSymlink(filePath: string): string {
|
|
96
|
+
try {
|
|
97
|
+
const linkTarget = readlinkSync(filePath);
|
|
98
|
+
if (path.isAbsolute(linkTarget)) {
|
|
99
|
+
return linkTarget;
|
|
100
|
+
}
|
|
101
|
+
return path.resolve(path.dirname(filePath), linkTarget);
|
|
102
|
+
} catch {
|
|
103
|
+
return filePath; // Not a symlink
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
interface DylibInfo {
|
|
108
|
+
path: string;
|
|
109
|
+
name: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function getDylibDependencies(binaryPath: string): Promise<DylibInfo[]> {
|
|
113
|
+
const dylibs: DylibInfo[] = [];
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const { stdout } = await execAsync(`otool -L "${binaryPath}"`);
|
|
117
|
+
const lines = stdout.split("\n");
|
|
118
|
+
|
|
119
|
+
for (const line of lines) {
|
|
120
|
+
const match = line.match(/^\s+(\S+\.dylib)/);
|
|
121
|
+
if (match) {
|
|
122
|
+
const dylibPath = match[1];
|
|
123
|
+
if (
|
|
124
|
+
dylibPath.includes("/opt/homebrew") ||
|
|
125
|
+
dylibPath.includes("/usr/local/opt")
|
|
126
|
+
) {
|
|
127
|
+
dylibs.push({
|
|
128
|
+
path: dylibPath,
|
|
129
|
+
name: path.basename(dylibPath),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
console.warn(`Warning: Could not get dependencies for ${binaryPath}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return dylibs;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function getAllDylibs(binaries: string[]): Promise<Map<string, string>> {
|
|
142
|
+
const allDylibs = new Map<string, string>();
|
|
143
|
+
const processed = new Set<string>();
|
|
144
|
+
|
|
145
|
+
async function processBinary(binaryPath: string): Promise<void> {
|
|
146
|
+
if (processed.has(binaryPath)) return;
|
|
147
|
+
processed.add(binaryPath);
|
|
148
|
+
|
|
149
|
+
const deps = await getDylibDependencies(binaryPath);
|
|
150
|
+
for (const dep of deps) {
|
|
151
|
+
if (!allDylibs.has(dep.name)) {
|
|
152
|
+
allDylibs.set(dep.name, dep.path);
|
|
153
|
+
await processBinary(dep.path);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
for (const binary of binaries) {
|
|
159
|
+
await processBinary(binary);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return allDylibs;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function fixDylibPaths(
|
|
166
|
+
binaryPath: string,
|
|
167
|
+
dylibs: Map<string, string>
|
|
168
|
+
): Promise<void> {
|
|
169
|
+
const { stdout } = await execAsync(`otool -L "${binaryPath}"`);
|
|
170
|
+
const lines = stdout.split("\n");
|
|
171
|
+
|
|
172
|
+
for (const [dylibName] of dylibs) {
|
|
173
|
+
for (const line of lines) {
|
|
174
|
+
const match = line.match(/^\s+(\S+)/);
|
|
175
|
+
if (match) {
|
|
176
|
+
const depPath = match[1];
|
|
177
|
+
if (
|
|
178
|
+
depPath.includes(dylibName) &&
|
|
179
|
+
!depPath.startsWith("@loader_path")
|
|
180
|
+
) {
|
|
181
|
+
try {
|
|
182
|
+
await execAsync(
|
|
183
|
+
`install_name_tool -change "${depPath}" "@loader_path/${dylibName}" "${binaryPath}"`
|
|
184
|
+
);
|
|
185
|
+
} catch {
|
|
186
|
+
// Ignore errors
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function fixDylibId(dylibPath: string): Promise<void> {
|
|
195
|
+
const dylibName = path.basename(dylibPath);
|
|
196
|
+
try {
|
|
197
|
+
await execAsync(
|
|
198
|
+
`install_name_tool -id "@loader_path/${dylibName}" "${dylibPath}"`
|
|
199
|
+
);
|
|
200
|
+
} catch {
|
|
201
|
+
console.warn(`Warning: Could not fix dylib id for ${dylibPath}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// ============================================================================
|
|
206
|
+
// macOS Export
|
|
207
|
+
// ============================================================================
|
|
208
|
+
|
|
209
|
+
function getHomebrewPath(): string | null {
|
|
210
|
+
if (existsSync(path.join(HOMEBREW_ARM_PATH, "bin", "idevice_id"))) {
|
|
211
|
+
return HOMEBREW_ARM_PATH;
|
|
212
|
+
}
|
|
213
|
+
if (existsSync(path.join(HOMEBREW_INTEL_PATH, "bin", "idevice_id"))) {
|
|
214
|
+
return HOMEBREW_INTEL_PATH;
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function exportDarwinResources(targetDir: string): Promise<void> {
|
|
220
|
+
console.log("\n=== Exporting macOS (Darwin) Resources ===\n");
|
|
221
|
+
|
|
222
|
+
const homebrewPath = getHomebrewPath();
|
|
223
|
+
if (!homebrewPath) {
|
|
224
|
+
console.error("Error: Homebrew libimobiledevice not found.");
|
|
225
|
+
console.error(
|
|
226
|
+
"Please install it first: brew install libimobiledevice ideviceinstaller"
|
|
227
|
+
);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
console.log(`Found Homebrew at: ${homebrewPath}`);
|
|
232
|
+
|
|
233
|
+
const darwinBinDir = path.join(targetDir, "bin", "darwin");
|
|
234
|
+
mkdirSync(darwinBinDir, { recursive: true });
|
|
235
|
+
|
|
236
|
+
// Collect all binaries that exist
|
|
237
|
+
const binaryPaths: string[] = [];
|
|
238
|
+
const copiedBinaries: string[] = [];
|
|
239
|
+
|
|
240
|
+
// Copy required tools
|
|
241
|
+
for (const tool of REQUIRED_TOOLS) {
|
|
242
|
+
const toolPath = path.join(homebrewPath, "bin", tool);
|
|
243
|
+
if (existsSync(toolPath)) {
|
|
244
|
+
const realPath = resolveSymlink(toolPath);
|
|
245
|
+
binaryPaths.push(realPath);
|
|
246
|
+
|
|
247
|
+
const destPath = path.join(darwinBinDir, tool);
|
|
248
|
+
copyFileSync(realPath, destPath);
|
|
249
|
+
chmodSync(destPath, 0o755);
|
|
250
|
+
copiedBinaries.push(destPath);
|
|
251
|
+
console.log(`✓ Copied ${tool}`);
|
|
252
|
+
} else {
|
|
253
|
+
console.error(`✗ Required tool not found: ${tool}`);
|
|
254
|
+
console.error(
|
|
255
|
+
` Please install: brew install libimobiledevice ideviceinstaller`
|
|
256
|
+
);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Copy optional tools
|
|
262
|
+
for (const tool of OPTIONAL_TOOLS) {
|
|
263
|
+
const toolPath = path.join(homebrewPath, "bin", tool);
|
|
264
|
+
if (existsSync(toolPath)) {
|
|
265
|
+
const realPath = resolveSymlink(toolPath);
|
|
266
|
+
binaryPaths.push(realPath);
|
|
267
|
+
|
|
268
|
+
const destPath = path.join(darwinBinDir, tool);
|
|
269
|
+
copyFileSync(realPath, destPath);
|
|
270
|
+
chmodSync(destPath, 0o755);
|
|
271
|
+
copiedBinaries.push(destPath);
|
|
272
|
+
console.log(`✓ Copied ${tool} (optional)`);
|
|
273
|
+
} else {
|
|
274
|
+
console.log(`- Skipping ${tool} (optional, not installed)`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Get all dylib dependencies
|
|
279
|
+
console.log("\nCollecting dylib dependencies...");
|
|
280
|
+
const allDylibs = await getAllDylibs(binaryPaths);
|
|
281
|
+
|
|
282
|
+
// Copy dylibs
|
|
283
|
+
console.log(`\nCopying ${allDylibs.size} dylibs...`);
|
|
284
|
+
const copiedDylibs: string[] = [];
|
|
285
|
+
|
|
286
|
+
for (const [dylibName, dylibPath] of allDylibs) {
|
|
287
|
+
const realPath = resolveSymlink(dylibPath);
|
|
288
|
+
const destPath = path.join(darwinBinDir, dylibName);
|
|
289
|
+
|
|
290
|
+
if (existsSync(realPath)) {
|
|
291
|
+
copyFileSync(realPath, destPath);
|
|
292
|
+
chmodSync(destPath, 0o755);
|
|
293
|
+
copiedDylibs.push(destPath);
|
|
294
|
+
console.log(`✓ Copied ${dylibName}`);
|
|
295
|
+
} else {
|
|
296
|
+
console.warn(`Warning: Dylib not found: ${realPath}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Fix dylib paths in all binaries and dylibs
|
|
301
|
+
console.log("\nFixing dylib paths...");
|
|
302
|
+
|
|
303
|
+
for (const binaryPath of copiedBinaries) {
|
|
304
|
+
await fixDylibPaths(binaryPath, allDylibs);
|
|
305
|
+
console.log(`✓ Fixed paths in ${path.basename(binaryPath)}`);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
for (const dylibPath of copiedDylibs) {
|
|
309
|
+
await fixDylibId(dylibPath);
|
|
310
|
+
await fixDylibPaths(dylibPath, allDylibs);
|
|
311
|
+
console.log(`✓ Fixed paths in ${path.basename(dylibPath)}`);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
console.log(`\n✓ macOS resources exported to: ${darwinBinDir}`);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ============================================================================
|
|
318
|
+
// Windows Export
|
|
319
|
+
// ============================================================================
|
|
320
|
+
|
|
321
|
+
async function exportWindowsResources(targetDir: string): Promise<void> {
|
|
322
|
+
console.log("\n=== Exporting Windows Resources ===\n");
|
|
323
|
+
|
|
324
|
+
// Check if we're on Windows
|
|
325
|
+
if (process.platform !== "win32") {
|
|
326
|
+
console.log("Note: Windows resources can only be built on Windows.");
|
|
327
|
+
console.log("Generating build script for later use...\n");
|
|
328
|
+
generateWindowsBuildScript(targetDir);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Check for MSYS2
|
|
333
|
+
const msys2Path = process.env.MSYS2_PATH || MSYS2_DEFAULT_PATH;
|
|
334
|
+
if (!existsSync(msys2Path)) {
|
|
335
|
+
console.error(`Error: MSYS2 not found at ${msys2Path}`);
|
|
336
|
+
console.error("Please install MSYS2 from https://www.msys2.org/");
|
|
337
|
+
console.error(
|
|
338
|
+
"Or set MSYS2_PATH environment variable to your MSYS2 installation."
|
|
339
|
+
);
|
|
340
|
+
generateWindowsBuildScript(targetDir);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Generate the build script
|
|
345
|
+
generateWindowsBuildScript(targetDir);
|
|
346
|
+
|
|
347
|
+
console.log("\nTo build Windows resources:");
|
|
348
|
+
console.log("1. Open MSYS2 MinGW 64-bit shell");
|
|
349
|
+
console.log(`2. Run: bash "${path.join(targetDir, "build-windows.sh")}"`);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function generateWindowsBuildScript(targetDir: string): void {
|
|
353
|
+
const windowsBinDir = path.join(targetDir, "bin", "windows");
|
|
354
|
+
mkdirSync(windowsBinDir, { recursive: true });
|
|
355
|
+
|
|
356
|
+
// Read the template file
|
|
357
|
+
const templatePath = path.join(__dirname, "build-windows.sh.template");
|
|
358
|
+
let buildScript = readFileSync(templatePath, "utf-8");
|
|
359
|
+
|
|
360
|
+
// Replace the placeholder with the actual target directory
|
|
361
|
+
buildScript = buildScript.replace(
|
|
362
|
+
"{{TARGET_DIR}}",
|
|
363
|
+
windowsBinDir.replace(/\\/g, "/")
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const scriptPath = path.join(targetDir, "build-windows.sh");
|
|
367
|
+
writeFileSync(scriptPath, buildScript);
|
|
368
|
+
console.log(`✓ Generated Windows build script: ${scriptPath}`);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// ============================================================================
|
|
372
|
+
// License File
|
|
373
|
+
// ============================================================================
|
|
374
|
+
|
|
375
|
+
function createLicenseFile(targetDir: string): void {
|
|
376
|
+
const licensesDir = path.join(targetDir, "licenses");
|
|
377
|
+
mkdirSync(licensesDir, { recursive: true });
|
|
378
|
+
|
|
379
|
+
const lgplText = `GNU LESSER GENERAL PUBLIC LICENSE
|
|
380
|
+
Version 2.1, February 1999
|
|
381
|
+
|
|
382
|
+
libimobiledevice and related tools are licensed under the
|
|
383
|
+
GNU Lesser General Public License version 2.1.
|
|
384
|
+
|
|
385
|
+
For full license text, see:
|
|
386
|
+
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
|
|
387
|
+
|
|
388
|
+
These binaries are bundled for convenience. The source code is available at:
|
|
389
|
+
- https://github.com/libimobiledevice/libimobiledevice
|
|
390
|
+
- https://github.com/libimobiledevice/libusbmuxd
|
|
391
|
+
- https://github.com/libimobiledevice/libplist
|
|
392
|
+
- https://github.com/libimobiledevice/libimobiledevice-glue
|
|
393
|
+
- https://github.com/libimobiledevice/ideviceinstaller
|
|
394
|
+
`;
|
|
395
|
+
|
|
396
|
+
const licensePath = path.join(licensesDir, "LGPL-2.1.txt");
|
|
397
|
+
writeFileSync(licensePath, lgplText);
|
|
398
|
+
console.log(`✓ Created license file: ${licensePath}`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// ============================================================================
|
|
402
|
+
// Main
|
|
403
|
+
// ============================================================================
|
|
404
|
+
|
|
405
|
+
async function main(): Promise<void> {
|
|
406
|
+
const args = process.argv.slice(2);
|
|
407
|
+
|
|
408
|
+
if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
409
|
+
printUsage();
|
|
410
|
+
process.exit(args.length === 0 ? 1 : 0);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const targetPath = path.resolve(args[0]);
|
|
414
|
+
|
|
415
|
+
console.log("=== Apple-kit Resources Export ===");
|
|
416
|
+
console.log(`Platform: ${process.platform}`);
|
|
417
|
+
console.log(`Target: ${targetPath}`);
|
|
418
|
+
|
|
419
|
+
// Create target directory
|
|
420
|
+
mkdirSync(targetPath, { recursive: true });
|
|
421
|
+
|
|
422
|
+
// Export based on platform
|
|
423
|
+
if (process.platform === "darwin") {
|
|
424
|
+
await exportDarwinResources(targetPath);
|
|
425
|
+
} else if (process.platform === "win32") {
|
|
426
|
+
await exportWindowsResources(targetPath);
|
|
427
|
+
} else {
|
|
428
|
+
console.log("\nNote: This script supports macOS and Windows.");
|
|
429
|
+
console.log("For Linux, install libimobiledevice-utils via your package manager.");
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Always create license file
|
|
433
|
+
console.log("");
|
|
434
|
+
createLicenseFile(targetPath);
|
|
435
|
+
|
|
436
|
+
console.log("\n=== Export Complete ===");
|
|
437
|
+
console.log(`Resources exported to: ${targetPath}`);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
main().catch((error) => {
|
|
441
|
+
console.error("Export failed:", error);
|
|
442
|
+
process.exit(1);
|
|
443
|
+
});
|
|
444
|
+
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Port allocation info
|
|
3
|
-
*/
|
|
4
|
-
export interface PortAllocation {
|
|
5
|
-
/** The logical port (USB hub position) */
|
|
6
|
-
logicalPort: number;
|
|
7
|
-
/** The allocated local port for forwarding */
|
|
8
|
-
localPort: number;
|
|
9
|
-
/** The device port being forwarded to */
|
|
10
|
-
devicePort: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Manages port allocation for device forwarding.
|
|
14
|
-
* Ensures each logical port gets a unique, available local port.
|
|
15
|
-
*/
|
|
16
|
-
export declare class PortManager {
|
|
17
|
-
private allocations;
|
|
18
|
-
private readonly basePort;
|
|
19
|
-
private readonly maxPortRange;
|
|
20
|
-
/**
|
|
21
|
-
* Create a new PortManager
|
|
22
|
-
*
|
|
23
|
-
* @param basePort Starting port number for allocation (default: 30000)
|
|
24
|
-
* @param maxPortRange Maximum range of ports to search (default: 1000)
|
|
25
|
-
*/
|
|
26
|
-
constructor(basePort?: number, maxPortRange?: number);
|
|
27
|
-
/**
|
|
28
|
-
* Find an available port starting from the given port number
|
|
29
|
-
*/
|
|
30
|
-
private findAvailablePort;
|
|
31
|
-
/**
|
|
32
|
-
* Check if a port is available for binding
|
|
33
|
-
*/
|
|
34
|
-
private isPortAvailable;
|
|
35
|
-
/**
|
|
36
|
-
* Allocate a local port for a logical port
|
|
37
|
-
*
|
|
38
|
-
* @param logicalPort The logical port number (USB hub position)
|
|
39
|
-
* @param devicePort The device port to forward to
|
|
40
|
-
* @returns The allocated port info
|
|
41
|
-
*/
|
|
42
|
-
allocate(logicalPort: number, devicePort: number): Promise<PortAllocation>;
|
|
43
|
-
/**
|
|
44
|
-
* Release the port allocation for a logical port
|
|
45
|
-
*/
|
|
46
|
-
release(logicalPort: number): void;
|
|
47
|
-
/**
|
|
48
|
-
* Get the current allocation for a logical port
|
|
49
|
-
*/
|
|
50
|
-
getAllocation(logicalPort: number): PortAllocation | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Get all current allocations
|
|
53
|
-
*/
|
|
54
|
-
getAllAllocations(): PortAllocation[];
|
|
55
|
-
/**
|
|
56
|
-
* Release all allocations
|
|
57
|
-
*/
|
|
58
|
-
releaseAll(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Check if a logical port has an allocation
|
|
61
|
-
*/
|
|
62
|
-
hasAllocation(logicalPort: number): boolean;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get the shared port manager instance
|
|
66
|
-
*/
|
|
67
|
-
export declare function getSharedPortManager(): PortManager;
|
|
68
|
-
//# sourceMappingURL=portManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portManager.d.ts","sourceRoot":"","sources":["../../../src/utils/portManager.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;;OAKG;gBACS,QAAQ,SAAQ,EAAE,YAAY,SAAO;IAKjD;;OAEG;YACW,iBAAiB;IAuB/B;;OAEG;IACH,OAAO,CAAC,eAAe;IAkBvB;;;;;;OAMG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAgChF;;OAEG;IACH,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQlC;;OAEG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI9D;;OAEG;IACH,iBAAiB,IAAI,cAAc,EAAE;IAIrC;;OAEG;IACH,UAAU,IAAI,IAAI;IAKlB;;OAEG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;CAG3C;AAOD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAKlD"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|