-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpreload.js
More file actions
110 lines (90 loc) · 5.07 KB
/
preload.js
File metadata and controls
110 lines (90 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const { ipcRenderer } = require('electron');
// contextIsolation is false in this app — direct window assignment works.
// If contextIsolation is ever enabled, switch to contextBridge.exposeInMainWorld.
window.electronAPI = {
dialog: {
selectDirectory: () => ipcRenderer.invoke('dialog:selectDirectory'),
selectFile: () => ipcRenderer.invoke('dialog:selectFile'),
},
wad: {
/**
* Extract a full champion WAD bundle (main + optional voiceover WADs).
* All fs operations run in the main process — no window.require('fs') in renderer.
* Progress events arrive via wad.onProgress(); unsubscribe with wad.offProgress().
*
* @param {Object} params
* @returns {Promise<Object>} result
*/
extractBundle: (params) => ipcRenderer.invoke('wad:extractBundle', params),
/**
* Subscribe to live progress events pushed from the main process.
* Callback receives (event, { count: number, message: string }).
* Keep the reference — you need it to call offProgress().
*/
onProgress: (callback) => ipcRenderer.on('wad:progress', callback),
/**
* Unsubscribe a specific progress callback.
*/
offProgress: (callback) => ipcRenderer.removeListener('wad:progress', callback),
/** Scan a directory for all .wad.client files, grouped by type. */
scanAll: (params) => ipcRenderer.invoke('wad:scanAll', params),
/** Parse WAD TOC and return a hierarchical file tree (no extraction). */
mountTree: (params) => ipcRenderer.invoke('wad:mountTree', params),
/** Batch-load compact path indexes for many WADs (cross-WAD search). */
loadAllIndexes: (params) => ipcRenderer.invoke('wad:loadAllIndexes', params),
/** Read/decompress one chunk payload by chunk id. */
readChunkData: (params) => ipcRenderer.invoke('wad:readChunkData', params),
/** Extract selected file entries (native rust backend). */
extractSelected: (params) => ipcRenderer.invoke('wad:extractSelected', params),
/** Parse already-extracted BIN files for accurate material→texture hints. */
parseSknBins: (params) => ipcRenderer.invoke('wad:parseSknBins', params),
/** Scan BIN/SKN chunks in a WAD for embedded paths; writes hashes.extracted.txt. */
extractHashes: (params) => ipcRenderer.invoke('wad:extractHashes', params),
/** Read a .bin chunk from a WAD and return ritobin text (fake-python format). */
readBinAsText: (params) => ipcRenderer.invoke('wad:readBinAsText', params),
/** Prepare Port donor from champion/skin via TOC-first selective extraction. */
preparePortDonorFromSkin: (params) => ipcRenderer.invoke('port:prepareDonorFromSkin', params),
cleanupPortDonorTemp: (params) => ipcRenderer.invoke('port:cleanupDonorTemp', params),
onPortDonorProgress: (callback) => ipcRenderer.on('port:donorProgress', callback),
offPortDonorProgress: (callback) => ipcRenderer.removeListener('port:donorProgress', callback),
extractBnkBanksFromGame: (params) => ipcRenderer.invoke('bnk:extractBanksFromGame', params),
onBnkGameProgress: (callback) => ipcRenderer.on('bnk:gameProgress', callback),
offBnkGameProgress: (callback) => ipcRenderer.removeListener('bnk:gameProgress', callback),
cleanupBnkGameCache: (params) => ipcRenderer.invoke('bnk:cleanupGameCache', params),
},
bumpath: {
/** Perform a Bumpath repath. Runs in main process for better folder management. */
repath: (params) => ipcRenderer.invoke('bumpath:repath', params),
},
hashtable: {
/**
* Eagerly load hash tables into main-process cache.
*/
warmCache: (hashPath, options = {}) => ipcRenderer.invoke('hashtable:warmCache', { hashPath, ...options }),
onWarmProgress: (callback) => ipcRenderer.on('hashtable:warmProgress', callback),
offWarmProgress: (callback) => ipcRenderer.removeListener('hashtable:warmProgress', callback),
setKeepAlive: (enabled) => ipcRenderer.invoke('hashtable:setKeepAlive', enabled),
/**
* Clear the main-process hashtables cache immediately.
* Call this when the user navigates away from a page that triggered extractions.
*/
clearCache: () => ipcRenderer.invoke('hashtable:clearCache'),
primeWad: (hashPath) => ipcRenderer.invoke('hashtable:primeWad', { hashPath }),
},
modelInspect: {
prepareSkinAssets: (params) => ipcRenderer.invoke('modelInspect:prepareSkinAssets', params),
onProgress: (callback) => ipcRenderer.on('modelInspect:progress', callback),
offProgress: (callback) => ipcRenderer.removeListener('modelInspect:progress', callback),
cleanup: () => ipcRenderer.invoke('modelInspect:cleanup'),
},
texture: {
/** Decode a TEX or DDS file to a PNG data URL via the native Rust addon. */
decodeToDataUrl: (filePath) => ipcRenderer.invoke('texture:decodeToDataUrl', { filePath }),
},
misc: {
openFolder: (folderPath) => ipcRenderer.invoke('file:open-folder', folderPath),
getUserDataPath: () => ipcRenderer.invoke('get-user-data-path'),
listFontFiles: () => ipcRenderer.invoke('fonts:list-files'),
readFontFileBase64: (fileName) => ipcRenderer.invoke('fonts:read-file-base64', fileName),
},
};