@lvce-editor/main-process 6.46.2 → 6.47.1
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/dist/mainProcessMain.js +98 -4
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -3420,6 +3420,9 @@ const Dash = '-';
|
|
|
3420
3420
|
const Space$3 = ' ';
|
|
3421
3421
|
|
|
3422
3422
|
const firstLetterLowerCase = string => {
|
|
3423
|
+
if (/^[A-Z][A-Z0-9]*$/.test(string)) {
|
|
3424
|
+
return string;
|
|
3425
|
+
}
|
|
3423
3426
|
return string[0].toLowerCase() + string.slice(1);
|
|
3424
3427
|
};
|
|
3425
3428
|
const camelCase = string => {
|
|
@@ -5689,7 +5692,7 @@ const openContextMenu = async (menuItems, x, y, browserViewId) => {
|
|
|
5689
5692
|
};
|
|
5690
5693
|
|
|
5691
5694
|
const profileDuration = 10_000;
|
|
5692
|
-
const getFileName$
|
|
5695
|
+
const getFileName$2 = targetName => {
|
|
5693
5696
|
const safeTargetName = targetName.replaceAll(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-/, '').replace(/-$/, '') || 'extension-host';
|
|
5694
5697
|
return `${safeTargetName}-${Date.now()}.cpuprofile`;
|
|
5695
5698
|
};
|
|
@@ -5744,7 +5747,7 @@ const takeCpuProfile = async (windowId, workerName) => {
|
|
|
5744
5747
|
recursive: true
|
|
5745
5748
|
});
|
|
5746
5749
|
const targetName = workerName || `Extension Host Window ${windowId}`;
|
|
5747
|
-
filePath = join$1(downloadsPath, getFileName$
|
|
5750
|
+
filePath = join$1(downloadsPath, getFileName$2(targetName));
|
|
5748
5751
|
writeFileSync(filePath, JSON.stringify(profile), {
|
|
5749
5752
|
flag: 'wx'
|
|
5750
5753
|
});
|
|
@@ -5788,7 +5791,7 @@ const takeWorkerCpuProfile = async (windowId, workerName) => {
|
|
|
5788
5791
|
return takeCpuProfile(windowId, workerName);
|
|
5789
5792
|
};
|
|
5790
5793
|
|
|
5791
|
-
const getFileName = workerName => {
|
|
5794
|
+
const getFileName$1 = workerName => {
|
|
5792
5795
|
const safeWorkerName = workerName.replaceAll(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-/, '').replace(/-$/, '') || 'worker';
|
|
5793
5796
|
return `${safeWorkerName}-${Date.now()}.heapsnapshot`;
|
|
5794
5797
|
};
|
|
@@ -5828,7 +5831,7 @@ const takeWorkerHeapSnapshot = async (windowId, workerName) => {
|
|
|
5828
5831
|
mkdirSync(downloadsPath, {
|
|
5829
5832
|
recursive: true
|
|
5830
5833
|
});
|
|
5831
|
-
filePath = join$1(downloadsPath, getFileName(workerName));
|
|
5834
|
+
filePath = join$1(downloadsPath, getFileName$1(workerName));
|
|
5832
5835
|
fileDescriptor = openSync(filePath, 'wx');
|
|
5833
5836
|
const currentFileDescriptor = fileDescriptor;
|
|
5834
5837
|
let writeError;
|
|
@@ -5882,6 +5885,96 @@ const takeWorkerHeapSnapshot = async (windowId, workerName) => {
|
|
|
5882
5885
|
}
|
|
5883
5886
|
};
|
|
5884
5887
|
|
|
5888
|
+
const getFileName = pid => {
|
|
5889
|
+
return `renderer-${pid}-${Date.now()}.heapsnapshot`;
|
|
5890
|
+
};
|
|
5891
|
+
const getRendererWebContents = pid => {
|
|
5892
|
+
for (const browserWindow of Electron.BrowserWindow.getAllWindows()) {
|
|
5893
|
+
const {
|
|
5894
|
+
webContents
|
|
5895
|
+
} = browserWindow;
|
|
5896
|
+
if (webContents.getOSProcessId() === pid) {
|
|
5897
|
+
return webContents;
|
|
5898
|
+
}
|
|
5899
|
+
}
|
|
5900
|
+
for (const value of getAll()) {
|
|
5901
|
+
const {
|
|
5902
|
+
webContents
|
|
5903
|
+
} = value.view;
|
|
5904
|
+
if (webContents.getOSProcessId() === pid) {
|
|
5905
|
+
return webContents;
|
|
5906
|
+
}
|
|
5907
|
+
}
|
|
5908
|
+
return undefined;
|
|
5909
|
+
};
|
|
5910
|
+
const takeRendererHeapSnapshot = async pid => {
|
|
5911
|
+
number(pid);
|
|
5912
|
+
const webContents = getRendererWebContents(pid);
|
|
5913
|
+
if (!webContents) {
|
|
5914
|
+
throw new Error(`Renderer process not found: ${pid}`);
|
|
5915
|
+
}
|
|
5916
|
+
if (webContents.isDestroyed()) {
|
|
5917
|
+
throw new Error(`Renderer process was destroyed: ${pid}`);
|
|
5918
|
+
}
|
|
5919
|
+
const electronDebugger = webContents.debugger;
|
|
5920
|
+
const wasAttached = electronDebugger.isAttached();
|
|
5921
|
+
let fileDescriptor;
|
|
5922
|
+
let filePath = '';
|
|
5923
|
+
let writeError;
|
|
5924
|
+
let success = false;
|
|
5925
|
+
if (!wasAttached) {
|
|
5926
|
+
electronDebugger.attach();
|
|
5927
|
+
}
|
|
5928
|
+
try {
|
|
5929
|
+
const downloadsPath = Electron.app.getPath('downloads');
|
|
5930
|
+
mkdirSync(downloadsPath, {
|
|
5931
|
+
recursive: true
|
|
5932
|
+
});
|
|
5933
|
+
filePath = join$1(downloadsPath, getFileName(pid));
|
|
5934
|
+
fileDescriptor = openSync(filePath, 'wx');
|
|
5935
|
+
const currentFileDescriptor = fileDescriptor;
|
|
5936
|
+
const handleMessage = (_event, method, parameters, sessionId) => {
|
|
5937
|
+
if (method !== 'HeapProfiler.addHeapSnapshotChunk' || sessionId || writeError) {
|
|
5938
|
+
return;
|
|
5939
|
+
}
|
|
5940
|
+
try {
|
|
5941
|
+
writeSync(currentFileDescriptor, parameters.chunk);
|
|
5942
|
+
} catch (error) {
|
|
5943
|
+
writeError = error;
|
|
5944
|
+
}
|
|
5945
|
+
};
|
|
5946
|
+
electronDebugger.on('message', handleMessage);
|
|
5947
|
+
try {
|
|
5948
|
+
await electronDebugger.sendCommand('HeapProfiler.enable');
|
|
5949
|
+
await electronDebugger.sendCommand('HeapProfiler.takeHeapSnapshot', {
|
|
5950
|
+
reportProgress: false
|
|
5951
|
+
});
|
|
5952
|
+
if (writeError) {
|
|
5953
|
+
throw writeError;
|
|
5954
|
+
}
|
|
5955
|
+
} finally {
|
|
5956
|
+
electronDebugger.off('message', handleMessage);
|
|
5957
|
+
}
|
|
5958
|
+
success = true;
|
|
5959
|
+
return pathToFileURL(filePath).href;
|
|
5960
|
+
} finally {
|
|
5961
|
+
try {
|
|
5962
|
+
if (fileDescriptor !== undefined) {
|
|
5963
|
+
closeSync(fileDescriptor);
|
|
5964
|
+
}
|
|
5965
|
+
if (!success && filePath) {
|
|
5966
|
+
rmSync(filePath, {
|
|
5967
|
+
force: true
|
|
5968
|
+
});
|
|
5969
|
+
}
|
|
5970
|
+
} finally {
|
|
5971
|
+
if (!wasAttached && electronDebugger.isAttached()) {
|
|
5972
|
+
electronDebugger.detach();
|
|
5973
|
+
}
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
5976
|
+
};
|
|
5977
|
+
|
|
5885
5978
|
const getPerformanceEntries = () => {
|
|
5886
5979
|
const entries = getEntries();
|
|
5887
5980
|
const {
|
|
@@ -8186,6 +8279,7 @@ const commandMap = {
|
|
|
8186
8279
|
'ElectronContextMenu.openContextMenu': openContextMenu,
|
|
8187
8280
|
'ElectronDeveloper.crashMainProcess': crashMainProcess,
|
|
8188
8281
|
'ElectronDeveloper.getPerformanceEntries': getPerformanceEntries,
|
|
8282
|
+
'ElectronDeveloper.takeRendererHeapSnapshot': takeRendererHeapSnapshot,
|
|
8189
8283
|
'ElectronDeveloper.takeWindowCpuProfile': takeWindowCpuProfile,
|
|
8190
8284
|
'ElectronDeveloper.takeWorkerCpuProfile': takeWorkerCpuProfile,
|
|
8191
8285
|
'ElectronDeveloper.takeWorkerHeapSnapshot': takeWorkerHeapSnapshot,
|