index.cjs.js 4.5 KB

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