Un-deprecate Resource.base64, compute bytes/base64 in terms of each other (#1138)

This makes changes to avoid a needless breaking change.
It preserves code like `new Resource { base64 = someValue }.sha256`,
and also code that renders `Resource` into static formats.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
This commit is contained in:
Daniel Chao
2025-07-23 06:25:49 -07:00
committed by GitHub
parent 03d8e01801
commit bdf6aa6b60
12 changed files with 270 additions and 227 deletions

View File

@@ -513,6 +513,9 @@ class PropertiesRenderer extends ValueRenderer {
/// An external (file, HTTP, etc.) resource.
///
/// Usually, a [Resource] is obtained via a `read()` expression, such as `read("some/file")`.
///
/// When created directly, either of [bytes] or [base64] can be set, and the other will be
/// computed in terms of the set value.
class Resource {
/// The URI of this resource.
uri: Uri
@@ -520,13 +523,12 @@ class Resource {
/// The text content of this resource.
text: String
/// The content of this resource in Base64 encoding.
base64: String = bytes.base64
/// The bytes of this resource.
@Since { version = "0.29.0" }
bytes: Bytes
/// The content of this resource in Base64.
@Deprecated { since = "0.29.0"; message = "Use bytes.base64 instead" }
hidden base64: String = bytes.base64
hidden bytes: Bytes = base64.base64DecodedBytes
/// The [MD5](https://en.wikipedia.org/wiki/MD5)
/// hash of this resource as hexadecimal string.