chat_message_core 0.0.4
chat_message_core: ^0.0.4 copied to clipboard
Pure Dart data models and core logic for chat messaging.
0.0.4 #
BREAKING CHANGES
toJson()is now deep (explicit_to_json: true): nestedauthor,repliedMessage,previewData,image,usersandlastMessagesare emitted as plain maps/lists instead of model objects.jsonEncodeoutput is unchanged.AudioMessageModel.copyWithnow treats an explicitnullas "clear this field", like every other model. Before, passingnullkept the existing value. Migration: if you forward nullable values (for exampleaudio.copyWith(remoteId: response.remoteId)), pass only the fields you mean to change, or fall back explicitly (response.remoteId ?? audio.remoteId).getPreviewDatano longer puts theproxyprefix inPreviewData.link;linkis always the original URL. The proxy still applies to the request and to image URLs.ChatCoreRegex.regexImageContentTypeis now anchored (^image\/). Before, it matched any string containing "image", such asapplication/x-apple-diskimage.- Removed the unused
metadataparameter fromImageMessageModel.copyWithandVideoMessageModel.copyWith Roomequality andhashCodenow includelastMessages(compared deeply). Key maps and sets byroom.id, not byRoom.- Message equality now includes
type - Requires Dart SDK
^3.9.2(0.0.3 allowed^3.7.2), becausejson_annotation ^4.12.0andintl ^0.20.3require Dart 3.9
Features
getPreviewDatatakes an optionalonError(error, stackTrace)callback. Errors are also logged withdart:developerin debug builds only.
Fixes
copyWithon text, image and video messages no longer clearsroomIdwhen it is not passedcopyWithon messages keeps a customtypeinstead of resetting it to the defaultMessageModel.fromJson(message.toJson())round-trips without throwinggetPreviewData:- Direct image links return an image preview. The image body is no longer downloaded (before, it was downloaded and then failed UTF-8 decoding).
- Direct
image/svg+xmlandimage/giflinks return only the link, matching how og:image and<img>already skip SVG and GIF - Non-2xx responses are treated as failed requests (link only) instead of previewing the error page
- Non-HTML responses (PDF, video, ...) return only the link
- Pages are decoded with the charset from the
Content-Typeheader or a<meta>tag (UTF-8, Latin-1, ASCII). Before, any page declaring a non-UTF-8 charset returned empty data, without even the link. - With
proxyset, several images and noimageSizeResolver, the chosen first image now has the proxy prefix
- Removed the unused
lastSeenparameter from theChatUser.copyWithimplementation
Chores
- Dependency updates:
json_annotation ^4.12.0,intl ^0.20.3,meta ^1.19.0,http ^1.6.0,html ^0.15.7 equatablenow allows>=2.0.7 <4.0.0. With equatable 3.x,toString()in release builds (stringify off) returnsInstance of '_TextMessage'instead of_TextMessage.- Enabled
package:lints/recommended.yaml - Added a test suite (
dart test) - Updated README for the 0.0.3+ API
0.0.3 #
BREAKING CHANGES
- Moved all top-level utility functions (
formatBytes,getUserInitials,getUserName,formattedDateTimeRep,calculateChatMessages,getPreviewData) into theChatCoreFunctionsclass - Moved all top-level regex constants (
regexEmail,regexImageContentType,regexLink,urlRegex,looseUrlRegex,protocolIdentifierRegex) into theChatCoreRegexclass - Removed
ChatL10nand all locale implementations (ChatL10nEn,ChatL10nDe,ChatL10nEs, etc.) - Merged
preview_data_fetcher.dartintofunctions.dart;getPreviewDatanow lives onChatCoreFunctions - Barrel now exports all symbols from
regex.dartandfunctions.dart(no longer selectively exported)
0.0.2 #
- misc fixes and improvements
0.0.1 #
- Initial release.