Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b2e67ab

Browse files
added back context menu with port cleanup after window close
1 parent 0d0f4bb commit b2e67ab

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

‎README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,22 @@ These updates make Reactime more powerful, reliable, and user-friendly than ever
176176
- React Developer Tools extension must be installed
177177
- Chrome browser (version 80 or higher recommended)
178178

179-
### Launch Reactime
179+
### Launch Reactime\
180+
181+
There are two ways to open the Reactime panel:
182+
183+
1. **DevTools**
180184

181185
- Open Chrome DevTools (F12 or ⌘+⌥+I)
182186
- Navigate to the "Reactime" tab
183187
- This will open Reactime as a panel within Chrome DevTools, integrated alongside your other development tools
184188

189+
2. **Context Menu**
190+
191+
- Right-click anywhere on your React application
192+
- Select "Reactime" from the context menu
193+
- This will open Reactime in a separate popup window which you can resize and position independently
194+
185195
Once launched, Reactime will automatically begin monitoring your application's state changes and performance metrics.
186196
<br>
187197
<br>

‎src/extension/background.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,3 +880,45 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
880880
sendResponse({ success: true });
881881
}
882882
});
883+
884+
// when reactime is installed
885+
// create a context menu that will open our devtools in a new window
886+
chrome.runtime.onInstalled.addListener(() => {
887+
chrome.contextMenus.create({
888+
id: 'reactime',
889+
title: 'Reactime',
890+
contexts: ['page', 'selection', 'image', 'link'],
891+
});
892+
});
893+
894+
chrome.contextMenus.onClicked.addListener((info, tab) => {
895+
if (info.menuItemId === 'reactime') {
896+
chrome.windows
897+
.create({
898+
url: chrome.runtime.getURL('panel.html'),
899+
type: 'popup',
900+
width: 1200,
901+
height: 800,
902+
})
903+
.then((window) => {
904+
// Listen for window close
905+
chrome.windows.onRemoved.addListener(function windowClosedListener(windowId) {
906+
if (windowId === window.id) {
907+
// Cleanup when window is closed
908+
portsArr.forEach((port) => {
909+
try {
910+
port.disconnect();
911+
} catch (error) {
912+
console.warn('Error disconnecting port:', error);
913+
}
914+
});
915+
// Clear the ports array
916+
portsArr.length = 0;
917+
918+
// Remove this specific listener
919+
chrome.windows.onRemoved.removeListener(windowClosedListener);
920+
}
921+
});
922+
});
923+
}
924+
});

‎src/extension/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"matches": ["<all_urls>"]
2525
}
2626
],
27-
"permissions": ["tabs", "activeTab", "scripting", "debugger", "alarms"],
27+
"permissions": ["contextMenus", "tabs", "activeTab", "scripting", "debugger", "alarms"],
2828
"host_permissions": ["<all_urls>"]
2929
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /