feat: add page renderer detection tool#16
Open
Darley-Wey wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new Page tool to detect the current Mini Program renderer (WebView vs Skyline) and refines the guidance shown to users for cross-component bounding client rect queries.
Changes:
- Add
page_getRenderertool that callswx.getSkylineInfoSync()and returns the inferred renderer plus raw diagnostics. - Register the new tool in the Page tools list.
- Update
element_getBoundingClientRectdescription to clarify howselector/innerSelectorshould be used with custom components.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/tools/page.ts |
Adds and registers page_getRenderer renderer-detection tool and outputs diagnostics. |
src/tools/element.ts |
Updates tool description text to clarify selector behavior across custom components. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+389
to
+393
| skylineInfo = await miniProgram.callWxMethod("getSkylineInfoSync"); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| throw new UserError(`调用 wx.getSkylineInfoSync() 失败: ${message}`); | ||
| } |
Owner
|
感谢贡献!这里我建议调整一下实现方向:不新增 原因有两个:
我这边实测到一个反例: {
"renderer": "webview",
"skylineInfo": {
"isSupported": true,
"version": "1.4.7"
}
}建议改法:
const runtimeInfo = await miniProgram.evaluate(() => {
const pages = getCurrentPages();
const page = pages[pages.length - 1];
return {
renderer: page?.renderer ?? null,
skylineInfo:
typeof wx.getSkylineInfoSync === "function"
? wx.getSkylineInfoSync()
: null,
};
});这样 |
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.
Summary
Validation