import { getPlatform, Platform } from 'para-utils';

/**
 * consider the sign '_ntv' is unique
 */
const getAndroidBridgeMethods = () => {
  const result: any = {};
  for (const prop in window) {
    if (window.hasOwnProperty(prop) && ~prop.indexOf('_ntv')) {
      result[prop] = window[prop];
    }
  }
  return result;
}

export const globalBridge = () => {
  if (getPlatform() === Platform.FacAndroidWebview) {
    return getAndroidBridgeMethods();
  } else {
    return require('./manifest-ios.json');
  }
}