PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@expo/cli/build/src/start/server/metro
Просмотр файла: MetroBundlerDevServer.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _devServer = require("@expo/dev-server");
var _port = require("../../../utils/port");
var _bundlerDevServer = require("../BundlerDevServer");
var _interstitialPageMiddleware = require("../middleware/InterstitialPageMiddleware");
var _runtimeRedirectMiddleware = require("../middleware/RuntimeRedirectMiddleware");
var _instantiateMetro = require("./instantiateMetro");
/** Default port to use for apps running in Expo Go. */ const EXPO_GO_METRO_PORT = 19000;
/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */ const DEV_CLIENT_METRO_PORT = 8081;
class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
get name() {
return "metro";
}
async resolvePortAsync(options = {}) {
var // If the manually defined port is busy then an error should be thrown...
_port1;
const port = (_port1 = options.port) != null ? _port1 : // Otherwise use the default port based on the runtime target.
(options.devClient ? Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT : await (0, _port).getFreePortAsync(EXPO_GO_METRO_PORT));
return port;
}
async startImplementationAsync(options) {
options.port = await this.resolvePortAsync(options);
this.urlCreator = this.getUrlCreator(options);
const parsedOptions = {
port: options.port,
maxWorkers: options.maxWorkers,
resetCache: options.resetDevServer,
// Use the unversioned metro config.
// TODO: Deprecate this property when expo-cli goes away.
unversioned: false
};
const { server , middleware , messageSocket } = await (0, _instantiateMetro).instantiateMetroAsync(this.projectRoot, parsedOptions);
const manifestMiddleware = await this.getManifestMiddlewareAsync(options);
// We need the manifest handler to be the first middleware to run so our
// routes take precedence over static files. For example, the manifest is
// served from '/' and if the user has an index.html file in their project
// then the manifest handler will never run, the static middleware will run
// and serve index.html instead of the manifest.
// https://github.com/expo/expo/issues/13114
(0, _devServer).prependMiddleware(middleware, manifestMiddleware);
middleware.use(new _interstitialPageMiddleware.InterstitialPageMiddleware(this.projectRoot).getHandler());
const deepLinkMiddleware = new _runtimeRedirectMiddleware.RuntimeRedirectMiddleware(this.projectRoot, {
onDeepLink: ({ runtime })=>{
// eslint-disable-next-line no-useless-return
if (runtime === "expo") return;
// TODO: Some heavy analytics...
},
getLocation: ({ runtime })=>{
if (runtime === "custom") {
var ref;
return (ref = this.urlCreator) == null ? void 0 : ref.constructDevClientUrl();
} else {
var ref1;
return (ref1 = this.urlCreator) == null ? void 0 : ref1.constructUrl({
scheme: "exp"
});
}
}
});
middleware.use(deepLinkMiddleware.getHandler());
// Extend the close method to ensure that we clean up the local info.
const originalClose = server.close.bind(server);
server.close = (callback)=>{
return originalClose((err)=>{
this.instance = null;
callback == null ? void 0 : callback(err);
});
};
return {
server,
location: {
// The port is the main thing we want to send back.
port: options.port,
// localhost isn't always correct.
host: "localhost",
// http is the only supported protocol on native.
url: `http://localhost:${options.port}`,
protocol: "http"
},
middleware,
messageSocket
};
}
getConfigModuleIds() {
return [
"./metro.config.js",
"./metro.config.json",
"./rn-cli.config.js"
];
}
}
exports.MetroBundlerDevServer = MetroBundlerDevServer;
//# sourceMappingURL=MetroBundlerDevServer.js.mapВыполнить команду
Для локальной разработки. Не используйте в интернете!