Skip to content

Commit

Permalink
Fix electron modules handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Feb 21, 2024
1 parent cce59da commit e377b97
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions app/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,23 @@ function resolveModuleRef(cache, cacheKey, scriptId, url, functionName) {
entry.name = cache.anonymous.get(scriptId);
}
} else {
entry.protocol = (url.match(/^([a-z\-]+):/i) || [])[1] || '';
if (url.startsWith('node:electron/') || url.startsWith('electron/')) {
entry.protocol = 'electron';
url = url.slice(url.indexOf('/') + 1);
} else {
entry.protocol = (url.match(/^([a-z\-]+):/i) || [])[1] || '';
}

if (entry.protocol.length === 1 && /[A-Z]/.test(entry.protocol)) {
entry.protocol = '';
url = url.slice(2).replace(/\\/g, '/');
}

switch (entry.protocol) {
case '': {
const prefix = (url.match(/^[^/]+(?=\/)/) || [])[0];

switch (url !== prefix && prefix) {
// case 'blink':
// case 'v8':
case 'electron':
entry.type = prefix;
entry.path = url;
break;

default:
entry.type = 'script';
entry.path = 'file://' + url;
}
case '':
entry.type = 'script';
entry.path = 'file://' + url;
break;
}

case 'file':
case 'http':
Expand All @@ -169,6 +161,11 @@ function resolveModuleRef(cache, cacheKey, scriptId, url, functionName) {
entry.path = url;
break;

case 'electron':
entry.type = 'electron';
entry.path = url;
break;

default:
entry.type = `protocol-${entry.protocol}`;
entry.name = url;
Expand Down Expand Up @@ -756,7 +753,7 @@ export default function(data, { rejectData, defineObjectMarker, addValueAnnotati
data.functionTree = aggregateNodes(wellKnownNodes.root, functions, node => node.function);

// build segments
data.naturalTree = buildSegments(data, nodeById, wellKnownNodes.gc);
// data.naturalTree = buildSegments(data, nodeById, wellKnownNodes.gc);

// extend jora's queries with custom methods
addQueryHelpers({
Expand Down

0 comments on commit e377b97

Please sign in to comment.