🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

metro

Package Overview
Dependencies
Maintainers
2
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro - npm Package Compare versions

Comparing version
0.84.3
to
0.84.4
+14
-15
package.json
{
"name": "metro",
"version": "0.84.3",
"version": "0.84.4",
"description": "🚇 The JavaScript bundler for React Native.",

@@ -30,3 +30,2 @@ "main": "src/index.js",

"accepts": "^2.0.0",
"chalk": "^4.0.0",
"ci-info": "^2.0.0",

@@ -44,14 +43,14 @@ "connect": "^3.6.5",

"lodash.throttle": "^4.1.1",
"metro-babel-transformer": "0.84.3",
"metro-cache": "0.84.3",
"metro-cache-key": "0.84.3",
"metro-config": "0.84.3",
"metro-core": "0.84.3",
"metro-file-map": "0.84.3",
"metro-resolver": "0.84.3",
"metro-runtime": "0.84.3",
"metro-source-map": "0.84.3",
"metro-symbolicate": "0.84.3",
"metro-transform-plugins": "0.84.3",
"metro-transform-worker": "0.84.3",
"metro-babel-transformer": "0.84.4",
"metro-cache": "0.84.4",
"metro-cache-key": "0.84.4",
"metro-config": "0.84.4",
"metro-core": "0.84.4",
"metro-file-map": "0.84.4",
"metro-resolver": "0.84.4",
"metro-runtime": "0.84.4",
"metro-source-map": "0.84.4",
"metro-symbolicate": "0.84.4",
"metro-transform-plugins": "0.84.4",
"metro-transform-worker": "0.84.4",
"mime-types": "^3.0.1",

@@ -77,3 +76,3 @@ "nullthrows": "^1.1.1",

"jest-snapshot-serializer-raw": "^1.2.0",
"metro-babel-register": "0.84.3",
"metro-babel-register": "0.84.4",
"metro-memory-fs": "*",

@@ -80,0 +79,0 @@ "mock-req": "^0.2.0",

@@ -224,14 +224,9 @@ "use strict";

}
if (fileExistsInFileMap != null) {
if (!fileExistsInFileMap(absolutePath)) {
throw new Error(
`'${relativePath}' could not be found, because it is not within the projectRoot or watchFolders, or it is blocked via the resolver.blockList config`,
);
}
} else {
if (!pathBelongsToRoots(absolutePath, [projectRoot, ...watchFolders])) {
throw new Error(
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder`,
);
}
if (
fileExistsInFileMap == null &&
!pathBelongsToRoots(absolutePath, [projectRoot, ...watchFolders])
) {
throw new Error(
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder`,
);
}

@@ -241,6 +236,18 @@ const record = await getAbsoluteAssetRecord(absolutePath, platform ?? null);

if (record.scales[i] >= assetData.resolution) {
if (
fileExistsInFileMap != null &&
!fileExistsInFileMap(record.files[i])
) {
continue;
}
return _fs.default.promises.readFile(record.files[i]);
}
}
return _fs.default.promises.readFile(record.files[record.files.length - 1]);
const lastFile = record.files[record.files.length - 1];
if (fileExistsInFileMap != null && !fileExistsInFileMap(lastFile)) {
throw new Error(
`'${relativePath}' could not be found, because it is not within the projectRoot or watchFolders, or it is blocked via the resolver.blockList config`,
);
}
return _fs.default.promises.readFile(lastFile);
}

@@ -247,0 +254,0 @@ function pathBelongsToRoots(pathToCheck, roots) {

@@ -66,3 +66,2 @@ "use strict";

var outputBundle = _interopRequireWildcard(require("./shared/output/bundle"));
var _chalk = _interopRequireDefault(require("chalk"));
var _fs = _interopRequireDefault(require("fs"));

@@ -75,2 +74,3 @@ var _http = _interopRequireDefault(require("http"));

var _nullthrows = _interopRequireDefault(require("nullthrows"));
var _util = _interopRequireDefault(require("util"));
function _interopRequireWildcard(e, t) {

@@ -206,3 +206,3 @@ if ("function" == typeof WeakMap)

console.warn(
_chalk.default.inverse.yellow.bold(" DEPRECATED "),
_util.default.styleText(["inverse", "yellow", "bold"], " DEPRECATED "),
"The `secure`, `secureCert`, and `secureKey` options are now deprecated. " +

@@ -209,0 +209,0 @@ "Please use the `secureServerOptions` object instead to pass options to " +

@@ -7,3 +7,2 @@ "use strict";

exports.default = void 0;
var _chalk = _interopRequireDefault(require("chalk"));
var _util = _interopRequireDefault(require("util"));

@@ -19,6 +18,6 @@ function _interopRequireDefault(e) {

level === "error"
? _chalk.default.inverse.red
? ["inverse", "red"]
: level === "warn"
? _chalk.default.inverse.yellow
: _chalk.default.inverse.white;
? ["inverse", "yellow"]
: ["inverse", "white"];
if (level === "group") {

@@ -32,3 +31,3 @@ groupStack.push(level);

terminal.log(
_chalk.default.inverse.yellow.bold(" WARN "),
_util.default.styleText(["inverse", "yellow", "bold"], " WARN "),
"Expected `console.groupEnd` to be called after `console.groupCollapsed`.",

@@ -53,4 +52,6 @@ );

terminal.log(
color.bold(` ${logFunction.toUpperCase()} `) +
"".padEnd(groupStack.length * 2, " "),
_util.default.styleText(
[...color, "bold"],
` ${logFunction.toUpperCase()} `,
) + "".padEnd(groupStack.length * 2, " "),
_util.default.format(...data),

@@ -57,0 +58,0 @@ );

@@ -10,3 +10,3 @@ "use strict";

exports.nullReporter = void 0;
var _chalk = _interopRequireDefault(require("chalk"));
var _tty = _interopRequireDefault(require("tty"));
var _util = _interopRequireDefault(require("util"));

@@ -16,5 +16,12 @@ function _interopRequireDefault(e) {

}
const supportsColor = () =>
process.stdout instanceof _tty.default.WriteStream &&
process.stdout.hasColors();
function logWarning(terminal, format, ...args) {
const str = _util.default.format(format, ...args);
terminal.log("%s %s", _chalk.default.yellow.inverse.bold(" WARN "), str);
terminal.log(
"%s %s",
_util.default.styleText(["yellow", "inverse", "bold"], " WARN "),
str,
);
}

@@ -24,7 +31,5 @@ function logError(terminal, format, ...args) {

"%s %s",
_chalk.default.red.inverse.bold(" ERROR "),
_util.default.styleText(["red", "inverse", "bold"], " ERROR "),
_util.default.format(
_chalk.default.supportsColor
? format
: _util.default.stripVTControlCharacters(format),
supportsColor() ? format : _util.default.stripVTControlCharacters(format),
...args,

@@ -36,3 +41,7 @@ ),

const str = _util.default.format(format, ...args);
terminal.log("%s %s", _chalk.default.cyan.inverse.bold(" INFO "), str);
terminal.log(
"%s %s",
_util.default.styleText(["cyan", "inverse", "bold"], " INFO "),
str,
);
}

@@ -39,0 +48,0 @@ const nullReporter = (exports.nullReporter = {

@@ -10,6 +10,6 @@ "use strict";

var reporting = _interopRequireWildcard(require("./reporting"));
var _chalk = _interopRequireDefault(require("chalk"));
var _lodash = _interopRequireDefault(require("lodash.throttle"));
var _metroCore = require("metro-core");
var _path = _interopRequireDefault(require("path"));
var _util = _interopRequireDefault(require("util"));
function _interopRequireWildcard(e, t) {

@@ -45,2 +45,3 @@ if ("function" == typeof WeakMap)

}
const style = (format, text) => _util.default.styleText(format, text);
const DARK_BLOCK_CHAR = "\u2593";

@@ -73,22 +74,20 @@ const LIGHT_BLOCK_CHAR = "\u2591";

const bundleTypeColor =
phase === "done"
? _chalk.default.green
: phase === "failed"
? _chalk.default.red
: _chalk.default.yellow;
phase === "done" ? ["green"] : phase === "failed" ? ["red"] : ["yellow"];
const progress =
phase === "in_progress"
? _chalk.default.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +
_chalk.default.bgWhite.white(
? style(["green", "bgGreen"], DARK_BLOCK_CHAR.repeat(filledBar)) +
style(
["bgWhite", "white"],
LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar),
) +
_chalk.default.bold(` ${Math.floor(100 * ratio)}% `) +
_chalk.default.dim(`(${transformedFileCount}/${totalFileCount})`)
style(["bold"], ` ${Math.floor(100 * ratio)}% `) +
style(["dim"], `(${transformedFileCount}/${totalFileCount})`)
: "";
return (
bundleTypeColor.inverse.bold(
style(
[...bundleTypeColor, "inverse", "bold"],
` ${isPrefetch === true ? "PREBUNDLE" : bundleType.toUpperCase()} `,
) +
_chalk.default.reset.dim(` ${_path.default.dirname(localPath)}/`) +
_chalk.default.bold(_path.default.basename(localPath)) +
style(["reset", "dim"], ` ${_path.default.dirname(localPath)}/`) +
style(["bold"], _path.default.basename(localPath)) +
" " +

@@ -138,6 +137,4 @@ progress

];
const color = hasReducedPerformance
? _chalk.default.red
: _chalk.default.blue;
this.terminal.log(color(logo.join("\n")));
const color = hasReducedPerformance ? ["red"] : ["blue"];
this.terminal.log(style(color, logo.join("\n")));
}

@@ -147,6 +144,6 @@ _logInitializingFailed(port, error) {

this.terminal.log(
_chalk.default.bgRed.bold(" ERROR "),
_chalk.default.red(
"Metro can't listen on port",
_chalk.default.bold(String(port)),
style(["bgRed", "bold"], " ERROR "),
style(
["red"],
`Metro can't listen on port ${style(["bold"], String(port))}`,
),

@@ -158,16 +155,16 @@ );

this.terminal.log("Run the following command to find out which process:");
this.terminal.log("\n ", _chalk.default.bold("lsof -i :" + port), "\n");
this.terminal.log("\n ", style(["bold"], "lsof -i :" + port), "\n");
this.terminal.log("Then, you can either shut down the other process:");
this.terminal.log("\n ", _chalk.default.bold("kill -9 <PID>"), "\n");
this.terminal.log("\n ", style(["bold"], "kill -9 <PID>"), "\n");
this.terminal.log("or run Metro on different port.");
} else {
this.terminal.log(
_chalk.default.bgRed.bold(" ERROR "),
_chalk.default.red(error.message),
style(["bgRed", "bold"], " ERROR "),
style(["red"], error.message),
);
const errorAttributes = JSON.stringify(error);
if (errorAttributes !== "{}") {
this.terminal.log(_chalk.default.red(errorAttributes));
this.terminal.log(style(["red"], errorAttributes));
}
this.terminal.log(_chalk.default.red(error.stack));
this.terminal.log(style(["red"], String(error.stack)));
}

@@ -223,18 +220,17 @@ }

case "dep_graph_loading":
const color = event.hasReducedPerformance
? _chalk.default.red
: _chalk.default.blue;
const color = event.hasReducedPerformance ? ["red"] : ["blue"];
const version = "v" + require("../../package.json").version;
this.terminal.log(
color.bold(
" ".repeat(19 - version.length / 2),
"Welcome to Metro " + _chalk.default.white(version) + "\n",
) +
_chalk.default.dim(
" Fast - Scalable - Integrated\n\n",
),
style(
[...color, "bold"],
" ".repeat(19 - version.length / 2) +
" Welcome to Metro " +
style(["white"], version) +
"\n",
) + style(["dim"], " Fast - Scalable - Integrated\n\n"),
);
if (event.hasReducedPerformance) {
this.terminal.log(
_chalk.default.red(
style(
["red"],
"Metro is operating with reduced performance.\n" +

@@ -370,3 +366,3 @@ "Please fix the problem above and restart Metro.\n\n",

this.terminal.log(
_chalk.default.green(`Watcher ${watcherName} is now healthy.`),
style(["green"], `Watcher ${watcherName} is now healthy.`),
);

@@ -410,3 +406,4 @@ }

this.terminal.log(
_chalk.default.dim(
style(
["dim"],
`Waiting for Watchman \`${status.command}\` (${Math.round(status.timeElapsed / 1000)}s)...`,

@@ -418,3 +415,4 @@ ),

this.terminal.log(
_chalk.default.green(
style(
["green"],
`Watchman \`${status.command}\` finished after ${(status.timeElapsed / 1000).toFixed(1)}s.`,

@@ -421,0 +419,0 @@ ),

@@ -408,2 +408,5 @@ "use strict";

}
if (isInPromiseChainWithRejectionHandler(path)) {
return true;
}
let sCount = 0;

@@ -426,2 +429,51 @@ let p = path;

}
function isInPromiseChainWithRejectionHandler(path) {
let current = path;
while (current.parentPath != null) {
const member = current.parentPath;
if (
member.node.type !== "MemberExpression" ||
member.node.object !== current.node ||
member.node.computed ||
member.node.property.type !== "Identifier" ||
member.parentPath == null
) {
return false;
}
const call = member.parentPath;
if (
call.node.type !== "CallExpression" ||
call.node.callee !== member.node
) {
return false;
}
const propertyName = member.node.property.name;
const args = call.node.arguments;
if (
propertyName === "catch" &&
args.length >= 1 &&
isNonNullishCallbackArg(args[0])
) {
return true;
}
if (
propertyName === "then" &&
args.length >= 2 &&
isNonNullishCallbackArg(args[1])
) {
return true;
}
current = call;
}
return false;
}
function isNonNullishCallbackArg(arg) {
if (arg.type === "NullLiteral") {
return false;
}
if (arg.type === "Identifier" && arg.name === "undefined") {
return false;
}
return true;
}
function getModuleNameFromCallArgs(path) {

@@ -428,0 +480,0 @@ const args = path.get("arguments");

@@ -83,3 +83,2 @@ "use strict";

computeDependencies: true,
rootDir: config.projectRoot,
});

@@ -86,0 +85,0 @@ plugins.push(dependencyPlugin);

@@ -9,3 +9,3 @@ /**

* @oncall react_native
* @generated SignedSource<<161e77301d04ce6cc254f1dbf15ef06b>>
* @generated SignedSource<<03b526801403adb05b3b0f6c25b25ed5>>
*

@@ -229,2 +229,5 @@ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js

): Promise<ExplodedSourceMap>;
_resolveWatchFolderPrefix(
filePath: string,
): {rootDir: string; filePath: string} | null;
_resolveRelativePath(

@@ -231,0 +234,0 @@ filePath: string,

@@ -1350,2 +1350,31 @@ "use strict";

}
_resolveWatchFolderPrefix(filePath) {
const watchFolderMatch = filePath.match(
/^\.\/\[metro-watchFolders\]\/(\d+)\/(.*)/,
);
if (watchFolderMatch != null) {
const index = parseInt(watchFolderMatch[1], 10);
const watchFolder = this._config.watchFolders[index];
if (watchFolder != null) {
return {
rootDir: _path.default.resolve(watchFolder),
filePath:
"." +
_path.default.sep +
watchFolderMatch[2].split("/").join(_path.default.sep),
};
}
}
const projectMatch = filePath.match(/^\.\/\[metro-project\]\/(.*)/);
if (projectMatch != null) {
return {
rootDir: _path.default.resolve(this._config.projectRoot),
filePath:
"." +
_path.default.sep +
projectMatch[1].split("/").join(_path.default.sep),
};
}
return null;
}
async _resolveRelativePath(

@@ -1360,10 +1389,14 @@ filePath,

);
const resolved = this._resolveWatchFolderPrefix(filePath);
const rootDir =
relativeTo === "server"
? this._getServerRootDir()
: this._config.projectRoot;
resolved != null
? resolved.rootDir
: relativeTo === "server"
? this._getServerRootDir()
: this._config.projectRoot;
const resolvedFilePath = resolved != null ? resolved.filePath : filePath;
return resolutionFn(`${rootDir}/.`, {
name: filePath,
name: resolvedFilePath,
data: {
key: filePath,
key: resolvedFilePath,
locs: [],

@@ -1408,2 +1441,6 @@ asyncType: null,

_getEntryPointAbsolutePath(entryFile) {
const resolved = this._resolveWatchFolderPrefix(entryFile);
if (resolved != null) {
return _path.default.resolve(resolved.rootDir, resolved.filePath);
}
return _path.default.resolve(this._getServerRootDir(), entryFile);

@@ -1410,0 +1447,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet