Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
cacheStores: [
new FileStore({
root: path.join(os.tmpdir(), 'metro-cache'),
}),
],
cacheVersion: '1.0',
// We assume the default project path is two levels up from
// node_modules/metro/
projectRoot: projectRoot || path.resolve(__dirname, '../../..'),
stickyWorkers: true,
watchFolders: [],
transformerPath: require.resolve('metro/src/JSTransformer/worker.js'),
maxWorkers: getMaxWorkers(),
resetCache: false,
reporter: new TerminalReporter(new Terminal(process.stdout)),
});
const ModuleCache = require("./ModuleCache");
const ResolutionRequest = require("./DependencyGraph/ResolutionRequest");
const fs = require("fs");
const path = require("path");
const _require = require("./DependencyGraph/ModuleResolution"),
ModuleResolver = _require.ModuleResolver;
const _require2 = require("events"),
EventEmitter = _require2.EventEmitter;
const _require3 = require("metro-core"),
_require3$Logger = _require3.Logger,
createActionStartEntry = _require3$Logger.createActionStartEntry,
createActionEndEntry = _require3$Logger.createActionEndEntry,
log = _require3$Logger.log;
const JEST_HASTE_MAP_CACHE_BREAKER = 4;
class DependencyGraph extends EventEmitter {
constructor(_ref) {
let config = _ref.config,
haste = _ref.haste,
initialHasteFS = _ref.initialHasteFS,
initialModuleMap = _ref.initialModuleMap;
super();
_defineProperty(this, "_doesFileExist", filePath => {
return this._hasteFS.exists(filePath);
const hmrJSBundle = require("./DeltaBundler/Serializers/hmrJSBundle");
const logToConsole = require("./lib/logToConsole");
const nullthrows = require("nullthrows");
const parseOptionsFromUrl = require("./lib/parseOptionsFromUrl");
const splitBundleOptions = require("./lib/splitBundleOptions");
const transformHelpers = require("./lib/transformHelpers");
const url = require("url");
const _require = require("metro-core"),
_require$Logger = _require.Logger,
createActionStartEntry = _require$Logger.createActionStartEntry,
createActionEndEntry = _require$Logger.createActionEndEntry,
log = _require$Logger.log;
function send(sendFns, message) {
const strMessage = JSON.stringify(message);
sendFns.forEach(sendFn => sendFn(strMessage));
}
/**
* The HmrServer (Hot Module Reloading) implements a lightweight interface
* to communicate easily to the logic in the React Native repository (which
* is the one that handles the Web Socket connections).
*
* This interface allows the HmrServer to hook its own logic to WS clients
* getting connected, disconnected or having errors (through the
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
const chalk = require("chalk");
const _require = require("metro-core"),
Logger = _require.Logger;
const JestWorker = require("jest-worker").default;
class WorkerFarm {
constructor(config, transformerConfig) {
this._config = config;
this._transformerConfig = transformerConfig;
if (this._config.maxWorkers > 1) {
const worker = this._makeFarm(
this._config.transformer.workerPath,
["transform"],
this._config.maxWorkers
);
worker.getStdout().on("data", chunk => {
const url = require("url");
const ResourceNotFoundError = require("./IncrementalBundler/ResourceNotFoundError");
const RevisionNotFoundError = require("./IncrementalBundler/RevisionNotFoundError");
const _require = require("./Assets"),
getAsset = _require.getAsset;
const _require2 = require("./DeltaBundler/Serializers/getExplodedSourceMap"),
getExplodedSourceMap = _require2.getExplodedSourceMap;
const _require3 = require("metro-core"),
Logger = _require3.Logger,
_require3$Logger = _require3.Logger,
createActionStartEntry = _require3$Logger.createActionStartEntry,
createActionEndEntry = _require3$Logger.createActionEndEntry,
log = _require3$Logger.log;
function debounceAndBatch(fn, delay) {
let timeout;
return () => {
clearTimeout(timeout);
timeout = setTimeout(fn, delay);
};
}
const DELTA_ID_HEADER = "X-Metro-Delta-ID";
const FILES_CHANGED_COUNT_HEADER = "X-Metro-Files-Changed-Count";
class Server {
return obj;
}
const chalk = require("chalk");
const path = require("path");
const reporting = require("./reporting");
const throttle = require("lodash.throttle");
const _require = require("metro-core"),
AmbiguousModuleResolutionError = _require.AmbiguousModuleResolutionError;
const _require2 = require("metro-core"),
formatBanner = _require2.formatBanner;
const DEP_GRAPH_MESSAGE = "Loading dependency graph";
const GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT =
"The global cache is now disabled because %s";
const DARK_BLOCK_CHAR = "\u2593";
const LIGHT_BLOCK_CHAR = "\u2591";
const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
/**
* We try to print useful information to the terminal for interactive builds.
* This implements the `Reporter` interface from the './reporting' module.
*/
class TerminalReporter {
/**
* The bundle builds for which we are actively maintaining the status on the
* terminal, ie. showing a progress bar. There can be several bundles being
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
const blacklist = require("metro-config/src/defaults/blacklist");
const invariant = require("invariant");
const _require = require("metro-core"),
Logger = _require.Logger;
const _require2 = require("metro-source-map"),
fromRawMappings = _require2.fromRawMappings,
toSegmentTuple = _require2.toSegmentTuple;
exports.createBlacklist = blacklist;
exports.sourceMaps = {
fromRawMappings,
compactMapping: toSegmentTuple
};
exports.createServer = createServer;
exports.Logger = Logger;
/**
* This is a public API, so we don't trust the value and purposefully downgrade
* it as `mixed`. Because it understands `invariant`, Flow ensure that we
const serializeDeltaJSBundle = require("./DeltaBundler/Serializers/helpers/serializeDeltaJSBundle");
const symbolicate = require("./Server/symbolicate/symbolicate");
const url = require("url");
const ResourceNotFoundError = require("./IncrementalBundler/ResourceNotFoundError");
const RevisionNotFoundError = require("./IncrementalBundler/RevisionNotFoundError");
const _require = require("./Assets"),
getAsset = _require.getAsset;
const _require2 = require("metro-core"),
Logger = _require2.Logger,
_require2$Logger = _require2.Logger,
createActionStartEntry = _require2$Logger.createActionStartEntry,
createActionEndEntry = _require2$Logger.createActionEndEntry,
log = _require2$Logger.log;
function debounceAndBatch(fn, delay) {
let timeout;
return () => {
clearTimeout(timeout);
timeout = setTimeout(fn, delay);
};
}
const DELTA_ID_HEADER = "X-Metro-Delta-ID";
const FILES_CHANGED_COUNT_HEADER = "X-Metro-Files-Changed-Count";
const serializeDeltaJSBundle = require("./DeltaBundler/Serializers/helpers/serializeDeltaJSBundle");
const symbolicate = require("./Server/symbolicate/symbolicate");
const url = require("url");
const ResourceNotFoundError = require("./IncrementalBundler/ResourceNotFoundError");
const RevisionNotFoundError = require("./IncrementalBundler/RevisionNotFoundError");
const _require = require("./Assets"),
getAsset = _require.getAsset;
const _require2 = require("metro-core"),
Logger = _require2.Logger,
_require2$Logger = _require2.Logger,
createActionStartEntry = _require2$Logger.createActionStartEntry,
createActionEndEntry = _require2$Logger.createActionEndEntry,
log = _require2$Logger.log;
function debounceAndBatch(fn, delay) {
let timeout;
return () => {
clearTimeout(timeout);
timeout = setTimeout(fn, delay);
};
}
const DELTA_ID_HEADER = "X-Metro-Delta-ID";
const FILES_CHANGED_COUNT_HEADER = "X-Metro-Files-Changed-Count";
class Server {
args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
const _require = require("metro-core"),
Logger = _require.Logger;
/**
* Main cache class. Receives an array of cache instances, and sequentially
* traverses them to return a previously stored value. It also ensures setting
* the value in all instances.
*
* All get/set operations are logged via Metro's logger.
*/
class Cache {
constructor(stores) {
this._hits = new WeakMap();
this._stores = stores;
}
get(key) {
var _this = this;