grpc-dc 0.32.11 → 0.32.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grpc-dc",
3
- "version": "0.32.11",
3
+ "version": "0.32.12",
4
4
  "description": "gRPC in the browser over WebRTC DataChannels: dependency-free generated gRPC clients & servers for JavaScript — no grpc-web proxy, no external runtime",
5
5
  "keywords": [
6
6
  "grpc",
@@ -3959,6 +3959,12 @@ function jpExplicitLiteral(model, f) {
3959
3959
  }
3960
3960
  }
3961
3961
 
3962
+ function jpBoxedDefault(model, f) {
3963
+ if (f.type === 1) return '0.0';
3964
+ if (f.type === 2) return '0.0f';
3965
+ return jpDefault(model, f);
3966
+ }
3967
+
3962
3968
  function jpDefault(model, f) {
3963
3969
  const lit = jpExplicitLiteral(model, f);
3964
3970
  if (lit !== null) return lit;
@@ -4194,8 +4200,8 @@ function jpMapHelpers(model, entry, support) {
4194
4200
  + jpEncodeSingular(model, { ...valF, label: 1 }, 'value', ' ', support)
4195
4201
  + ' return w.toBytes();\n }\n\n'
4196
4202
  + ' static Object[] ' + base + 'Decode(byte[] bytes) {\n'
4197
- + ' ' + kt + ' key = ' + jpDefault(model, { ...keyF, label: 1 }) + ';\n'
4198
- + ' ' + vt + ' value = ' + jpDefault(model, { ...valF, label: 1 }) + ';\n'
4203
+ + ' ' + kt + ' key = ' + jpBoxedDefault(model, { ...keyF, label: 1 }) + ';\n'
4204
+ + ' ' + vt + ' value = ' + jpBoxedDefault(model, { ...valF, label: 1 }) + ';\n'
4199
4205
  + ' Reader r = new Reader(bytes);\n Field field;\n while ((field = r.next()) != null) {\n switch (field.number) {\n'
4200
4206
  + ' case ' + keyF.number + ': ' + jpDecodeSingularStmt(model, { ...keyF, label: 1 }, 'key') + ' break;\n'
4201
4207
  + ' case ' + valF.number + ': ' + jpDecodeSingularStmt(model, { ...valF, label: 1 }, 'value') + ' break;\n'
@@ -4377,6 +4383,22 @@ function emitJavaPbFiles(model) {
4377
4383
  return files;
4378
4384
  }
4379
4385
 
4386
+ function javaQualifyType(pkg, simple, full) {
4387
+ if (!full || !pkg || full.startsWith(pkg + '.')) return simple;
4388
+ return full.split('.').slice(0, -1).join('.') + '.' + simple;
4389
+ }
4390
+
4391
+ function javaQualifyServices(pkg, services) {
4392
+ return services.map((svc) => ({
4393
+ ...svc,
4394
+ methods: svc.methods.map((m) => ({
4395
+ ...m,
4396
+ input: javaQualifyType(pkg, m.input, m.inputFull),
4397
+ output: javaQualifyType(pkg, m.output, m.outputFull),
4398
+ })),
4399
+ }));
4400
+ }
4401
+
4380
4402
  function emitJavaFile(model, params) {
4381
4403
  const base = baseName(model.name);
4382
4404
  const className = pascalName(base) + 'GrpcDc';
@@ -4391,7 +4413,7 @@ function emitJavaFile(model, params) {
4391
4413
  + 'import java.util.concurrent.CompletableFuture;\nimport java.util.concurrent.CompletionException;\n\n'
4392
4414
  + '/** Generated gRPC-over-DataChannels stubs for ' + model.name + '. */\n'
4393
4415
  + 'public final class ' + className + ' {\n private ' + className + '() {}\n\n'
4394
- + model.services.map(javaService).join('')
4416
+ + javaQualifyServices(pkg, model.services).map(javaService).join('')
4395
4417
  + '}\n',
4396
4418
  };
4397
4419
  const pbFiles = emitJavaPbFiles(model);