Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@protobufjs/codegen

dcodeIO60.1mBSD-3-Clause2.0.4TypeScript support: included

A minimalistic code generation utility.

readme

@protobufjs/codegen

npm

A minimalistic code generation utility.

API

  • codegen([functionParams: string[]], [functionName: string]): Codegen
    Begins generating a function.

  • codegen.verbose = false
    When set to true, codegen will log generated code to console. Useful for debugging.

Invoking codegen returns an appender function that appends code to the function's body and returns itself:

  • Codegen(formatString: string, [...formatParams: any]): Codegen
    Appends code to the function's body. The format string can contain placeholders specifying the types of inserted format parameters:

    • %d: Number (integer or floating point value)
    • %f: Floating point value
    • %i: Integer value
    • %j: JSON.stringify'ed value
    • %s: String value
    • %%: Percent sign
  • Codegen([scope: Object.<string,*>]): Function
    Finishes the function and returns it.

  • Codegen.toString([functionNameOverride: string]): string
    Returns the function as a string.

Example

var codegen = require("@protobufjs/codegen");

var add = codegen(["a", "b"], "add") // A function with parameters "a" and "b" named "add"
  ("// awesome comment")             // adds the line to the function's body
  ("return a + b - c + %d", 1)       // replaces %d with 1 and adds the line to the body
  ({ c: 1 });                        // adds "c" with a value of 1 to the function's scope

console.log(add.toString()); // function add(a, b) { return a + b - c + 1 }
console.log(add(1, 2));      // calculates 1 + 2 - 1 + 1 = 3

License: BSD 3-Clause License

changelog

Changelog

7.4.0 (2024-08-22)

Features

  • Add prepublishOnly script (0e4da8b)

Bug Fixes

7.3.3 (2024-08-16)

Bug Fixes

  • handle nullability for optional fields (59569c1)

7.3.2 (2024-06-12)

Bug Fixes

  • docs: Update readme to correct command for creating types (#1939) (0f9d477)

7.3.1 (2024-06-05)

Bug Fixes

  • types: reserved field in IType can contain reserved names (#2001) (d1d2c0c)

7.3.0 (2024-05-10)

Features

  • add handling for extension range options (#1990) (2d58011)

7.2.6 (2024-01-16)

Bug Fixes

  • report missing import properly in loadSync (#1960) (af3ff83)

7.2.5 (2023-08-21)

Bug Fixes

7.2.4 (2023-06-23)

Bug Fixes

  • do not let setProperty change the prototype (#1899) (e66379f)

7.2.3 (2023-03-27)

Bug Fixes

  • type names can be split into multiple tokens (#1877) (8817ee6)

7.2.2 (2023-02-07)

Bug Fixes

  • do not allow to extend same field twice to prevent the error (#1784) (14f0536)

7.2.1 (2023-02-02)

Bug Fixes

  • cli: fix relative path to Google pb files (#1859) (e42eea4)
  • Revert "fix: error should be thrown" (4489fa7)
  • use bundled filename to fix common pb includes (#1860) (dce9a2e)
  • use ES5 style function syntax (#1830) (64e8936)

7.2.0 (2023-01-24)

Features

  • cli: generate static files at the granularity of proto messages (#1840) (32f2d6a)

Bug Fixes

7.1.2 (2022-09-22)

Bug Fixes

7.1.1 (2022-09-09)

Bug Fixes

  • add import long to the generated .d.ts (#1802) (7c27b5a)
  • generate valid js code for aliased enum values (#1801) (7120e93)

7.1.0 (2022-08-26)

Features

Bug Fixes

7.0.0 (2022-07-08)

⚠ BREAKING CHANGES

  • drop support for Node 4, 6, 8, 10 (#1764)
  • move command line tool to a new package named protobufjs-cli (#1234)
  • encoding of empty Buffers (#1514)

Features

Bug Fixes

6.10.2 (2020-11-13)

Bug Fixes

6.10.1 (2020-07-16)

Bug Fixes

  • make node detection a bit more forgiving (#1445) (4e75f6d)

6.10.0 (2020-07-13)

Features

Bug Fixes

6.9.0 (2020-04-17)

Features

Bug Fixes

  • allow file-level options everywhere in the file (b70eebd)
  • Import Long types (1d98cb8)
  • npm audit fixes (ca52447)
  • properly iterate and return method descriptors (d96bb7a)
  • run npm audit fix (#1208) (b5b6632)
  • docs: update CHANGELOG to match format of release-please (#1376) (15ed8a0)

6.8.8

Fixed

:hash: Persist recent index.d.ts changes in JSDoc

6.8.7

Fixed

:hash: Fix package browser field descriptor (#1046)
:hash: Fix static codegen issues with uglifyjs3
:hash: Fix lint issues / pbts on windows
:hash: Fix empty 'bytes' field decoding, now using Buffer where applicable (#1020)
:hash: Fix circular dependency of Namespace and Enum (#994)
:hash: Ignore optional commas in aggregate options (#999)

New

:hash: Make Message<T> have a default type param (#1086)
:hash: Explicitly define service method names when generating static code, see #857
:hash: Also handle services in ext/descriptor (#1001)

CLI

:hash: Extend list of ignored ESLint rules for pbjs, fixes #1085
:hash: Fix declared return type of pbjs/pbts callback (#1025)
:hash: Added an option to pbts to allow custom imports (#1038)
:hash: Get node executable path from process.execPath (#1018)

Other

:hash: Slim down CI testing and remove some not ultimately necesssary dependencies with audit issues
:hash: Move global handling to util, see #995

6.8.6

Fixed

:hash: Fix typeRefRe being vulnerable to ReDoS

6.8.5

New

:hash: Preserve comments when serializing/deserializing with toJSON and fromJSON. (#983)
:hash: Add more details to some frequent error messages (#962)
:hash: Add IParseOptions#alternateCommentMode (#968)
:hash: Added field_mask to built-in common wrappers (#982)

Other

:hash: Remove code climate config in order to use 'in-app' config instead

6.8.4

Other

:hash: Update jsdoc dependency (pinned vulnerable marked)

6.8.3

CLI

:hash: Use correct safeProp in json-module target, see #956

6.8.2

Other

:hash: Include dist files in npm package, see #955

6.8.1

Fixed

:hash: Prevent invalid JSDoc names when generating service methods, see #870
:hash: Prevent parse errors when generating service method names, see #870
:hash: Support parsing nested option-values with or without ':' (#951, fixes #946)
:hash: Add support for reserved keyword in enums (#950, fixes #949)
:hash: Unified safe property escapes and added a test for #834
:hash: Fix codegen if type name starts with "Object"
:hash: Fixed dependency for json-module to use "light".
:hash: Basic support for URL prefixes in google.protobuf.Any types.
:hash: fixed 'error is not defined linter warning when using static/static-module and es6
:hash: Fixed wrong type_url for any type (no leading '.' allowed).
:hash: Fixed fromObject() for google.protobuf.Any types.
:hash: Handle case where 'extendee' is undefined in ext/descriptor

CLI

:hash: Sanitize CR-only line endings (coming from jsdoc?)
:hash: Make sure enum typings become generated (#884 didn't solve this)
:hash: Remove exclude and include patterns from jsdoc config
:hash: Skip defaults when generating proto3
:hash: Wait for both the 'end' and 'close' event to happen before finishing in pbts, see #863
:hash: Accept null for optional fields in generated static code
:hash: Annotate TS classes with @implements
:hash: Annotate virtual oneofs as string literal unions

New

:hash: Also check for reserved ids and names in enums
:hash: Also support 'reserved' in enum descriptors

Other

:hash: Include just relevant files in npm package, fixes #781
:hash: Fix travis build

6.8.0

Breaking

:hash: Replaced Buffer and Long types with interfaces and removed stubs
:hash: Removed Message#toObject in favor of having just the static version (unnecessary static code otherwise)
:hash: Everything uses interfaces now instead of typedefs (SomethingProperties is now ISomething)
:hash: ReflectionObject#toJSON properly omits explicit undefined values
:hash: Initial implementation of TypeScript decorators
:hash: Refactored protobuf.Class away
:hash: TypeScript definitions now have (a lot of) generics
:hash: Removed deprecated features

Fixed

:hash: Added 'undefined' besides 'null' as a valid value of an optional field, fixes #826
:hash: Fixed an issue with codegen typings, see #819
:hash: Ported utf8 chunking mechanism to base64 as well, fixes #800
:hash: Also be more verbose when defining properties for ES6, fixes #820
:hash: Generate more verbose JSDoc comments for ES6 support, fixes #820
:hash: Emit a maximum of one error var when generating verifiers, fixes #786
:hash: Fixed missing semicolon after 'extensions' and 'reserved' when generating proto files, fixes #810
:hash: Call npm with '--no-bin-links' when installing CLI deps, fixes #823
:hash: Fix Reader argument conversion in static module
:hash: Use JSDoc, they said, it documents code, they said. Fixes #770
:hash: parser should not confuse previous trailing line comments with comments for the next declaration, see #762
:hash: Types should not clear constructor with cache (fixes decorators)
:hash: Namespace#lookup should also check in nested namespaces (wtf)
:hash: Reader#bytes should also support plain arrays
:hash: Fix markdown for pipe in code in table

New

:hash: Upgrade to codegen 2
:hash: ext/descriptor enables interoperability between reflection and descriptor.proto (experimental), see #757
:hash: Added 'json' conversion option for proto3 JSON mapping compatibility of NaN and Infinity + additional documentation of util.toJSONOptions, see #351

CLI

:hash: Use protobuf/minimal when pbjs target is static-module
:hash: Added closure wrapper
:hash: Various improvements to statically generated JSDoc, also fixes #772
:hash: Check incompatible properties for namespaces only in tsd-jsdoc
:hash: Additional tsd-jsdoc handling of properties inside of namespaces and TS specific API exposure
:hash: Several improvements to tsd-jsdoc emitted comments
:hash: Further TypeScript definition improvements
:hash: Relieved tsd files from unnecessary comments
:hash: Generate TS namespaces for vars and functions with properties
:hash: Prefer @tstype over @type when generating typedefs (tsd-jsdoc)

Docs

:hash: Replaced nullable types with explicit type|null for better tooling compatibility, also fixes #766 and fixes 767
:hash: Added more info to ext/descriptor README, see #757
:hash: Additional notes on ext/descriptor
:hash: Updated CHANGELOG so everyone knows what's going on (and soon, breaking)
:hash: Additional docs on TS/decorators usage

Other

:hash: Updated dist files
:hash: Added package-lock.json
:hash: Minor formatting
:hash: Generate files
:hash: Remove the no-constructor arg
:hash: Remove the ctor option.
:hash: Add support to generate types for JSON object.
:hash: aspromise performance pass
:hash: codegen 2 performance pass, #653 might benefit
:hash: Fixed minimal library including reflection functionality
:hash: Minor compression ratio tuning
:hash: Fixed failing test case + coverage
:hash: Improved fromObject wrapper for google.protobuf.Any.
:hash: Fixed failing tokenize test case
:hash: Removed debug build, made it an extension
:hash: Regenerated dist files
:hash: Even more documentation and typings for ext/descriptor
:hash: ext/descriptor docs
:hash: Decorators coverage
:hash: ext/descriptor support for various standard options, see #757
:hash: ext/descriptor passes descriptor.proto test with no differences, see #757
:hash: Properly remove unnecessary (packed) options from JSON descriptors
:hash: Use typedefs in ext/descriptor (like everywhere else), see #757
:hash: Fixed obvious issues with ext/descriptor, does not throw anymore when throwing descriptor.proto itself at it, see #757
:hash: Added still missing root traversal to ext/descriptor, see #757
:hash: Initial map fields support for ext/descriptor, see #757
:hash: Added infrastructure for TypeScript support of extensions
:hash: TypeScript generics improvements
:hash: More ext/descriptor progress, see #757
:hash: Just export the relevant namespace in ext/descriptor
:hash: Initial descriptor.proto extension for reflection interoperability, see #757
:hash: Moved custom wrappers to its own module instead, also makes the API easier to use manually, see #677
:hash: Added infrastructure for custom wrapping/unwrapping of special types, see #677
:hash: More decorator progress (MapField.d, optional Type.d)
:hash: tsd-jsdoc now has limited generics support

6.7.3

Other

:hash: long, @types/long and @types/node are just dependencies, see #753

6.7.2

New

:hash: Split up NamespaceDescriptor to make nested plain namespaces a thing, see #749

Docs

:hash: More README
:hash: Replaced 'runtime message' with 'message instance' for clarity
:hash: Rephrased the Usage section around the concept of valid messages
:hash: Added toolset diagram to README

Other

:hash: Touched benchmark output metrics once more
:hash: Fixed failing browser test
:hash: Output more human friendly metrics from benchmark
:hash: Stripped down static bench code to what's necessary
:hash: Revamped benchmark, now also covers Google's JS implementation
:hash: Updated dependencies and dist files

6.7.1

New

:hash: Made .verify behave more like .encode, see #710

CLI

:hash: With null/undefined eliminated by constructors and .create, document message fields as non-optional where applicable (ideally used with TS & strictNullChecks), see #743
:hash: Renamed --strict-long/message to --force-long/message with backward compatible aliases, see #741
:hash: Keep $Properties with --strict-message but require actual instances within, see #741
:hash: Added --strict-message option to pbjs to strictly reference message instances instead of $Properties, see #741

Docs

:hash: Restructured README
:hash: Added more information on typings usage, see #744
:hash: Clarified typescript example in README, see #744
:hash: Clarified that the service API targets clients consuming a service, see #742

Other

:hash: Omit copying of undefined or null in constructors and .create, see #743

6.7.0

Breaking

:hash: Namespace#lookupEnum should actually look up the reflected enum and not just its values
:hash: Decoder now throws if required fields are missing, see #695 / #696

Fixed

:hash: Added functionality to filter for multiple types at once in lookup(), used by lookupTypeOrEnum(), fixes #740
:hash: Ensure that fields have been resolved when looking up js types in static target, see #731
:hash: Properly copy fields array before sorting in toObject, fixes #729
:hash: Actually emit TS compatible enums in static target if not aliases, see #720
:hash: Hardened tokenize/parse, esp. comment parsing, see #713
:hash: Exclude any fields part of some oneof when populating defaults in toObject, see #710
:hash: Most of the parser is not case insensitive, see #705
:hash: Retain options argument in Root#load when used with promises, see #684

New

:hash: Created a micromodule from (currently still bundled) float support
:hash: util.isset(obj, prop) can be used to test if a message property is considered to be set, see #728
:hash: Implemented stubs for long.js / node buffers to be used where either one isn't wanted, see #718
:hash: Simplified reusing / replacing internal constructors
:hash: Constructors/.create always initialize proper mutable objects/arrays, see #700
:hash: Verifiers return an error if multiple fields part of the same oneof are set, see #710
:hash: Added oneofs: true to ConversionOptions, see #710
:hash: Optional fields handle null just like undefined regardless of type see #709
:hash: Encoders no longer examine virtual oneof properties but encode whatever is present, see #710
:hash: pbjs now generates multiple exports when using ES6 syntax, see #686
:hash: Sequentially serialize fields ordered by id, as of the spec.
:hash: decode throws specific ProtocolError with a reference to the so far decoded message if required fields are missing + example
:hash: Reader.create asserts that buffer is a valid buffer, see #695

CLI

:hash: Exclude JSDoc on typedefs from generated d.ts files because typescript@next, see #737
:hash: Prepare static code with estraverse instead of regular expressions, see #732
:hash: Moved tsd-jsdoc to future cli package, see #716
:hash: $Properties are just a type that's satisfied, not implemented, by classes, see #723
:hash: More progress on decoupling the CLI
:hash: Fixed computed array indexes not being renamed in static code, see #726
:hash: Check upfront if key-var is required in static decoders with maps, see #726
:hash: Fixed handling of stdout if callback is specified, see #724
:hash: Preparations for moving the CLI to its own package, see #716
:hash: Properly implement $Properties interface in JSDoc, see #723
:hash: Recursively use $Properties inside of $Properties in static code, see #717
:hash: Added --strict-long option to pbjs to always emit 'Long' instead of 'number|Long' (only relevant with long.js), see #718
:hash: Statically emitted long type is 'Long' now instead of '$protobuf.Long', see #718
:hash: Decoupled message properties as an interface in static code for TS intellisense support, see #717
:hash: Static code statically resolves types[..], see #715

Docs

:hash: Added type definitions for all possible JSON descriptors
:hash: Explained the JSON structure in README and moved CLI specific information to the CLI package
:hash: Added information on how to use the stubs to README, see #718
:hash: Added 'What is a valid message' section to README
:hash: Added a hint on using .create to initial example
:hash: Even more usage for README
:hash: Additional information on general usage (README)
:hash: Restructured README to Installation, Usage and Examples sections
:hash: Added a longish section on the correct use of the toolset to README
:hash: Added a few additional notes on core methods to README, see #710
:hash: Extended traverse-types example, see #693
:hash: Better explain how .verify, .encode and .decode are connected
:hash: Documented that Type#encode respectively Message.encode do not implicitly .verify, see #696 [ci-skip]
:hash: Documented throwing behavior of Reader.create and Message.decode
:hash: Added error handling notes to README, see #696

Other

:hash: Use @protobufjs/float
:hash: Rebuilt dist files for 6.7.0
:hash: Updated deps, ts fixes and regenerated dist files
:hash: Manually merged gentests improvements, fixes #733
:hash: Make sure that util.Long is overridden by AMD loaders only if present, see #730
:hash: Coverage for util.isset and service as a namespace
:hash: Shortened !== undefined && !== null to equivalent != null in static code
:hash: With stubs in place, 'number|Long' return values can be just 'Long' instead, see #718
:hash: Just alias as the actual ideal type when using stubs, see #718
:hash: General cleanup + regenerated dist/test files
:hash: Simplified camel case regex, see #714
:hash: Regenerated dist files and changelog for 6.7.0
:hash: Retain alias order in static code for what it's worth, see #712
:hash: Everything can be block- or line-style when parsing, see #713
:hash: Determine necessary aliases depending on config, see #712
:hash: Use more precise types for message-like plain objects
:hash: Regenerated dist files
:hash: Regenerated relevant files
:hash: Moved field comparer to util
:hash: Updated tests to use new simplified encoder logic
:hash: Updated path to tsd-jsdoc template used by pbts, see #707
:hash: Additional restructuring for moving configuration files out of the root folder
:hash: Added codegen support for constructor functions, see #700
:hash: Attempted to fix broken custom error test
:hash: Trying out a more aggressive aproach for custom error subclasses
:hash: Moved a few things out of the root folder
:hash: Coverage for encoder compat. / protocolerror
:hash: Updated dist and generated test files
:hash: Added tslint
:hash: Exclude dist/ from codeclimate checks
:hash: Also lint cli utilities
:hash: Cache any regexp instance (perf)
:hash: Use code climate badges
:hash: Updated travis to pipe to codeclimate, coverage
:hash: More precise linter configuration
:hash: Added codeclimate
:hash: Moved cli deps placeholder creation to post install script

6.6.5

Fixed

:hash: sfixed64 is not zig-zag encoded, see #692

CLI

:hash: Added a placeholder to cli deps node_modules folder to make sure node can load from it

Other

:hash: Restructured a few failing tests
:hash: Traversal example + minimalistic documentation
:hash: Added a custom getters/setters example for gRPC

6.6.4

Fixed

:hash: Made sure that LongBits ctor is always called with unsigned 32 bits + static codegen compat., fixes #690
:hash: Properly handle multiple ../.. in path.normalize, see #688
:hash: Post-merge, also tackles #683 (packed option for repeated enum values)

New

:hash: Verify accepts non-null objects only, see #685
:hash: allow_alias enum option was not being honored. This case is now handled and a test case was added

CLI

:hash: Added an experimental --sparse option to limit pbjs output to actually referenced types within main files

Docs

:hash: Added explicit hint on Uint8Array to initial example, see #670

Other

:hash: Ranges and names support for reserved fields, see #676
:hash: Updated depdendencies / rebuilt dist files
:hash: Use ?: instead of |undefined in .d.ts files
:hash: Mark optional fields as possibly being undefined
:hash: Added a few more common google types from google/api, see #433
:hash: Minor optimizations to dependencies, build process and tsd

6.6.3

Fixed

:hash: Support node 4.2.0 to 4.4.7 buffers + travis case, see #665

CLI

:hash: Added ES6 syntax flag to pbjs, see #667

Docs

:hash: Reference Buffer for BufferReader/Writer, see #668
:hash: Slightly shortened README
:hash: Additional notes on the distinction of different use cases / distributions, see #666
:hash: Extended README with additional information on JSON format
:hash: Added extended usage instructions for TypeScript and custom classes to README, see #666

Other

:hash: Updated dist files
:hash: Updated test cases to use new buffer util
:hash: Added fetch test cases + some test cleanup

6.6.2

Fixed

:hash: Properly replace short vars when beautifying static code, see #663
:hash: Use custom prelude in order to exclude any module loader code from source (for webpack), see #658
:hash: Make sure to check optional inner messages for null when encoding, see #658

New

:hash: Initial attempt on a backwards compatible fetch implementation with binary support, see #661

Other

:hash: Root#resolvePath skips files when returning null, see #368
:hash: Changes callback on failed response decode in rpc service to pass actual error instead of 'error' string
:hash: Travis should exit with the respective error when running sauce tests
:hash: Moved checks whether a test case is applicable to parent case
:hash: Added eventemitter tests and updated micromodule dependencies (so far)
:hash: Added lib/path tests and updated a few dependencies
:hash: Moved micro modules to lib so they can have their own tests etc.
:hash: Updated travis

6.6.1

Fixed

:hash: Properly set up reflection when using light build

6.6.0 (release)

Breaking

:hash: Inlined / refactored away .testJSON, see #653
:hash: Refactored util.extend away
:hash: Reflected and statically generated services use common utility, now work exactly the same
:hash: fromObject now throws for entirely bogus values (repeated, map and inner message fields), fixes #601
:hash: Cleaned up library distributions, now is full / light / minimal with proper browserify support for each

Fixed

:hash: Do not randomly remove slashes from comments, fixes #656
:hash: Properly parse nested textformat options, also tackles #655

New

:hash: Relieved the requirement to call .resolveAll() on roots in order to populate static code-compatible properties, see #653
:hash: Added a (highly experimental) debug build as a starting point for #653
:hash: Full build depends on light build depends on minimal build, shares all relevant code

CLI

:hash: Also reuse specified root in pbjs for JSON modules, see #653
:hash: Reuse specified root name in pbjs to be able to split definitions over multiple files more easily, see #653

Docs

:hash: Improved pbjs/pbts examples, better covers reflection with definitions for static modules
:hash: Fixed centered formatting on npm

Other

:hash: Various other minor improvements / assertions refactored away, see #653
:hash: Fixed some common reflection deopt sites, see #653
:hash: Reflection performance pass, see #653
:hash: Added TS definitions to alternative builds' index files
:hash: Removed unnecessary prototype aliases, improves gzip ratio
:hash: Unified behaviour of and docs on Class constructor / Class.create
:hash: Statically generated services actually inherit from rpc.Service
:hash: Do not try to run sauce tests for PRs
:hash: Added utility to enable/disable debugging extensions to experimental debug build
:hash: Fixed node 0.12 tests
:hash: Fixed coverage
:hash: Added a test case for #652

6.5.3

Other

:hash: In fromObject, check if object is already a runtime message, see #652

6.5.2

Docs

:hash: Added coverage reporting

CLI

:hash: Added version scheme warning to everything CLI so that we don't need this overly explicit in README

Other

:hash: Coverage progress, 100%
:hash: Coverage progress
:hash: Attempted to fix badges once and for all
:hash: Coverage progress

6.5.1

CLI

:hash: Reuse module paths when looking up cli dependencies, see #648
:hash: Check actual module directories to determine if cli dependencies are present and bootstrap semver, see #648

Docs

:hash: Added a note on semver-incompatibility, see #649

Other

:hash: Coverage progress

6.5.0 (release)

Breaking

:hash: Initial upgrade of converters to real generated functions, see #620

Fixed

:hash: An enum's default value present as a string looks up using typeDefault, not defaultValue which is an array if repeated
:hash: Use common utility for virtual oneof getters and setters in both reflection and static code, see #644
:hash: Properly use Type.toObject/Message.toObject within converters, see #641
:hash: Generate null/undefined assertion in fromObject if actually NOT an enum, see #620
:hash: Replace ALL occurencies of types[%d].values in static code, see #641

New

:hash: Switched to own property-aware encoders for compatibility, see #639
:hash: Now also parses comments, sets them on reflected objects and re-uses them when generating static code, see #640

CLI

:hash: Further improved generated static code style
:hash: Removed scoping iifes from generated static code
:hash: Removed even more clutter from generated static code
:hash: Removed various clutter from generated static code
:hash: Made sure that static target's replacement regexes don't match fields
:hash: Also accept (trailing) triple-slash comments for compatibility with protoc-gen-doc, see #640
:hash: Use semver to validate that CLI dependencies actually satisfy the required version, see #637

Docs

:hash: Added a hint on documenting .proto files for static code
:hash: Documented internally used codegen partials for what it's worth
:hash: Updated converter documentation

Other

:hash: Bundler provides useful stuff to uglify and a global var without extra bloat
:hash: Cleaned and categorized tests, coverage progress
:hash: Properly removed builtins from bundle
:hash: Call hasOwnProperty builtin as late as possible decreasing the probability of having to call it at all (perf)
:hash: Slightly hardened codegen sprintf
:hash: Significantly improved uint32 write performance
:hash: Cleaned up test case data and removed unused files
:hash: Removed now useless trailing comment checks, see #640
:hash: Ensured that pbjs' beautify does not break regular expressions in generated verify functions

6.4.6

Fixed

:hash: Case-sensitively test for legacy group definitions, fixes #638
:hash: Properly parse text format options + simple test case, fixes #636

Docs

:hash: Added SVG logo, see #629

Other

:hash: Also refactored Service and Type to inherit from NamespaceBase, see #635
:hash: Moved TS-compatible Namespace features to a virtual NamespaceBase class, compiles with strictNullChecks by default now, see #635
:hash: Minor codegen enhancements

6.4.5

Fixed

:hash: Properly handle empty/noop Writer#ldelim, fixes #625
:hash: Properly annotate map fields in pbjs, fixes #624

New

:hash: Made sure that Writer#bytes is always able to handle plain arrays

Other

:hash: Slightly restructured utility to better support static code default values

6.4.4

Fixed

:hash: Dynamically resolve jsdoc when running pbts, fixes #622

Docs

:hash: Explain 6.4.2 vs 6.4.3 in changelog

6.4.3

Fixed

:hash: Fixed invalid definition of Field#packed property, also introduced decoder.compat mode (packed fields, on by default)
:hash: Always decode packed/non-packed based on wire format only, see #602
:hash: Use full library for JSON modules and runtime dependency for static modules, fixes #621

CLI

:hash: Additional workarounds for on demand CLI dependencies, see #618
:hash: Revised automatic setup of cli dependencies, see #618

Other

:hash: Removed Android 4.0 test (no longer supported by sauce)
:hash: Removed some unused utility, slightly more efficient codegen, additional comments
:hash: Updated tests for new package.json layout
:hash: Added break/continue label support to codegen
:hash: Updated dependencies, rebuilt dist files and changed logo to use an absolute url

6.4.2 had been accidentally published as 6.4.3.

6.4.1

Fixed

:hash: Added more default value checks to converter, fixes #616
:hash: Respect long defaults in converters
:hash: Convert inner messages and undefined/null values more thoroughly, fixes #615
:hash: Always use first defined enum value as field default, fixes #613
:hash: Install correct 'tmp' dependency when running pbts without dev dependencies installed, fixes #612

New

:hash: Generate named constructors for runtime messages, see #588

CLI

:hash: pbjs/pbts no longer generate any volatile headers, see #614

Docs

:hash: Attempted to make broken shields less annoying
:hash: Updated README

Other

:hash: Some cleanup and added a logo
:hash: use $protobuf.Long

6.4.0 (release)

Breaking

:hash: Dropped IE8 support
:hash: Removed now unused util.longNeq which was used by early static code

Fixed

:hash: Do not swallow errors in loadSync, also accept negative enum values in Enum#add, fixes #609
:hash: Improved bytes field support, also fixes #606
:hash: Fall back to browser Reader when passing an Uint8Array under node, fixes #605
:hash: Respect optional properties when writing interfaces in tsd-jsdoc, fixes #598

New

:hash: Instead of protobuf.parse.keepCase, fall back to protobuf.parse.defaults holding all possible defaults, see #608
:hash: Added global ParseOptions#keepCase fallback as protobuf.parse.keepCase, see #608
:hash: Converters use code generation and support custom implementations
:hash: Be more verbose when throwing invalid wire type errors, see #602
:hash: Added an asJSON-option to always populate array fields, even if defaults=false, see #597
:hash: Attempt to improve TypeScript support by using explicit exports
:hash: Copy-pasted typescript definitions to micro modules, see #599
:hash: Emit an error on resolveAll() if any extension fields cannot be resolved, see #595 + test case

CLI

:hash: Removed 'not recommend' label for --keep-case, see #608
:hash: Added customizable linter configuration to pbjs
:hash: Added stdin support to pbjs and pbts
:hash: Static code no longer uses IE8 support utility
:hash: Generated static code now supports asJSON/from
:hash: Added support for TypeScript enums to pbts
:hash: Added a few helpful comments to static code
:hash: Slightly beautify statically generated code
:hash: Do not wrap main definition as a module and export directly instead
:hash: Generate prettier definitions with --no-comments
:hash: Added variable arguments support to tsd-jsdoc
:hash: Reference dependency imports as a module to prevent name collisions, see #596
:hash: Removed now unnecessary comment lines in generated static code

Docs

:hash: Added notes on CSP-restricted environments to README, see #593

Other

:hash: Added test case for asJSON with arrays=true, see #597
:hash: Added a tape adapter to assert message equality accross browsers
:hash: Refactored some internal utility away
:hash: Reverted previous attempt on #597
:hash: Minor tsd-jsdoc refactor
:hash: Removed unused sandbox files
:hash: Updated package.json of micro modules to reference types, see #599
:hash: Reference dependencies as imports in generated typescript definitions, see #596
:hash: Allow null values on optional long fields, see #590
:hash: Various jsdoc improvements and a workaround for d.ts generation, see #592

6.3.1

Fixed

:hash: Empty inner messages are always present on the wire + test case + removed now unused Writer#ldelim parameter, see #585

CLI

:hash: Expose tsd-jsdoc's comments option to pbts as --no-comments, see #587
:hash: Increase child process max buffer when running jsdoc from pbts, see #587
:hash: pbjs now generates more convenient dot-notation property accessors

Other

:hash: And fixed IE8 again (should probably just drop IE8 for good)

6.3.0

Breaking

:hash: Moved camelCase/underScore away from util to where actually used
:hash: Renamed asJSON option keys (enum to enums, long to longs) because enum is a reserved keyword
:hash: Moved JSON/Message conversion to its own source file and added Message/Type.from + test case, see #575
:hash: Relicensed the library and its components to BSD-3-Clause to match the official implementation (again)
:hash: Dropped support for browser buffer entirely (is an Uint8Array anyway), ensures performance and makes things simpler
:hash: Removed dead parts of the Reader API
:hash: Refactored BufferReader/Writer to their own files and removed unnecessary operations (node always has FloatXXArray and browser buffer uses ieee anyway)
:hash: Stripped out fallback encoder/decoder/verifier completely (even IE8 supports codegen), significantly reduces bundle size, can use static codegen elsewhere

Fixed

:hash: Actually concatenate mixed custom options when parsing
:hash: Fixed a couple of issues with alternative browser builds
:hash: Properly set long defaults on prototypes
:hash: Fixed reference error in minimal runtime, see #580
:hash: Non-repeated empty messages are always present on the wire, see #581
:hash: Properly check Buffer.prototype.set with node v4
:hash: Prevent NRE and properly annotate verify signature in tsd-jsdoc, fixed #572
:hash: Fix directly using Buffer instead of util.Buffer
:hash: Added filter type to Namespace#lookup, fixes #569
:hash: Fixed parsing enum inner options, see #565
:hash: Fixed release links in README files

New

:hash: Added a noparse build for completeness
:hash: Now compresses .gz files using zopfli to make them useful beyond being just a reference
:hash: Updated non-bundled google types folder with missing descriptors and added wrappers to core
:hash: Replaced the ieee754 implementation for old browsers with a faster, use-case specific one + simple test case
:hash: Added .create to statically generated types and uppercase nested elements to reflection namespaces, see #576
:hash: Also added Namespace#getEnum for completeness, see #576
:hash: Added Namespace#getEnum and changed #lookupEnum to the same behavior, see #576
:hash: Added a heap of coverage comments for usually unused code paths to open things up
:hash: Added codegen test to determine if any ancient browsers don't actually support it
:hash: Added legacy groups support to pbjs, see #568
:hash: Initial support for legacy groups + test case, see #568
:hash: Added asJSON bytes as Buffer, see #566

CLI

:hash: Annotated callback types in pbjs-generated services, see #582
:hash: Removed type/ns alias comment in static target to not confuse jsdoc unnecessarily
:hash: Made pbjs use loadSync for deterministic outputs, see #573

Docs

:hash: Updated documentation on runtime and noparse builds
:hash: Fixed an issue with the changelog generator skipping some commits
:hash: Added notes on how to use pbjs and pbts programmatically
:hash: Manually sorted old changelog entries
:hash: Initial changelog generator, see #574
:hash: Added static/JSON module interchangeability to README
:hash: Updated README and bundler according to dynamic require calls

Other

:hash: Added basic services test case
:hash: Just polyfill Buffer.from / .allocUnsafe for good
:hash: Added a test case to find out if all the fallbacks are just for IE8
:hash: Commented out float assertions in float test including explanation
:hash: Expose array implementation used with (older) browsers on util for tests
:hash: Updated test cases
:hash: Added assumptions to float test case
:hash: Updated travis config to use C++11
:hash: Updated / added additional LICENSE files where appropriate
:hash: Integrated changelog into build process, now also has 'npm run make' for everything, see #574
:hash: Minor optimizations through providing type-hints
:hash: Reverted shortened switch statements in verifier
:hash: Enums can't be map key types
:hash: Use custom require (now a micromodule) for all optional modules, see #571
:hash: Support usage when size = 0
:hash: Reverted aliases frequently used in codegen for better gzip ratio
:hash: Shrinked bundle size - a bit
:hash: Can finally run with --trace-deopt again without crashes
:hash: Other minor optimizations

6.2.1

New

:hash: Added ParseOptions to protobuf.parse and --keep-case for .proto sources to pbjs, see #564

Other

:hash: Better TypeScript definition support for @property-annotated objects
:hash: Can't just inline longNeq but can be simplified
:hash: Array abuse and varint optimization
:hash: Updated dependencies
:hash: Other minor improvements to short ifs
:hash: Reader/Writer example

6.2.0

Fixed

:hash: Fixed reserved names re, also ensure valid service method names, see #559
:hash: Fix d.ts whitespace on empty lines, added tsd-jsdoc LICENSE
:hash: Fix asJSON defaults option, make it work for repeated fields.
:hash: Inlined any Reader/Writer#tag calls, also fixes #556
:hash: Fix building default dist files with explicit runtime=false
:hash: Apply asJSON recursively
:hash: Ensure working reflection class names with minified builds
:hash: Lazily resolve (some) cyclic dependencies, see #560

New

:hash: Added protobuf.roots to minimal runtime, see #554
:hash: Repo now includes a restructured version of tsd-jsdoc with our changes incorporated for issues/prs, see #550

CLI

:hash: Updated pbjs arguments
:hash: Pipe tsd-jsdoc output (requires dcodeIO/tsd-jsdoc/master) and respect cwd, see #550
:hash: tsd-jsdoc progress

Docs

:hash: README

Other

:hash: Added GH issue template
:hash: Path micromodule, dependencies
:hash: Test case for #556
:hash: Raw alloc benchmark
:hash: Other minor optimizations

6.1.1

Fixed

:hash: Properly encode/decode map kv pairs as repeated messages (codegen and fallback), see #547
:hash: Make genVerifyKey actually generate conditions for 32bit values and bool, fixes #546
:hash: Fix to generation of verify methods for bytes
:hash: Take special care of oneofs when encoding (i.e. when explicitly set to defaults), see #542

New

:hash: Added Message#asJSON option for bytes conversion
:hash: Added Namespace#lookupType and Namespace#lookupService (throw instead of returning null), see #544
:hash: Provide prebuilt browser versions of the static runtime

CLI

:hash: Initial pbts CLI for generating TypeScript definitions, see #550
:hash: Refactored json/static-module targets to use common wrappers
:hash: Refactor cli to support multiple built-in wrappers, added named roots instead of always using global.root and added additionally necessary eslint comments, see #540
:hash: Annotate namespaces generated by static target, see #550
:hash: static target: Basic support for oneof fields, see #542

Docs

:hash: Fix to reflection documentation
:hash: README on minimal runtime / available downloads
:hash: Notes on descriptors vs static modules

Other

:hash: A lot of minor optimizations to performance and gzip ratio
:hash: Minimized base64 tables

6.1.0

Breaking

:hash: Removed as-function overload for Reader/Writer, profiler stub, optimized version of Reader#int32
:hash: Refactored Prototype and inherits away, is now Class and Message for more intuitive documentation and type refs

Fixed

:hash: Fixed failing test case on node < 6
:hash: Fixed serialization order of sfixed64, fixes #536
:hash: Fixed serialization order of fixed64, fallback to parseInt with no long lib, see #534
:hash: Actually allow undefined as service method type, fixes #528
:hash: Do not skip optional delimiter after aggregate options, fixes #520
:hash: Verify empty base64 encoded strings for bytes fields, see #535
:hash: wrong spell role should be rule
:hash: decodeDelimited always forks if writer is specified, see #531
:hash: Mimic spec-compliant behaviour in oneof getVirtual, see #523

New

:hash: Initial base64 string support for bytes fields, see #535
:hash: Initial type-checking verifier, see #526, added to bench out of competition
:hash: Initial loadSync (node only), see #529
:hash: Initial RPC service implementaion, see #529
:hash: added 'defaults' option to Prototype#asJSON, see #521
:hash: Use Uint8Array pool in browsers, just like node does with buffers
:hash: Also validate map fields, see #526 (this really needs some tests)

CLI

:hash: Added json-module target to pbjs, renamed static to static-module, see #522
:hash: updated internals and static target to use immutable objects on prototypes

Docs

:hash: Added a couple of alternative signatures, protobuf.load returns promise or undefined, aliased Reader/Writer-as-function signature with Reader/Writer.create for typed dialects, see #518
:hash: Added variations for Root#load, see #527
:hash: Added benchmark and profile related information to README
:hash: Added service example to README, see #529
:hash: README on tests
:hash: Update README/dist to reflect recent changes
:hash: Minimal documentation for micromodules
:hash: Document all the callbacks, see #527
:hash: Documented streaming-rpc example a bit

Other

:hash: Removed the need for triple-slash references in .d.ts by providing a minimal Long interface, see #527, see #530
:hash: Transition to micromodules
:hash: Refactored argument order of utf8 for plausibility
:hash: Restructured reusable micromodules
:hash: Can't use Uint8Array#set on node < 6 buffers
:hash: Test case for #531
:hash: Safer signaling for synchronous load, see #529
:hash: Proper end of stream signaling to rpcImpl, see #529
:hash: Moved event emitter to util, also accepts listener context, see #529
:hash: Probably the worst form of hiding require programmatically, see #527
:hash: Attempt to hide require('fs') from webpack, see #527
:hash: Trying out jsdoc variations, see #527
:hash: by the way, why not include the json->proto functionality into "util"?
:hash: Update proto.js
:hash: Automatic profile generation and processing
:hash: Generalized buffer pool and moved it to util
:hash: Make shields visible on npm, yey
:hash: More shields, I love shields, and maybe a workaround for travis timing out when sauce takes forever
:hash: Trying SauceLabs with higher concurrency

6.0.2

Fixed

:hash: Fix packable float/double see #513

New

:hash: Handle oneofs in prototype ctor, add non-ES5 fallbacks, test case
:hash: Be nice to AMD, allow reconfiguration of Reader/Writer interface

CLI

:hash: Initial static codegen target for reference
:hash: pbjs static target services support
:hash: pbjs static target progress, uses customizable wrapper template
:hash: Static pbjs target progress, now generates usable CommonJS code, see #512

Docs

:hash: TypeScript example
:hash: Adjectives, notes on browserify

Other

:hash: Refactor runtime util into separate file, reader/writer uses runtime util
:hash: Also optimize reader with what we have learned
:hash: More (shameless) writer over-optimization
:hash: Trading package size for float speed
:hash: Skip defining getters and setters on IE8 entirely, automate defining fallbacks
:hash: Unified proto/reflection/classes/static encoding API to always return a writer
:hash: plain js utf8 is faster for short strings
:hash: improve TypeScript support. add simple test script.
:hash: Use long.js dependency in tests, reference types instead of paths in .d.ts see #503
:hash: Restructured encoder / decoder to better support static code gen

6.0.1

Fixed

:hash: Add support for long strings, fixes #509
:hash: expose zero on LongBits, fixes #508
:hash: Fixed issues with Root.fromJSON/#addJSON, search global for Long
:hash: Properly exclude browserify's annoying _process, again, fixes #502
:hash: Remember loaded files earlier to prevent race conditions, fixes #501
:hash: Allow negative enum ids even if super inefficient (encodes as 10 bytes), fixes #499, fixes #500
:hash: set resolvedResponseType on resolve(), fixes #497

New

:hash: Initial take on runtime services, see #507
:hash: Include dist/ in npm package for frontend use

CLI

:hash: pbjs proto target field options, language-level compliance with jspb test.proto

Docs

:hash: always use Uint8Array in docs for tsd, see #503
:hash: Notes on dist files

Other

:hash: Update eslint env
:hash: Browser field in package.json isn't required