-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devtools): integrate react devtools (#5042)
- Loading branch information
Showing
108 changed files
with
686 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,63 @@ | ||
/* WARNING: NO ES6 SYNTAX HERE!!! */ | ||
/* eslint-disable no-inner-declarations */ | ||
/* eslint-disable no-var */ | ||
import { initialize } from 'react-devtools-inline/backend'; | ||
import routesManifest from '../dist/routes-manifest.json'; | ||
|
||
(function () { | ||
if (!window.opener) { | ||
try { | ||
var container = document.createElement('div'); | ||
container.className = '_modern_js_devtools_container'; | ||
document.body.appendChild(container); | ||
|
||
var shadow = container.attachShadow({ mode: 'closed' }); | ||
|
||
routesManifest.routeAssets.mount.assets.forEach(function (asset) { | ||
var el; | ||
if (asset.endsWith('.js')) { | ||
el = document.createElement('script'); | ||
el.src = asset; | ||
} else if (asset.endsWith('.css')) { | ||
el = document.createElement('link'); | ||
el.href = asset; | ||
el.rel = 'stylesheet'; | ||
// Delete existing devtools hooks registered by react devtools extension. | ||
try { | ||
delete window.__REACT_DEVTOOLS_GLOBAL_HOOK__; | ||
} catch {} | ||
// Call this before importing React (or any other packages that might import React). | ||
initialize(window); | ||
// Deny react devtools extension to activate. | ||
const originSubHook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__.sub; | ||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.sub = (e, handler) => { | ||
if (e === 'devtools-backend-installed') { | ||
return undefined; | ||
} | ||
shadow.appendChild(el); | ||
}); | ||
|
||
var app = document.createElement('div'); | ||
app.className = '_modern_js_devtools_mountpoint theme-register'; | ||
var appGlobalExport = '_modern_js_devtools_app'; | ||
window[appGlobalExport] = { | ||
container: app, | ||
// eslint-disable-next-line no-undef | ||
resourceQuery: __resourceQuery, | ||
return originSubHook(e, handler); | ||
}; | ||
shadow.appendChild(app); | ||
} catch (err) { | ||
var e = new Error('Failed to execute mount point of DevTools.'); | ||
const e = new Error('Failed to inject React DevTools backend.'); | ||
e.cause = err; | ||
console.error(e); | ||
} | ||
})(); | ||
} | ||
|
||
try { | ||
const container = document.createElement('div'); | ||
container.className = '_modern_js_devtools_container'; | ||
document.body.appendChild(container); | ||
|
||
const shadow = container.attachShadow({ mode: 'closed' }); | ||
|
||
for (const asset of routesManifest.routeAssets.mount.assets) { | ||
if (asset.endsWith('.js')) { | ||
const el = document.createElement('script'); | ||
el.src = asset; | ||
shadow.appendChild(el); | ||
} else if (asset.endsWith('.css')) { | ||
const el = document.createElement('link'); | ||
el.href = asset; | ||
el.rel = 'stylesheet'; | ||
shadow.appendChild(el); | ||
} else { | ||
console.warn(new Error(`Can't resolve unknown asset tag: ${asset}`)); | ||
} | ||
} | ||
|
||
const app = document.createElement('div'); | ||
app.className = '_modern_js_devtools_mountpoint theme-register'; | ||
const appGlobalExport = '_modern_js_devtools_app'; | ||
window[appGlobalExport] ||= {}; | ||
Object.assign(window[appGlobalExport], { | ||
container: app, | ||
// eslint-disable-next-line no-undef | ||
resourceQuery: __resourceQuery, | ||
}); | ||
shadow.appendChild(app); | ||
} catch (err) { | ||
const e = new Error('Failed to execute mount point of DevTools.'); | ||
e.cause = err; | ||
console.error(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,31 +42,36 @@ | |
"@radix-ui/react-popover": "^1.0.7", | ||
"@radix-ui/react-tabs": "^1.0.4", | ||
"@radix-ui/themes": "^2.0.0", | ||
"@types/jest": "^29", | ||
"@rsbuild/core": "^0.1.0", | ||
"@types/jest": "^29", | ||
"@types/lodash": "^4.14.202", | ||
"@types/node": "~16.11.7", | ||
"@types/react": "^18", | ||
"@types/react-devtools-inline": "^4.24.8", | ||
"@types/react-dom": "^18", | ||
"birpc": "0.2.13", | ||
"clsx": "^1.2.1", | ||
"lodash": "^4.17.21", | ||
"nanoid": "3.3.4", | ||
"p-defer": "^3.0.0", | ||
"postcss-custom-media": "^10.0.1", | ||
"react": "~18.2.0", | ||
"react": "^18.2.0", | ||
"react-exp": "npm:[email protected]", | ||
"react-base16-styling": "^0.9.1", | ||
"react-dom": "~18.2.0", | ||
"react-devtools-inline": "^4.28.5", | ||
"react-dom": "^18.2.0", | ||
"react-dom-exp": "npm:[email protected]", | ||
"react-icons": "^4.11.0", | ||
"react-is": "^18", | ||
"react-json-tree": "^0.18.0", | ||
"react-json-view": "^1.21.3", | ||
"react-use": "^17.4.0", | ||
"rimraf": "^3.0.2", | ||
"scheduler": "^0.23.0", | ||
"suspend-react": "^0.1.3", | ||
"type-fest": "^4.1.0", | ||
"typescript": "~5.0.4", | ||
"ufo": "^1.3.0", | ||
"valtio": "^1.11.1" | ||
}, | ||
"dependencies": {} | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
packages/devtools/client/src/client/components/HeaderRule/Editor.module.scss
This file was deleted.
Oops, something went wrong.
105 changes: 0 additions & 105 deletions
105
packages/devtools/client/src/client/components/HeaderRule/Editor.tsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...t/routes/config/[toolkit].[type]/page.tsx → ...t/routes/config/[toolkit].[type]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...rc/client/routes/context/builder/page.tsx → ...es/client/routes/context/builder/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../client/routes/context/framework/page.tsx → .../client/routes/context/framework/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.