Skip to content
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

Switch to v2 #948

Merged
merged 253 commits into from
Jul 30, 2024
Merged

Switch to v2 #948

merged 253 commits into from
Jul 30, 2024

Conversation

timostamm
Copy link
Member

This merges the branch v2 into main. A copy of main is kept in the branch v1.

timostamm and others added 30 commits March 1, 2024 16:11
Remove the toString method, and let GeneratedFile.jsDoc() return a Printable.

This brings the JSDocBlock printable in line with others.
And provide utilities for Timestamp, such as timestampNow()
Add `toBinary` and `fromBinary` functions to serialize to and from
protobuf encoded bytes. Added compatibility tests with v1 for now.
Ignore in prettier. Move Node10 module resolution fallbacks to correct path.
This annotation informs bundlers that the succeeding function call is free of side effects. This means the symbol can be removed from the module during tree-shaking if it is unused.

See #470

The annotation is not terribly effective yet, since all generated descriptors depend on the file descriptor, but it's still worthwhile.
This adds two new types to the reflect API: ReflectList and ReflectMap. The API now always returns messages as ReflectMessage, list fields as ReflectList, and map fields as ReflectMap. Note that accessing an unset message fields returns a ReflectMessage with a new zero-message.

The methods ReflectMessage.addListItem and ReflectMessage.setMapEntry are kept for now. We can decide whether it's worth to keep them for the hot path when we take a look at performance.

This also updates create() to fully support the "init" argument.
The IEEE standard requires that NaN != NaN. It's questionable whether that should also be the case when comparing two protobuf fields,
The message descriptor contains cyclic references and methods, causing issues with Jest, RSC serialization, structured clone, and others.

By removing the property, messages are no longer self-describing, and functions that need schema information require the user to path both the message descriptor and the message.
Most importantly, tests for serializing map fields.

Fixes a bug in fromBinary, where map keys were converted to strings, which are the correct representation in a message, but not for a ReflectMap. This bug was most likely introduced in 7054ed7, which limited the conversion to a smaller set of acceptable types.
In case of a test failure, we'll see the diff instead of Jest crashing.
See jestjs/jest#11617 (comment)

There don't appear to be any adverse effects of enabling the option. Test failures when strictly comparing message classes are still reported correctly.
In order to reduce the number of main exports, move types that are rarely needed by end-users to a new subpath "wire".

- BinaryWriter and BinaryReader have been moved, and their interfaces discarded.

- Users can bring their own Text encoding API via wire/configureTextEncoding() now instead of the serialization options readerFactory / writerFactory.

- protoBase64 has been split into the functions base64Decode and base64Encode, with the latter allowing to encode with padding, without padding, or URL-safe.

The exports protoDelimited and protoBase64 are also candidates for moving to wire, but are not moved by this commit.
Move reflect/wkt.ts to wkt/wrappers.ts to keep WKT-specific code in one place. This does not move the code for custom JSON representation of WKTs.
fileDesc() from codegenv1/hydrate.ts restored redundant json names incorrectly, leading DescField.jsonName to be an empty string instead of undefined.
timostamm and others added 25 commits June 28, 2024 18:38
Signed-off-by: Timo Stamm <[email protected]>
Co-authored-by: Carol Gunby <[email protected]>
Co-authored-by: Steve Ayers <[email protected]>
Signed-off-by: Timo Stamm <[email protected]>
Co-authored-by: Timo Stamm <[email protected]>
@timostamm timostamm merged commit 64b8e61 into main Jul 30, 2024
33 checks passed
@timostamm timostamm deleted the v2 branch August 1, 2024 13:53
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.

4 participants