1 |
|
2 | 'use strict';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | require("core-js/modules/es.symbol");
|
9 |
|
10 | require("core-js/modules/es.symbol.description");
|
11 |
|
12 | require("core-js/modules/es.symbol.iterator");
|
13 |
|
14 | require("core-js/modules/es.array.find");
|
15 |
|
16 | require("core-js/modules/es.array.is-array");
|
17 |
|
18 | require("core-js/modules/es.array.iterator");
|
19 |
|
20 | require("core-js/modules/es.function.name");
|
21 |
|
22 | require("core-js/modules/es.object.to-string");
|
23 |
|
24 | require("core-js/modules/es.regexp.exec");
|
25 |
|
26 | require("core-js/modules/es.string.iterator");
|
27 |
|
28 | require("core-js/modules/es.string.split");
|
29 |
|
30 | require("core-js/modules/web.dom-collections.iterator");
|
31 |
|
32 | Object.defineProperty(exports, "__esModule", {
|
33 | value: true
|
34 | });
|
35 | exports["default"] = getHost;
|
36 |
|
37 | function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
38 |
|
39 | function getByRemoteConfig(hostname) {
|
40 | var remoteModuleConfig = typeof window !== 'undefined' && window.__fbBatchedBridgeConfig && window.__fbBatchedBridgeConfig.remoteModuleConfig;
|
41 | if (!Array.isArray(remoteModuleConfig) || hostname !== 'localhost' && hostname !== '127.0.0.1') return {
|
42 | hostname: hostname,
|
43 | passed: false
|
44 | };
|
45 | var constants = (remoteModuleConfig.find(getConstants) || [])[1];
|
46 |
|
47 | if (constants) {
|
48 | var serverHost = constants.ServerHost || hostname;
|
49 | return {
|
50 | hostname: serverHost.split(':')[0],
|
51 | passed: true
|
52 | };
|
53 | }
|
54 |
|
55 | return {
|
56 | hostname: hostname,
|
57 | passed: false
|
58 | };
|
59 | }
|
60 |
|
61 | function getConstants(config) {
|
62 | return config && (config[0] === 'AndroidConstants' || config[0] === 'PlatformConstants');
|
63 | }
|
64 |
|
65 | function getByRNRequirePolyfill(hostname) {
|
66 | var NativeModules;
|
67 | var PlatformConstants;
|
68 | var AndroidConstants;
|
69 |
|
70 | if (typeof window === 'undefined' || !window.__DEV__ || typeof window.require !== 'function' ||
|
71 |
|
72 | window.require.name === 'metroRequire') {
|
73 | return hostname;
|
74 | }
|
75 |
|
76 | NativeModules = window.require('NativeModules');
|
77 |
|
78 | if (!NativeModules || !NativeModules.PlatformConstants && !NativeModules.AndroidConstants) {
|
79 | return hostname;
|
80 | }
|
81 |
|
82 | PlatformConstants = NativeModules.PlatformConstants;
|
83 | AndroidConstants = NativeModules.AndroidConstants;
|
84 | var serverHost = (PlatformConstants ? PlatformConstants.ServerHost : AndroidConstants.ServerHost) || hostname;
|
85 | return serverHost.split(':')[0];
|
86 | }
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | function getHost(hostname) {
|
94 |
|
95 | if ((typeof __fbBatchedBridge === "undefined" ? "undefined" : _typeof(__fbBatchedBridge)) !== 'object' || hostname !== 'localhost' && hostname !== '127.0.0.1') {
|
96 | return hostname;
|
97 | }
|
98 |
|
99 | var result = getByRemoteConfig(hostname);
|
100 |
|
101 | if (result.passed) {
|
102 | return result.hostname;
|
103 | }
|
104 |
|
105 |
|
106 | return getByRNRequirePolyfill(hostname);
|
107 | } |
\ | No newline at end of file |