GSI - Employe Self Service Mobile
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.

360 lines
14 KiB

2 months ago
  1. import * as modularAPIs from '@firebase/app';
  2. import { deleteApp, _addComponent, _DEFAULT_ENTRY_NAME, registerVersion } from '@firebase/app';
  3. import { Component } from '@firebase/component';
  4. import { ErrorFactory, contains, deepExtend } from '@firebase/util';
  5. /**
  6. * @license
  7. * Copyright 2019 Google LLC
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. */
  21. /**
  22. * Global context object for a collection of services using
  23. * a shared authentication state.
  24. */
  25. var FirebaseAppLiteImpl = /** @class */ (function () {
  26. function FirebaseAppLiteImpl(_delegate, firebase) {
  27. var _this = this;
  28. this._delegate = _delegate;
  29. this.firebase = firebase;
  30. // add itself to container
  31. _addComponent(_delegate, new Component('app-compat', function () { return _this; }, "PUBLIC" /* ComponentType.PUBLIC */));
  32. }
  33. Object.defineProperty(FirebaseAppLiteImpl.prototype, "automaticDataCollectionEnabled", {
  34. get: function () {
  35. return this._delegate.automaticDataCollectionEnabled;
  36. },
  37. set: function (val) {
  38. this.automaticDataCollectionEnabled = val;
  39. },
  40. enumerable: false,
  41. configurable: true
  42. });
  43. Object.defineProperty(FirebaseAppLiteImpl.prototype, "name", {
  44. get: function () {
  45. return this._delegate.name;
  46. },
  47. enumerable: false,
  48. configurable: true
  49. });
  50. Object.defineProperty(FirebaseAppLiteImpl.prototype, "options", {
  51. get: function () {
  52. return this._delegate.options;
  53. },
  54. enumerable: false,
  55. configurable: true
  56. });
  57. FirebaseAppLiteImpl.prototype.delete = function () {
  58. this.firebase.INTERNAL.removeApp(this.name);
  59. return deleteApp(this._delegate);
  60. };
  61. /**
  62. * Return a service instance associated with this app (creating it
  63. * on demand), identified by the passed instanceIdentifier.
  64. *
  65. * NOTE: Currently storage is the only one that is leveraging this
  66. * functionality. They invoke it by calling:
  67. *
  68. * ```javascript
  69. * firebase.app().storage('STORAGE BUCKET ID')
  70. * ```
  71. *
  72. * The service name is passed to this already
  73. * @internal
  74. */
  75. FirebaseAppLiteImpl.prototype._getService = function (name, instanceIdentifier) {
  76. if (instanceIdentifier === void 0) { instanceIdentifier = _DEFAULT_ENTRY_NAME; }
  77. this._delegate.checkDestroyed();
  78. // getImmediate will always succeed because _getService is only called for registered components.
  79. return this._delegate.container.getProvider(name).getImmediate({
  80. identifier: instanceIdentifier
  81. });
  82. };
  83. return FirebaseAppLiteImpl;
  84. }());
  85. /**
  86. * @license
  87. * Copyright 2019 Google LLC
  88. *
  89. * Licensed under the Apache License, Version 2.0 (the "License");
  90. * you may not use this file except in compliance with the License.
  91. * You may obtain a copy of the License at
  92. *
  93. * http://www.apache.org/licenses/LICENSE-2.0
  94. *
  95. * Unless required by applicable law or agreed to in writing, software
  96. * distributed under the License is distributed on an "AS IS" BASIS,
  97. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  98. * See the License for the specific language governing permissions and
  99. * limitations under the License.
  100. */
  101. var _a;
  102. var ERRORS = (_a = {},
  103. _a["no-app" /* AppError.NO_APP */] = "No Firebase App '{$appName}' has been created - " +
  104. 'call Firebase App.initializeApp()',
  105. _a["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */] = 'firebase.{$appName}() takes either no argument or a ' +
  106. 'Firebase App instance.',
  107. _a);
  108. var ERROR_FACTORY = new ErrorFactory('app-compat', 'Firebase', ERRORS);
  109. /**
  110. * @license
  111. * Copyright 2019 Google LLC
  112. *
  113. * Licensed under the Apache License, Version 2.0 (the "License");
  114. * you may not use this file except in compliance with the License.
  115. * You may obtain a copy of the License at
  116. *
  117. * http://www.apache.org/licenses/LICENSE-2.0
  118. *
  119. * Unless required by applicable law or agreed to in writing, software
  120. * distributed under the License is distributed on an "AS IS" BASIS,
  121. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  122. * See the License for the specific language governing permissions and
  123. * limitations under the License.
  124. */
  125. /**
  126. * Because auth can't share code with other components, we attach the utility functions
  127. * in an internal namespace to share code.
  128. * This function return a firebase namespace object without
  129. * any utility functions, so it can be shared between the regular firebaseNamespace and
  130. * the lite version.
  131. */
  132. function createFirebaseNamespaceCore(firebaseAppImpl) {
  133. var apps = {};
  134. // // eslint-disable-next-line @typescript-eslint/no-explicit-any
  135. // const components = new Map<string, Component<any>>();
  136. // A namespace is a plain JavaScript Object.
  137. var namespace = {
  138. // Hack to prevent Babel from modifying the object returned
  139. // as the firebase namespace.
  140. // @ts-ignore
  141. __esModule: true,
  142. initializeApp: initializeAppCompat,
  143. // @ts-ignore
  144. app: app,
  145. registerVersion: modularAPIs.registerVersion,
  146. setLogLevel: modularAPIs.setLogLevel,
  147. onLog: modularAPIs.onLog,
  148. // @ts-ignore
  149. apps: null,
  150. SDK_VERSION: modularAPIs.SDK_VERSION,
  151. INTERNAL: {
  152. registerComponent: registerComponentCompat,
  153. removeApp: removeApp,
  154. useAsService: useAsService,
  155. modularAPIs: modularAPIs
  156. }
  157. };
  158. // Inject a circular default export to allow Babel users who were previously
  159. // using:
  160. //
  161. // import firebase from 'firebase';
  162. // which becomes: var firebase = require('firebase').default;
  163. //
  164. // instead of
  165. //
  166. // import * as firebase from 'firebase';
  167. // which becomes: var firebase = require('firebase');
  168. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  169. namespace['default'] = namespace;
  170. // firebase.apps is a read-only getter.
  171. Object.defineProperty(namespace, 'apps', {
  172. get: getApps
  173. });
  174. /**
  175. * Called by App.delete() - but before any services associated with the App
  176. * are deleted.
  177. */
  178. function removeApp(name) {
  179. delete apps[name];
  180. }
  181. /**
  182. * Get the App object for a given name (or DEFAULT).
  183. */
  184. function app(name) {
  185. name = name || modularAPIs._DEFAULT_ENTRY_NAME;
  186. if (!contains(apps, name)) {
  187. throw ERROR_FACTORY.create("no-app" /* AppError.NO_APP */, { appName: name });
  188. }
  189. return apps[name];
  190. }
  191. // @ts-ignore
  192. app['App'] = firebaseAppImpl;
  193. /**
  194. * Create a new App instance (name must be unique).
  195. *
  196. * This function is idempotent. It can be called more than once and return the same instance using the same options and config.
  197. */
  198. function initializeAppCompat(options, rawConfig) {
  199. if (rawConfig === void 0) { rawConfig = {}; }
  200. var app = modularAPIs.initializeApp(options, rawConfig);
  201. if (contains(apps, app.name)) {
  202. return apps[app.name];
  203. }
  204. var appCompat = new firebaseAppImpl(app, namespace);
  205. apps[app.name] = appCompat;
  206. return appCompat;
  207. }
  208. /*
  209. * Return an array of all the non-deleted FirebaseApps.
  210. */
  211. function getApps() {
  212. // Make a copy so caller cannot mutate the apps list.
  213. return Object.keys(apps).map(function (name) { return apps[name]; });
  214. }
  215. function registerComponentCompat(component) {
  216. var componentName = component.name;
  217. var componentNameWithoutCompat = componentName.replace('-compat', '');
  218. if (modularAPIs._registerComponent(component) &&
  219. component.type === "PUBLIC" /* ComponentType.PUBLIC */) {
  220. // create service namespace for public components
  221. // The Service namespace is an accessor function ...
  222. var serviceNamespace = function (appArg) {
  223. if (appArg === void 0) { appArg = app(); }
  224. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  225. if (typeof appArg[componentNameWithoutCompat] !== 'function') {
  226. // Invalid argument.
  227. // This happens in the following case: firebase.storage('gs:/')
  228. throw ERROR_FACTORY.create("invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */, {
  229. appName: componentName
  230. });
  231. }
  232. // Forward service instance lookup to the FirebaseApp.
  233. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  234. return appArg[componentNameWithoutCompat]();
  235. };
  236. // ... and a container for service-level properties.
  237. if (component.serviceProps !== undefined) {
  238. deepExtend(serviceNamespace, component.serviceProps);
  239. }
  240. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  241. namespace[componentNameWithoutCompat] = serviceNamespace;
  242. // Patch the FirebaseAppImpl prototype
  243. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  244. firebaseAppImpl.prototype[componentNameWithoutCompat] =
  245. // TODO: The eslint disable can be removed and the 'ignoreRestArgs'
  246. // option added to the no-explicit-any rule when ESlint releases it.
  247. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  248. function () {
  249. var args = [];
  250. for (var _i = 0; _i < arguments.length; _i++) {
  251. args[_i] = arguments[_i];
  252. }
  253. var serviceFxn = this._getService.bind(this, componentName);
  254. return serviceFxn.apply(this, component.multipleInstances ? args : []);
  255. };
  256. }
  257. return component.type === "PUBLIC" /* ComponentType.PUBLIC */
  258. ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
  259. namespace[componentNameWithoutCompat]
  260. : null;
  261. }
  262. // Map the requested service to a registered service name
  263. // (used to map auth to serverAuth service when needed).
  264. function useAsService(app, name) {
  265. if (name === 'serverAuth') {
  266. return null;
  267. }
  268. var useService = name;
  269. return useService;
  270. }
  271. return namespace;
  272. }
  273. /**
  274. * @license
  275. * Copyright 2019 Google LLC
  276. *
  277. * Licensed under the Apache License, Version 2.0 (the "License");
  278. * you may not use this file except in compliance with the License.
  279. * You may obtain a copy of the License at
  280. *
  281. * http://www.apache.org/licenses/LICENSE-2.0
  282. *
  283. * Unless required by applicable law or agreed to in writing, software
  284. * distributed under the License is distributed on an "AS IS" BASIS,
  285. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  286. * See the License for the specific language governing permissions and
  287. * limitations under the License.
  288. */
  289. function createFirebaseNamespaceLite() {
  290. var namespace = createFirebaseNamespaceCore(FirebaseAppLiteImpl);
  291. namespace.SDK_VERSION = "".concat(namespace.SDK_VERSION, "_LITE");
  292. var registerComponent = namespace.INTERNAL.registerComponent;
  293. namespace.INTERNAL.registerComponent = registerComponentForLite;
  294. /**
  295. * This is a special implementation, so it only works with performance.
  296. * only allow performance SDK to register.
  297. */
  298. function registerComponentForLite(
  299. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  300. component) {
  301. // only allow performance to register with firebase lite
  302. if (component.type === "PUBLIC" /* ComponentType.PUBLIC */ &&
  303. !component.name.includes('performance') &&
  304. !component.name.includes('installations')) {
  305. throw Error("".concat(name, " cannot register with the standalone perf instance"));
  306. }
  307. return registerComponent(component);
  308. }
  309. return namespace;
  310. }
  311. var name$1 = "@firebase/app-compat";
  312. var version = "0.2.1";
  313. /**
  314. * @license
  315. * Copyright 2019 Google LLC
  316. *
  317. * Licensed under the Apache License, Version 2.0 (the "License");
  318. * you may not use this file except in compliance with the License.
  319. * You may obtain a copy of the License at
  320. *
  321. * http://www.apache.org/licenses/LICENSE-2.0
  322. *
  323. * Unless required by applicable law or agreed to in writing, software
  324. * distributed under the License is distributed on an "AS IS" BASIS,
  325. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  326. * See the License for the specific language governing permissions and
  327. * limitations under the License.
  328. */
  329. function registerCoreComponents(variant) {
  330. // Register `app` package.
  331. registerVersion(name$1, version, variant);
  332. }
  333. /**
  334. * @license
  335. * Copyright 2019 Google LLC
  336. *
  337. * Licensed under the Apache License, Version 2.0 (the "License");
  338. * you may not use this file except in compliance with the License.
  339. * You may obtain a copy of the License at
  340. *
  341. * http://www.apache.org/licenses/LICENSE-2.0
  342. *
  343. * Unless required by applicable law or agreed to in writing, software
  344. * distributed under the License is distributed on an "AS IS" BASIS,
  345. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  346. * See the License for the specific language governing permissions and
  347. * limitations under the License.
  348. */
  349. var firebase = createFirebaseNamespaceLite();
  350. registerCoreComponents('lite');
  351. export { firebase as default };
  352. //# sourceMappingURL=index.lite.esm5.js.map