ts-proto 2.2.4 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -169,7 +169,10 @@ function getExtensionValue(ctx, extension, data) {
169
169
  return Buffer.from(bytes);
170
170
  }));
171
171
  const result = resultBuffer.toString("base64");
172
- return (0, ts_poet_1.code) `'${extension.name}': ${typeName}.decode(Buffer.from('${result}', 'base64'))`;
172
+ const encoded = ctx.options.env === options_1.EnvOption.NODE
173
+ ? (0, ts_poet_1.code) `Buffer.from('${result}', 'base64')`
174
+ : (0, ts_poet_1.code) `${ctx.utils.bytesFromBase64}("${result}")`;
175
+ return (0, ts_poet_1.code) `'${extension.name}': ${typeName}.decode(${encoded})`;
173
176
  }
174
177
  else {
175
178
  const reader = new wire_1.BinaryReader(data[0]);
@@ -188,8 +191,8 @@ function encodedOptionsToOptions(ctx, extendee, encodedOptions) {
188
191
  const resultOptions = [];
189
192
  for (const key in encodedOptions) {
190
193
  const value = encodedOptions[key];
191
- const extension = extensionCache[extendee][parseInt(key, 10) >>> 3];
192
- if (shouldAddOptionDefinition(ctx, extension)) {
194
+ const extension = extensionCache[extendee]?.[parseInt(key, 10) >>> 3];
195
+ if (extension && shouldAddOptionDefinition(ctx, extension)) {
193
196
  // todo: we should be able to create an option definition ALWAYS, however,
194
197
  // we currently cannot do that because the if the extension is a sub-message
195
198
  // (and thus, not just a straightforward value), we don't have an JSON object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "",
5
5
  "main": "build/src/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",