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.

144 lines
5.3 KiB

2 months ago
  1. import firebase from '@firebase/app-compat';
  2. import { Component } from '@firebase/component';
  3. import { __awaiter, __generator } from 'tslib';
  4. import { getToken, deleteToken, onMessage } from '@firebase/messaging';
  5. import { isIndexedDBAvailable, areCookiesEnabled } from '@firebase/util';
  6. import { onBackgroundMessage } from '@firebase/messaging/sw';
  7. var name = "@firebase/messaging-compat";
  8. var version = "0.2.1";
  9. /**
  10. * @license
  11. * Copyright 2020 Google LLC
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License");
  14. * you may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. function isSupported() {
  26. if (self && 'ServiceWorkerGlobalScope' in self) {
  27. // Running in ServiceWorker context
  28. return isSwSupported();
  29. }
  30. else {
  31. // Assume we are in the window context.
  32. return isWindowSupported();
  33. }
  34. }
  35. /**
  36. * Checks to see if the required APIs exist.
  37. * Unlike the modular version, it does not check if IndexedDB.open() is allowed
  38. * in order to keep isSupported() synchronous and maintain v8 compatibility.
  39. */
  40. function isWindowSupported() {
  41. return (typeof window !== 'undefined' &&
  42. isIndexedDBAvailable() &&
  43. areCookiesEnabled() &&
  44. 'serviceWorker' in navigator &&
  45. 'PushManager' in window &&
  46. 'Notification' in window &&
  47. 'fetch' in window &&
  48. ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
  49. PushSubscription.prototype.hasOwnProperty('getKey'));
  50. }
  51. /**
  52. * Checks to see if the required APIs exist within SW Context.
  53. */
  54. function isSwSupported() {
  55. return (isIndexedDBAvailable() &&
  56. 'PushManager' in self &&
  57. 'Notification' in self &&
  58. ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
  59. PushSubscription.prototype.hasOwnProperty('getKey'));
  60. }
  61. var MessagingCompatImpl = /** @class */ (function () {
  62. function MessagingCompatImpl(app, _delegate) {
  63. this.app = app;
  64. this._delegate = _delegate;
  65. this.app = app;
  66. this._delegate = _delegate;
  67. }
  68. MessagingCompatImpl.prototype.getToken = function (options) {
  69. return __awaiter(this, void 0, void 0, function () {
  70. return __generator(this, function (_a) {
  71. return [2 /*return*/, getToken(this._delegate, options)];
  72. });
  73. });
  74. };
  75. MessagingCompatImpl.prototype.deleteToken = function () {
  76. return __awaiter(this, void 0, void 0, function () {
  77. return __generator(this, function (_a) {
  78. return [2 /*return*/, deleteToken(this._delegate)];
  79. });
  80. });
  81. };
  82. MessagingCompatImpl.prototype.onMessage = function (nextOrObserver) {
  83. return onMessage(this._delegate, nextOrObserver);
  84. };
  85. MessagingCompatImpl.prototype.onBackgroundMessage = function (nextOrObserver) {
  86. return onBackgroundMessage(this._delegate, nextOrObserver);
  87. };
  88. return MessagingCompatImpl;
  89. }());
  90. /**
  91. * @license
  92. * Copyright 2020 Google LLC
  93. *
  94. * Licensed under the Apache License, Version 2.0 (the "License");
  95. * you may not use this file except in compliance with the License.
  96. * You may obtain a copy of the License at
  97. *
  98. * http://www.apache.org/licenses/LICENSE-2.0
  99. *
  100. * Unless required by applicable law or agreed to in writing, software
  101. * distributed under the License is distributed on an "AS IS" BASIS,
  102. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  103. * See the License for the specific language governing permissions and
  104. * limitations under the License.
  105. */
  106. var messagingCompatFactory = function (container) {
  107. if (self && 'ServiceWorkerGlobalScope' in self) {
  108. // in sw
  109. return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate());
  110. }
  111. else {
  112. // in window
  113. return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate());
  114. }
  115. };
  116. var NAMESPACE_EXPORTS = {
  117. isSupported: isSupported
  118. };
  119. function registerMessagingCompat() {
  120. firebase.INTERNAL.registerComponent(new Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));
  121. }
  122. /**
  123. * @license
  124. * Copyright 2020 Google LLC
  125. *
  126. * Licensed under the Apache License, Version 2.0 (the "License");
  127. * you may not use this file except in compliance with the License.
  128. * You may obtain a copy of the License at
  129. *
  130. * http://www.apache.org/licenses/LICENSE-2.0
  131. *
  132. * Unless required by applicable law or agreed to in writing, software
  133. * distributed under the License is distributed on an "AS IS" BASIS,
  134. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  135. * See the License for the specific language governing permissions and
  136. * limitations under the License.
  137. */
  138. registerMessagingCompat();
  139. firebase.registerVersion(name, version);
  140. //# sourceMappingURL=index.esm.js.map