refactor(devtools): type-check devtools hook method names across runtime and eval bridge - #8824
Open
Aejkatappaja wants to merge 3 commits into
Open
refactor(devtools): type-check devtools hook method names across runtime and eval bridge#8824Aejkatappaja wants to merge 3 commits into
Aejkatappaja wants to merge 3 commits into
Conversation
…ime and eval bridge The extension read page data through raw-JS eval strings that referenced hook method names as untyped literals, so a typo or a renamed hook method broke silently at runtime. - Route the extension eval accessors through a typed hookCall(method, ...args) helper whose method name is constrained to the hook contract. - Export QwikDevtoolsHookExtended from kit and type both hook-assignment sites in installers.ts against it (satisfies + cast, erased at build), so a rename on the producer side is now a compile error too. No runtime change: the stringified injected runtime is byte-identical.
🦋 Changeset detectedLatest commit: 9638882 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@qwik.dev/core
@qwik.dev/router
eslint-plugin-qwik
create-qwik
@qwik.dev/optimizer
@qwik.dev/devtools
commit: |
Contributor
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Contributor
|
done @wmertens |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The browser extension reads page data through JS string templates passed to
chrome.devtools.inspectedWindow.eval(). Those templates referenced the devtools hook method names (getComponentDetail,setSignalValue,highlightNode, ...) as untyped string literals, so a typo or a renamed hook method broke silently at runtime with no compile-time, lint, or test signal.Note: the data-extraction logic itself already lives in compiled, type-checked, unit-tested modules (
installers.ts__qwik_install_hook_runtime__/__qwik_install_vnode_runtime__, injected as web-accessible resources, covered byhook-runtime.unit.ts/vnode-runtime.unit.ts). This PR closes the remaining gap: the untyped method-name references on the eval bridge.Solution
Type-check the hook method names on both sides of the bridge.
hookCall(method, ...args)helper whosemethodis constrained tokeyof QwikDevtoolsHookExtended, plus areadHookJsonwrapper. A typo or rename is now a compile error.QwikDevtoolsHookExtendedfrom kit and type both hook-assignment sites ininstallers.tsagainst it (satisfieson the base hook object, a cast on the vnode-bridge hook). A rename on the runtime side is now a compile error too. These annotations are erased at build, so the stringified injected runtime is byte-identical.Why eval is not removed
A devtools panel can only reach the inspected page's main world via
chrome.devtools.inspectedWindow.eval; the content-script/port channel is isolated-world and cannot readwindow.__QWIK_DEVTOOLS__. Soevalis the correct RPC channel here (subscriptions already use the port where it fits). The fix is to make the eval surface type-checked, not to remove it.Verification
installers.tstype-checks against the interface (satisfies+ cast).tscis clean (only two pre-existing wxtTS2742errors); eslint passes on the touched files.References
QwikDev project board, card "p1 Eval Bridge Is Untested and String-Based": https://github.com/orgs/QwikDev/projects/6/views/1