-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(weapp/createBufferURL): 修正 createBufferURL 的类型定义 #18325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough将 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller as 调用方
participant Taro as TaroStatic
Caller->>Taro: createBufferURL(buffer: ArrayBuffer|TypedArray)
note right of Taro: 生成内部Buffer的URL表示
Taro-->>Caller: string (URL)
note over Caller: 以前无返回值;现在需处理/可使用URL字符串
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/taro/types/api/storage/index.d.ts (2)
306-314
: 补充 JSDoc:标注返回值与示例用法。
有利于使用者快速理解与及时释放内存。/** 根据传入的 buffer 创建一个唯一的 URL 存在内存中 * @supported weapp + * @returns 返回内存中该 buffer 对应的唯一 URL(请在不再使用时调用 revokeBufferURL 释放)。 + * @example + * ```ts + * const url = Taro.createBufferURL(buffer) + * // 用于 <Image/>、<Video/> 等组件或能力 + * Taro.revokeBufferURL(url) // 不再需要时请及时释放 + * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.createBufferURL.html */ createBufferURL( /** 需要存入内存的二进制数据 */ buffer: ArrayBuffer | TypedArray ): string
5-15
: (可选)考虑是否需要支持 DataView。
如果微信侧也接受 ArrayBufferView,则可以纳入 DataView,扩大兼容范围;若官方未明确支持,可忽略本建议。type TypedArray = | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array - | Float64Array + | Float64Array + | DataView
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/taro/types/api/storage/index.d.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
🔇 Additional comments (2)
packages/taro/types/api/storage/index.d.ts (2)
310-314
: 返回类型更正为 string,和微信小程序文档一致,变更合理。
与 revokeBufferURL(url: string) 搭配也更一致,类型对称性更好。
310-314
: 请核对实现与调用点是否匹配(防止运行时与类型不一致)。
若运行时未返回字符串会导致类型与行为不符。#!/bin/bash # 1) 检查是否仍存在返回 void 的声明(除本文件外) rg -nP -g '!**/dist/**' -g '!**/node_modules/**' 'createBufferURL\s*\([^)]*\)\s*:\s*void' # 2) 检查所有实现/调用点,确认有返回值且调用方可能使用该返回值 rg -nP -g '!**/dist/**' -g '!**/node_modules/**' 'createBufferURL\s*\(' -C3 # 3) 交叉检查 weapp 端实现是否确实返回字符串 rg -nP -g '!**/dist/**' -g '!**/node_modules/**' '(createBufferURL|revokeBufferURL)' -C3期望:1) 无匹配;2) 调用点可选择接收字符串;3) weapp 端实现包含返回 URL 的逻辑。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18325 +/- ##
=======================================
Coverage 55.06% 55.06%
=======================================
Files 416 416
Lines 21564 21564
Branches 5276 5268 -8
=======================================
Hits 11874 11874
- Misses 8072 8162 +90
+ Partials 1618 1528 -90
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
/** 需要存入内存的二进制数据 */ | ||
buffer: ArrayBuffer | TypedArray | ||
): void | ||
): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是 Promise 的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 PR 做了什么? (简要描述所做更改)
修正 createBufferURL 的类型定义
ref: https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.createBufferURL.html
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit