Skip to content

Commit d641478

Browse files
committed
Combine detector and debugger scipts to single real_world script
1 parent ab28cde commit d641478

File tree

8 files changed

+204
-211
lines changed

8 files changed

+204
-211
lines changed

packages/extension/src/background.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ chrome.runtime.onConnect.addListener(port => {
8484

8585
function toggle_action_icon(tab_id: Tab_Id) {
8686

87-
if (script_content_map.get(tab_id)?.detection?.Solid) {
87+
if (script_content_map.get(tab_id)?.detection?.solid) {
8888
chrome.action.setIcon({tabId: tab_id, path: ICONS_BLUE})
8989

9090
/*
9191
For some reason setting the icon immediately does not always work
9292
*/
9393
setTimeout(() => {
94-
if (script_content_map.get(tab_id)?.detection?.Solid) {
94+
if (script_content_map.get(tab_id)?.detection?.solid) {
9595
chrome.action.setIcon({tabId: tab_id, path: ICONS_BLUE})
9696
} else {
9797
chrome.action.setIcon({tabId: tab_id, path: ICONS_GRAY})

packages/extension/src/content.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import {
1818
} from './shared.ts'
1919

2020
// @ts-expect-error ?script&module query ensures output in ES module format and only import the script path
21-
import detector_path from './detector.ts?script&module'
22-
// @ts-expect-error ?script&module query ensures output in ES module format and only import the script path
23-
import debugger_path from './debugger.ts?script&module'
21+
import real_world_path from './real_world.ts?script&module'
2422

2523

2624
DEV: {log(Place_Name.Content+' loaded.')}
@@ -55,14 +53,14 @@ if (document.readyState === 'complete') {
5553
function on_loaded() {
5654

5755
/*
58-
Load Detect_Real_World script
56+
Load Real_World script
5957
↳ Debugger_Setup detected
60-
↳ Load Debugger_Real_World
58+
↳ Load Debugger
6159
↳ 'Debugger_Connected' message
6260
*/
6361

64-
loadScriptInRealWorld(detector_path)
65-
.catch(err => error(`Detector_Real_World (${detector_path}) failed to load.`, err))
62+
loadScriptInRealWorld(real_world_path)
63+
.catch(err => error(`Real_World script (${real_world_path}) failed to load.`, err))
6664
}
6765

6866

@@ -72,9 +70,6 @@ const port = chrome.runtime.connect({name: ConnectionName.Content})
7270

7371
let devtools_opened = false
7472

75-
// prevent the script to be added multiple times if detected before solid
76-
let debugger_real_world_added = false
77-
7873
/* From Background */
7974
port_on_message(port, e => {
8075
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
@@ -93,22 +88,6 @@ port_on_message(port, e => {
9388
window_on_message(e => {
9489
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
9590
switch (e.name) {
96-
// From Detector_Real_World
97-
case 'Detected': {
98-
99-
/* Forward to Background script */
100-
port_post_message_obj(port, e)
101-
102-
/* Load Debugger_Real_World */
103-
if (e.details && e.details.Debugger && !debugger_real_world_added) {
104-
debugger_real_world_added = true
105-
106-
loadScriptInRealWorld(debugger_path)
107-
.catch(err => error(`Debugger_Real_World (${debugger_path}) failed to load.`, err))
108-
}
109-
110-
break
111-
}
11291
case 'Debugger_Connected': {
11392

11493
// eslint-disable-next-line no-console
@@ -122,7 +101,7 @@ window_on_message(e => {
122101
client: e.details.client,
123102
solid: e.details.solid,
124103
extension: extension_version,
125-
expectedClient: import.meta.env.EXPECTED_CLIENT,
104+
client_expected: import.meta.env.EXPECTED_CLIENT,
126105
})
127106

128107
if (devtools_opened) {

packages/extension/src/debugger.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

packages/extension/src/detector.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

packages/extension/src/panel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ function App() {
2222
const empty_versions: Versions = {
2323
solid: '',
2424
client: '',
25-
expectedClient: '',
25+
client_expected: '',
2626
extension: '',
2727
}
2828
const [versions, setVersions] = s.createSignal<Versions>(empty_versions)
2929

3030
const devtools = frontend.createDevtools()
31-
31+
3232
const port = chrome.runtime.connect({name: ConnectionName.Panel})
3333
port_on_message(port, e => {
3434
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
@@ -58,14 +58,14 @@ function App() {
5858
>
5959
<devtools.Devtools
6060
headerSubtitle={`#${versions().extension}_${versions().client}/${
61-
versions().expectedClient
61+
versions().client_expected
6262
}`}
6363
errorOverlayFooter={
6464
<ul>
6565
<li>Solid: {versions().solid}</li>
6666
<li>Extension: {versions().extension}</li>
6767
<li>Client: {versions().client}</li>
68-
<li>Expected client: {versions().expectedClient}</li>
68+
<li>Expected client: {versions().client_expected}</li>
6969
</ul>
7070
}
7171
useShortcuts

packages/extension/src/popup.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const port = chrome.runtime.connect({name: ConnectionName.Popup})
1818

1919
const [versions, setVersions] = s.createSignal<Versions | null>(null)
2020
const empty_detection_state: DetectionState = {
21-
Solid: false,
22-
SolidDev: false,
23-
Debugger: false,
21+
solid: false,
22+
solid_dev: false,
23+
setup: false,
2424
}
2525
const [detectionState, setDetectionState] = s.createSignal(empty_detection_state)
2626

@@ -39,20 +39,20 @@ port_on_message(port, e => {
3939
const App: s.Component = () => {
4040
return <>
4141
<div>
42-
<p data-detected={detectionState().Solid}>
43-
Solid {detectionState().Solid ? 'detected' : 'not detected'}
42+
<p data-detected={detectionState().solid}>
43+
Solid {detectionState().solid ? 'detected' : 'not detected'}
4444
</p>
4545
</div>
4646
<div>
47-
<p data-detected={detectionState().SolidDev}>
48-
Solid Dev Mode {detectionState().SolidDev ? 'detected' : 'not detected'}
47+
<p data-detected={detectionState().solid_dev}>
48+
Solid Dev Mode {detectionState().solid_dev ? 'detected' : 'not detected'}
4949
</p>
5050
</div>
5151
<div>
52-
<p data-detected={detectionState().Debugger}>
53-
Debugger {detectionState().Debugger ? 'detected' : 'not detected'}
52+
<p data-detected={detectionState().setup}>
53+
Debugger {detectionState().setup ? 'detected' : 'not detected'}
5454
</p>
55-
<s.Show when={detectionState().SolidDev && !detectionState().Debugger}>
55+
<s.Show when={detectionState().solid_dev && !detectionState().setup}>
5656
<div class="details">
5757
<p>
5858
Devtools extension requires a runtime client to be installed.
@@ -77,7 +77,7 @@ const App: s.Component = () => {
7777
<li>Solid ___________ {v.solid || 'unknown'}</li>
7878
<li>Extension _______ {v.extension}</li>
7979
<li>Client found ____ {v.client || 'unknown'}</li>
80-
<li>Client expected _ {v.expectedClient}</li>
80+
<li>Client expected _ {v.client_expected}</li>
8181
</ul>
8282
</div>
8383
)}

0 commit comments

Comments
 (0)