diff --git a/packages/bridge/src/commands/index.ts b/packages/bridge/src/commands/index.ts index b007b8b1..cd1fe555 100644 --- a/packages/bridge/src/commands/index.ts +++ b/packages/bridge/src/commands/index.ts @@ -1,4 +1,3 @@ export * from './navigateBack'; export * from './navigateToShowDetail'; export * from './requestToken'; -export * from './utils'; diff --git a/packages/bridge/src/commands/sendCommand.ts b/packages/bridge/src/commands/sendCommand.ts index b3fbd294..db0d50fa 100644 --- a/packages/bridge/src/commands/sendCommand.ts +++ b/packages/bridge/src/commands/sendCommand.ts @@ -1,7 +1,7 @@ import { BRIDGE } from '../constants'; import { Command, PostMessageFn, ResponseListener, WebviewCommand } from '../types'; import { messageListeners, subscribe, unsubscribe } from './messageListeners'; -import { getTimeStamp, getUuid, hasAndroidPostMessage, hasWebkitPostMessage } from './utils'; +import { getTimeStamp, getUuid, hasAndroidPostMessage, hasWebkitPostMessage } from '../utils'; const getPostMessageFn = (): PostMessageFn | null => { if (hasAndroidPostMessage()) { diff --git a/packages/bridge/src/commands/utils.ts b/packages/bridge/src/commands/utils.ts deleted file mode 100644 index 18f60c04..00000000 --- a/packages/bridge/src/commands/utils.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { v4 as uuidv4 } from 'uuid'; - -export const getTimeStamp = () => new Date().valueOf().toString(); - -export const getUuid = () => uuidv4(); - -export const hasAndroidPostMessage = () => - !!(typeof window !== 'undefined' && window.boolti && window.boolti.postMessage); - -export const hasWebkitPostMessage = () => - !!( - typeof window !== 'undefined' && - window.webkit && - window.webkit.messageHandlers && - window.webkit.messageHandlers.boolti && - window.webkit.messageHandlers.boolti.postMessage - ); - -export const isWebViewBridgeAvailable = () => hasAndroidPostMessage() || hasWebkitPostMessage(); diff --git a/packages/bridge/src/utils.ts b/packages/bridge/src/utils.ts index 4cff62b1..ec53c5dd 100644 --- a/packages/bridge/src/utils.ts +++ b/packages/bridge/src/utils.ts @@ -1,4 +1,5 @@ import { OS_REGEX, WEBVIEW_REGEX } from './constants'; +import { v4 as uuidv4 } from 'uuid'; export const getUserAgent = () => window.navigator.userAgent; @@ -19,3 +20,21 @@ export const checkIsIOS = (userAgent: string) => { if (!checkIsWebView(userAgent)) return false; return getWebViewOS(userAgent) === 'IOS'; }; + +export const getTimeStamp = () => new Date().valueOf().toString(); + +export const getUuid = () => uuidv4(); + +export const hasAndroidPostMessage = () => + !!(typeof window !== 'undefined' && window.boolti && window.boolti.postMessage); + +export const hasWebkitPostMessage = () => + !!( + typeof window !== 'undefined' && + window.webkit && + window.webkit.messageHandlers && + window.webkit.messageHandlers.boolti && + window.webkit.messageHandlers.boolti.postMessage + ); + +export const isWebViewBridgeAvailable = () => hasAndroidPostMessage() || hasWebkitPostMessage();