@gxp-dev/tools 2.0.24 → 2.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.
@@ -1,9 +1,10 @@
1
1
  // JavaScript Proxy Extension Content Script
2
2
  // This extension handles redirects at the network level via webRequest/declarativeNetRequest APIs
3
- // Content script is mainly used for cache clearing and debugging
3
+ // Content script is mainly used for cache clearing, debugging, and inspector communication
4
4
  (function () {
5
5
  let isProxyEnabled = false;
6
6
  let config = {};
7
+ let inspectorEnabled = false;
7
8
 
8
9
  // Get initial state from background script
9
10
  chrome.runtime
@@ -25,13 +26,40 @@
25
26
  )
26
27
  );
27
28
 
28
- // Listen for state changes from background script
29
+ // Listen for messages from popup/background
29
30
  chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
30
31
  if (message.action === "configUpdate") {
31
32
  isProxyEnabled = message.config.enabled;
32
33
  config = message.config;
33
34
  console.log("[JavaScript Proxy Content] Config updated:", config);
34
35
  }
36
+
37
+ // Inspector toggle request from popup
38
+ if (message.action === "toggleInspector") {
39
+ // Relay to page context via postMessage
40
+ window.postMessage({ type: 'GXP_INSPECTOR_ACTION', action: 'toggleInspector' }, '*');
41
+ // Toggle local state
42
+ inspectorEnabled = !inspectorEnabled;
43
+ sendResponse({ enabled: inspectorEnabled });
44
+ return true;
45
+ }
46
+
47
+ // Get inspector state request from popup
48
+ if (message.action === "getInspectorState") {
49
+ // Check if inspector is loaded in page
50
+ sendResponse({ enabled: inspectorEnabled });
51
+ return true;
52
+ }
53
+ });
54
+
55
+ // Listen for messages from page context (inspector.js)
56
+ window.addEventListener('message', (event) => {
57
+ if (event.source !== window) return;
58
+
59
+ // Inspector state updates from page context
60
+ if (event.data?.type === 'GXP_INSPECTOR_STATE') {
61
+ inspectorEnabled = event.data.enabled;
62
+ }
35
63
  });
36
64
 
37
65
  // Expose proxy state for debugging
@@ -3,6 +3,7 @@
3
3
  const originalFetch = window.fetch;
4
4
  let isProxyEnabled = false;
5
5
  let proxyConfig = {};
6
+ let inspectorEnabled = false;
6
7
 
7
8
  // Get initial state from background script
8
9
  browser.runtime
@@ -22,12 +23,38 @@
22
23
  console.error("[Traffic Proxy Content] Failed to get proxy config:", err)
23
24
  );
24
25
 
25
- // Listen for config changes
26
+ // Listen for config changes and inspector messages
26
27
  browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
27
28
  if (message.action === "configUpdate") {
28
29
  isProxyEnabled = message.enabled;
29
30
  proxyConfig = message.config;
30
31
  }
32
+
33
+ // Inspector toggle request from popup
34
+ if (message.action === "toggleInspector") {
35
+ // Relay to page context via postMessage
36
+ window.postMessage({ type: 'GXP_INSPECTOR_ACTION', action: 'toggleInspector' }, '*');
37
+ // Toggle local state
38
+ inspectorEnabled = !inspectorEnabled;
39
+ sendResponse({ enabled: inspectorEnabled });
40
+ return true;
41
+ }
42
+
43
+ // Get inspector state request from popup
44
+ if (message.action === "getInspectorState") {
45
+ sendResponse({ enabled: inspectorEnabled });
46
+ return true;
47
+ }
48
+ });
49
+
50
+ // Listen for messages from page context (inspector.js)
51
+ window.addEventListener('message', (event) => {
52
+ if (event.source !== window) return;
53
+
54
+ // Inspector state updates from page context
55
+ if (event.data?.type === 'GXP_INSPECTOR_STATE') {
56
+ inspectorEnabled = event.data.enabled;
57
+ }
31
58
  });
32
59
 
33
60
  // Override fetch function
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gxp-dev/tools",
3
- "version": "2.0.24",
3
+ "version": "2.0.25",
4
4
  "description": "Dev tools to create platform plugins",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {