From c0245c54d8c45f1f3171e9066bc7bab3c4162b69 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 23 Nov 2020 12:40:15 -0800 Subject: [PATCH] fix(browser): check for fetch on window --- .../speech_translation_service_client.ts | 18 +++++++++++++----- synth.metadata | 14 ++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/v1beta1/speech_translation_service_client.ts b/src/v1beta1/speech_translation_service_client.ts index 7aa8e06..7f04f67 100644 --- a/src/v1beta1/speech_translation_service_client.ts +++ b/src/v1beta1/speech_translation_service_client.ts @@ -16,11 +16,17 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +/* global window */ import * as gax from 'google-gax'; import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; import * as path from 'path'; import * as protos from '../../protos/protos'; +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/speech_translation_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ import * as gapicConfig from './speech_translation_service_client_config.json'; const version = require('../../../package.json').version; @@ -73,9 +79,9 @@ export class SpeechTranslationServiceClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. - * TODO(@alexander-fenster): link to gax documentation. - * @param {boolean} fallback - Use HTTP fallback mode. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. * In fallback mode, a special browser-compatible transport implementation is used * instead of gRPC transport. In browser context (if the `window` object is defined) * the fallback mode is enabled automatically; set `options.fallback` to `false` @@ -89,7 +95,9 @@ export class SpeechTranslationServiceClient { opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? typeof window !== 'undefined'; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. @@ -301,7 +309,7 @@ export class SpeechTranslationServiceClient { * stream.write(request); * stream.end(); */ - streamingTranslateSpeech(options?: gax.CallOptions): gax.CancellableStream { + streamingTranslateSpeech(options?: CallOptions): gax.CancellableStream { this.initialize(); return this.innerApiCalls.streamingTranslateSpeech(options); } diff --git a/synth.metadata b/synth.metadata index 32f3a76..e5578dc 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,8 +3,16 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/nodejs-media-translation.git", - "sha": "f132c7b2725509ef3d4d497733ba85f851b52789" + "remote": "https://github.com/googleapis/nodejs-media-translation.git", + "sha": "f58a09e23452b1407079078809d079b2c31775f4" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "2f019bf70bfe06f1e2af1b04011b0a2405190e43", + "internalRef": "343202295" } }, { @@ -78,14 +86,12 @@ "LICENSE", "README.md", "api-extractor.json", - "package-lock.json.3635725974", "protos/google/cloud/mediatranslation/v1beta1/media_translation.proto", "protos/protos.d.ts", "protos/protos.js", "protos/protos.json", "renovate.json", "samples/README.md", - "samples/package-lock.json.3114264012", "src/index.ts", "src/v1beta1/index.ts", "src/v1beta1/speech_translation_service_client.ts",