No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.esm2017.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import firebase from '@firebase/app-compat';
  2. import { httpsCallable, httpsCallableFromURL, connectFunctionsEmulator } from '@firebase/functions';
  3. import { FirebaseError } from '@firebase/util';
  4. import { Component } from '@firebase/component';
  5. const name = "@firebase/functions-compat";
  6. const version = "0.3.1";
  7. /**
  8. * @license
  9. * Copyright 2020 Google LLC
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. */
  23. class FunctionsService {
  24. constructor(app, _delegate) {
  25. this.app = app;
  26. this._delegate = _delegate;
  27. this._region = this._delegate.region;
  28. this._customDomain = this._delegate.customDomain;
  29. }
  30. httpsCallable(name, options) {
  31. return httpsCallable(this._delegate, name, options);
  32. }
  33. httpsCallableFromURL(url, options) {
  34. return httpsCallableFromURL(this._delegate, url, options);
  35. }
  36. /**
  37. * Deprecated in pre-modularized repo, does not exist in modularized
  38. * functions package, need to convert to "host" and "port" args that
  39. * `useFunctionsEmulatorExp` takes.
  40. * @deprecated
  41. */
  42. useFunctionsEmulator(origin) {
  43. const match = origin.match('[a-zA-Z]+://([a-zA-Z0-9.-]+)(?::([0-9]+))?');
  44. if (match == null) {
  45. throw new FirebaseError('functions', 'No origin provided to useFunctionsEmulator()');
  46. }
  47. if (match[2] == null) {
  48. throw new FirebaseError('functions', 'Port missing in origin provided to useFunctionsEmulator()');
  49. }
  50. return connectFunctionsEmulator(this._delegate, match[1], Number(match[2]));
  51. }
  52. useEmulator(host, port) {
  53. return connectFunctionsEmulator(this._delegate, host, port);
  54. }
  55. }
  56. /**
  57. * @license
  58. * Copyright 2020 Google LLC
  59. *
  60. * Licensed under the Apache License, Version 2.0 (the "License");
  61. * you may not use this file except in compliance with the License.
  62. * You may obtain a copy of the License at
  63. *
  64. * http://www.apache.org/licenses/LICENSE-2.0
  65. *
  66. * Unless required by applicable law or agreed to in writing, software
  67. * distributed under the License is distributed on an "AS IS" BASIS,
  68. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  69. * See the License for the specific language governing permissions and
  70. * limitations under the License.
  71. */
  72. const DEFAULT_REGION = 'us-central1';
  73. const factory = (container, { instanceIdentifier: regionOrCustomDomain }) => {
  74. // Dependencies
  75. const app = container.getProvider('app-compat').getImmediate();
  76. const functionsServiceExp = container.getProvider('functions').getImmediate({
  77. identifier: regionOrCustomDomain !== null && regionOrCustomDomain !== void 0 ? regionOrCustomDomain : DEFAULT_REGION
  78. });
  79. return new FunctionsService(app, functionsServiceExp);
  80. };
  81. function registerFunctions() {
  82. const namespaceExports = {
  83. Functions: FunctionsService
  84. };
  85. firebase.INTERNAL.registerComponent(new Component('functions-compat', factory, "PUBLIC" /* ComponentType.PUBLIC */)
  86. .setServiceProps(namespaceExports)
  87. .setMultipleInstances(true));
  88. }
  89. /**
  90. * @license
  91. * Copyright 2020 Google LLC
  92. *
  93. * Licensed under the Apache License, Version 2.0 (the "License");
  94. * you may not use this file except in compliance with the License.
  95. * You may obtain a copy of the License at
  96. *
  97. * http://www.apache.org/licenses/LICENSE-2.0
  98. *
  99. * Unless required by applicable law or agreed to in writing, software
  100. * distributed under the License is distributed on an "AS IS" BASIS,
  101. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  102. * See the License for the specific language governing permissions and
  103. * limitations under the License.
  104. */
  105. registerFunctions();
  106. firebase.registerVersion(name, version);
  107. //# sourceMappingURL=index.esm2017.js.map