yeet
This commit is contained in:
167
node_modules/@react-native-community/cli/build/commands/start/runServer.js
generated
vendored
Normal file
167
node_modules/@react-native-community/cli/build/commands/start/runServer.js
generated
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _metro() {
|
||||
const data = _interopRequireDefault(require("metro"));
|
||||
|
||||
_metro = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _metroCore() {
|
||||
const data = require("metro-core");
|
||||
|
||||
_metroCore = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliServerApi() {
|
||||
const data = require("@react-native-community/cli-server-api");
|
||||
|
||||
_cliServerApi = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _loadMetroConfig = _interopRequireDefault(require("../../tools/loadMetroConfig"));
|
||||
|
||||
var _releaseChecker = _interopRequireDefault(require("../../tools/releaseChecker"));
|
||||
|
||||
var _watchMode = _interopRequireDefault(require("./watchMode"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// @ts-ignore untyped metro
|
||||
// @ts-ignore untyped metro
|
||||
async function runServer(_argv, ctx, args) {
|
||||
let reportEvent;
|
||||
const terminal = new (_metroCore().Terminal)(process.stdout);
|
||||
const ReporterImpl = getReporterImpl(args.customLogReporterPath);
|
||||
const terminalReporter = new ReporterImpl(terminal);
|
||||
const reporter = {
|
||||
update(event) {
|
||||
terminalReporter.update(event);
|
||||
|
||||
if (reportEvent) {
|
||||
reportEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
const metroConfig = await (0, _loadMetroConfig.default)(ctx, {
|
||||
config: args.config,
|
||||
maxWorkers: args.maxWorkers,
|
||||
port: args.port,
|
||||
resetCache: args.resetCache,
|
||||
watchFolders: args.watchFolders,
|
||||
projectRoot: args.projectRoot,
|
||||
sourceExts: args.sourceExts,
|
||||
reporter
|
||||
});
|
||||
|
||||
if (args.assetPlugins) {
|
||||
metroConfig.transformer.assetPlugins = args.assetPlugins.map(plugin => require.resolve(plugin));
|
||||
}
|
||||
|
||||
const {
|
||||
middleware,
|
||||
attachToServer
|
||||
} = (0, _cliServerApi().createDevServerMiddleware)({
|
||||
host: args.host,
|
||||
port: metroConfig.server.port,
|
||||
watchFolders: metroConfig.watchFolders
|
||||
});
|
||||
middleware.use(_cliServerApi().indexPageMiddleware);
|
||||
const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;
|
||||
|
||||
metroConfig.server.enhanceMiddleware = (metroMiddleware, server) => {
|
||||
if (customEnhanceMiddleware) {
|
||||
metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);
|
||||
}
|
||||
|
||||
return middleware.use(metroMiddleware);
|
||||
};
|
||||
|
||||
const serverInstance = await _metro().default.runServer(metroConfig, {
|
||||
host: args.host,
|
||||
secure: args.https,
|
||||
secureCert: args.cert,
|
||||
secureKey: args.key,
|
||||
hmrEnabled: true
|
||||
});
|
||||
const {
|
||||
messageSocket,
|
||||
eventsSocket
|
||||
} = attachToServer(serverInstance);
|
||||
reportEvent = eventsSocket.reportEvent;
|
||||
|
||||
if (args.interactive) {
|
||||
(0, _watchMode.default)(messageSocket);
|
||||
} // In Node 8, the default keep-alive for an HTTP connection is 5 seconds. In
|
||||
// early versions of Node 8, this was implemented in a buggy way which caused
|
||||
// some HTTP responses (like those containing large JS bundles) to be
|
||||
// terminated early.
|
||||
//
|
||||
// As a workaround, arbitrarily increase the keep-alive from 5 to 30 seconds,
|
||||
// which should be enough to send even the largest of JS bundles.
|
||||
//
|
||||
// For more info: https://github.com/nodejs/node/issues/13391
|
||||
//
|
||||
|
||||
|
||||
serverInstance.keepAliveTimeout = 30000;
|
||||
await (0, _releaseChecker.default)(ctx.root);
|
||||
}
|
||||
|
||||
function getReporterImpl(customLogReporterPath) {
|
||||
if (customLogReporterPath === undefined) {
|
||||
return require('metro/src/lib/TerminalReporter');
|
||||
}
|
||||
|
||||
try {
|
||||
// First we let require resolve it, so we can require packages in node_modules
|
||||
// as expected. eg: require('my-package/reporter');
|
||||
return require(customLogReporterPath);
|
||||
} catch (e) {
|
||||
if (e.code !== 'MODULE_NOT_FOUND') {
|
||||
throw e;
|
||||
} // If that doesn't work, then we next try relative to the cwd, eg:
|
||||
// require('./reporter');
|
||||
|
||||
|
||||
return require(_path().default.resolve(customLogReporterPath));
|
||||
}
|
||||
}
|
||||
|
||||
var _default = runServer;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=runServer.js.map
|
91
node_modules/@react-native-community/cli/build/commands/start/start.js
generated
vendored
Normal file
91
node_modules/@react-native-community/cli/build/commands/start/start.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _runServer = _interopRequireDefault(require("./runServer"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
var _default = {
|
||||
name: 'start',
|
||||
func: _runServer.default,
|
||||
description: 'starts the webserver',
|
||||
options: [{
|
||||
name: '--port [number]',
|
||||
parse: val => Number(val)
|
||||
}, {
|
||||
name: '--host [string]',
|
||||
default: ''
|
||||
}, {
|
||||
name: '--projectRoot [path]',
|
||||
description: 'Path to a custom project root',
|
||||
parse: val => _path().default.resolve(val)
|
||||
}, {
|
||||
name: '--watchFolders [list]',
|
||||
description: 'Specify any additional folders to be added to the watch list',
|
||||
parse: val => val.split(',').map(folder => _path().default.resolve(folder))
|
||||
}, {
|
||||
name: '--assetPlugins [list]',
|
||||
description: 'Specify any additional asset plugins to be used by the packager by full filepath',
|
||||
parse: val => val.split(',')
|
||||
}, {
|
||||
name: '--sourceExts [list]',
|
||||
description: 'Specify any additional source extensions to be used by the packager',
|
||||
parse: val => val.split(',')
|
||||
}, {
|
||||
name: '--max-workers [number]',
|
||||
description: 'Specifies the maximum number of workers the worker-pool ' + 'will spawn for transforming files. This defaults to the number of the ' + 'cores available on your machine.',
|
||||
parse: workers => Number(workers)
|
||||
}, {
|
||||
name: '--transformer [string]',
|
||||
description: 'Specify a custom transformer to be used'
|
||||
}, {
|
||||
name: '--reset-cache, --resetCache',
|
||||
description: 'Removes cached files'
|
||||
}, {
|
||||
name: '--custom-log-reporter-path, --customLogReporterPath [string]',
|
||||
description: 'Path to a JavaScript file that exports a log reporter as a replacement for TerminalReporter'
|
||||
}, {
|
||||
name: '--verbose',
|
||||
description: 'Enables logging'
|
||||
}, {
|
||||
name: '--https',
|
||||
description: 'Enables https connections to the server'
|
||||
}, {
|
||||
name: '--key [path]',
|
||||
description: 'Path to custom SSL key'
|
||||
}, {
|
||||
name: '--cert [path]',
|
||||
description: 'Path to custom SSL cert'
|
||||
}, {
|
||||
name: '--config [string]',
|
||||
description: 'Path to the CLI configuration file',
|
||||
parse: val => _path().default.resolve(val)
|
||||
}, {
|
||||
name: '--no-interactive',
|
||||
description: 'Disables interactive mode'
|
||||
}]
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=start.js.map
|
89
node_modules/@react-native-community/cli/build/commands/start/watchMode.js
generated
vendored
Normal file
89
node_modules/@react-native-community/cli/build/commands/start/watchMode.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _readline() {
|
||||
const data = _interopRequireDefault(require("readline"));
|
||||
|
||||
_readline = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _hookStdout = _interopRequireDefault(require("../../tools/hookStdout"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function printWatchModeInstructions() {
|
||||
_cliTools().logger.log('\n\nTo reload the app press "r"\nTo open developer menu press "d"');
|
||||
}
|
||||
|
||||
function enableWatchMode(messageSocket) {
|
||||
// We need to set this to true to catch key presses individually.
|
||||
// As a result we have to implement our own method for exiting
|
||||
// and other commands (e.g. ctrl+c & ctrl+z)
|
||||
if (!process.stdin.setRawMode) {
|
||||
_cliTools().logger.debug('Watch mode is not supported in this environment');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_readline().default.emitKeypressEvents(process.stdin);
|
||||
|
||||
process.stdin.setRawMode(true); // We have no way of knowing when the dependency graph is done loading
|
||||
// except by hooking into stdout itself. We want to print instructions
|
||||
// right after its done loading.
|
||||
|
||||
const restore = (0, _hookStdout.default)(output => {
|
||||
if (output.includes('Learn once, write anywhere')) {
|
||||
printWatchModeInstructions();
|
||||
restore();
|
||||
}
|
||||
});
|
||||
process.stdin.on('keypress', (_key, data) => {
|
||||
const {
|
||||
ctrl,
|
||||
name
|
||||
} = data;
|
||||
|
||||
if (ctrl === true) {
|
||||
switch (name) {
|
||||
case 'c':
|
||||
process.exit();
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
process.emit('SIGTSTP');
|
||||
break;
|
||||
}
|
||||
} else if (name === 'r') {
|
||||
messageSocket.broadcast('reload', null);
|
||||
|
||||
_cliTools().logger.info('Reloading app...');
|
||||
} else if (name === 'd') {
|
||||
messageSocket.broadcast('devMenu', null);
|
||||
|
||||
_cliTools().logger.info('Opening developer menu...');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var _default = enableWatchMode;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=watchMode.js.map
|
Reference in New Issue
Block a user