cherry-studio/packages/shared
SuYao 76ee67d4d7
fix: prevent OOM when handling large base64 image data (#12244)
* fix: prevent OOM when handling large base64 image data

- Add memory-safe parseDataUrl utility using string operations instead of regex
- Truncate large base64 data in ErrorBlock detail modal to prevent freezing
- Update ImageViewer, FileStorage, messageConverter to use shared parseDataUrl
- Deprecate parseDataUrlMediaType in favor of shared utility
- Add GB support to formatFileSize
- Add comprehensive unit tests for parseDataUrl (18 tests)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: simplify parseDataUrl API to return DataUrlParts | null

- Change return type from discriminated union to simple nullable type
- Update all call sites to use optional chaining (?.)
- Update tests to use toBeNull() for failure cases
- More idiomatic and consistent with codebase patterns (e.g., parseJSON)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-06 00:34:14 +08:00
..
__tests__ fix: prevent OOM when handling large base64 image data (#12244) 2026-01-06 00:34:14 +08:00
agents/claudecode ⬆️ chore: migrate from Claude Code SDK to Claude Agent SDK v0.1.1 2025-09-30 17:54:02 +08:00
anthropic fix: restore API version control with trailing # delimiter (addresses #11750) (#11773) 2025-12-10 13:42:15 +08:00
config refactor: switch yarn to pnpm (#12260) 2026-01-05 22:16:34 +08:00
IpcChannel.ts fix(ovms): add platform check to prevent errors on non-Windows systems (#12125) 2025-12-31 22:24:53 +08:00
utils.ts fix: prevent OOM when handling large base64 image data (#12244) 2026-01-06 00:34:14 +08:00