sea-react-components 1.3.10 → 1.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,10 @@
1
1
  import { CONSTANTS } from "sea-platform-helpers";
2
2
  import { FirebaseConfig, NotificationPayload } from "../../utils/firebase-client";
3
- export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, _onForegroundMessage, _onGetToken, }: Readonly<{
3
+ export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, firebaseSWPath, _onForegroundMessage, _onGetToken, }: Readonly<{
4
4
  config: FirebaseConfig;
5
5
  updateFirebaseTokenUrl: string;
6
6
  applicationKey: CONSTANTS.Application.ApplicationKeys;
7
+ firebaseSWPath?: string;
7
8
  _onForegroundMessage?: (notification: NotificationPayload) => void;
8
9
  _onGetToken?: (token: string) => void;
9
10
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/firebase-token-handler/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAS,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAIL,cAAc,EACd,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AASrC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,WAAW,GACZ,EAAE,QAAQ,CAAC;IACV,MAAM,EAAE,cAAc,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC;IACtD,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC,2CAwBD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/firebase-token-handler/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAS,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAIL,cAAc,EACd,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AASrC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,sBAAsB,EACtB,cAAc,EACd,cAA4C,EAC5C,oBAAoB,EACpB,WAAW,GACZ,EAAE,QAAQ,CAAC;IACV,MAAM,EAAE,cAAc,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC,2CAwBD"}
@@ -11,10 +11,10 @@ const axiosOptions = {
11
11
  Authorization: `Bearer ${getCookie(CONSTANTS.JWT.JWTCookieKey)}`,
12
12
  },
13
13
  };
14
- export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, _onForegroundMessage, _onGetToken, }) {
14
+ export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, firebaseSWPath = "/firebase-messaging-sw.js", _onForegroundMessage, _onGetToken, }) {
15
15
  useEffect(() => {
16
16
  initFirebase(config);
17
- requestForToken(config.vapidKey).then((token) => {
17
+ requestForToken(config.vapidKey, firebaseSWPath).then((token) => {
18
18
  if (token) {
19
19
  axios.put(updateFirebaseTokenUrl, { token, applicationKey }, axiosOptions);
20
20
  _onGetToken && _onGetToken(token);
@@ -7,7 +7,7 @@ export declare function initFirebase(config: FirebaseConfig): Messaging;
7
7
  /**
8
8
  * Get FCM token for this device/browser
9
9
  */
10
- export declare function requestForToken(vapidKey: string): Promise<string | null>;
10
+ export declare function requestForToken(vapidKey: string, swPath?: string): Promise<string | null>;
11
11
  /**
12
12
  * Listen for foreground messages
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../../src/utils/firebase-client/firebase.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAK9D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAc9D;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcxB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAC/C,IAAI,CAgBN"}
1
+ {"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../../src/utils/firebase-client/firebase.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAK9D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAc9D;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAoC,GAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBxB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAC/C,IAAI,CAgBN"}
@@ -22,12 +22,20 @@ export function initFirebase(config) {
22
22
  /**
23
23
  * Get FCM token for this device/browser
24
24
  */
25
- export async function requestForToken(vapidKey) {
25
+ export async function requestForToken(vapidKey, swPath = "/firebase-messaging-sw.js" // default
26
+ ) {
26
27
  if (!messagingInstance) {
27
28
  throw new Error("[firebase-notifications] Firebase not initialized. Call initFirebase first.");
28
29
  }
29
30
  try {
30
- const token = await getToken(messagingInstance, { vapidKey });
31
+ const registration = await navigator.serviceWorker.register(swPath, {
32
+ // make sure scope matches subdirectory
33
+ scope: swPath.replace("firebase-messaging-sw.js", ""),
34
+ });
35
+ const token = await getToken(messagingInstance, {
36
+ vapidKey,
37
+ serviceWorkerRegistration: registration,
38
+ });
31
39
  return token;
32
40
  }
33
41
  catch (err) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sea-react-components",
3
3
  "description": "SEA react components library",
4
- "version": "1.3.10",
4
+ "version": "1.3.11",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc --build && npx postcss src/styles.css -o dist/styles.css && npx postcss src/components/text-editor/style.css -o dist/components/text-editor/style.css",