Skip to content

Conversation

Runc2333
Copy link
Contributor

@Runc2333 Runc2333 commented Sep 7, 2025

这个 PR 做了什么? (简要描述所做更改)

修正 createBufferURL 的类型定义
ref: https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.createBufferURL.html

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

  • 新功能
    • createBufferURL 现返回字符串,可直接获得生成的 Buffer URL,便于存储、传递与复用。
    • 开发者可使用返回值在页面或组件中直接绑定展示或持久化,无需额外转换。

Copy link

coderabbitai bot commented Sep 7, 2025

Walkthrough

packages/taro/types/api/storage/index.d.tsTaroStatic.createBufferURL 的返回类型由 void 更新为 string,参数保持不变。

Changes

Cohort / File(s) Change Summary
Types: Taro Storage API
packages/taro/types/api/storage/index.d.ts
更新 TaroStatic.createBufferURL(buffer: ArrayBuffer | TypedArray) 的返回类型:voidstring;其他签名未变。

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字符串
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • Single-Dancer

Poem

小兔挥笔改类型,耳朵随风轻轻晃,
旧日空回无声息,今日字符串回响。
一缕 URL 出指尖,缓冲化作清晰光,
蹦跳提交入主干,胡萝卜也笑得香。 🥕✨

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot requested a review from Single-Dancer September 7, 2025 10:57
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1676906 and 69b0ab6.

📒 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 的逻辑。

Copy link

codecov bot commented Sep 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.06%. Comparing base (1676906) to head (69b0ab6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           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     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 51 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

/** 需要存入内存的二进制数据 */
buffer: ArrayBuffer | TypedArray
): void
): string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是 Promise 的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image 同步方法

@Runc2333 Runc2333 requested a review from yoyo837 September 8, 2025 21:25
@yoyo837 yoyo837 merged commit 54c1c98 into NervJS:main Sep 9, 2025
24 checks passed
This was referenced Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants