metro-runtime
Advanced tools
Comparing version 0.64.0 to 0.65.0
{ | ||
"name": "metro-runtime", | ||
"version": "0.64.0", | ||
"version": "0.65.0", | ||
"description": "🚇 Module required for evaluating Metro bundles.", | ||
@@ -5,0 +5,0 @@ "main": "src", |
@@ -12,95 +12,7 @@ /** | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _slicedToArray(arr, i) { | ||
return ( | ||
_arrayWithHoles(arr) || | ||
_iterableToArrayLimit(arr, i) || | ||
_unsupportedIterableToArray(arr, i) || | ||
_nonIterableRest() | ||
); | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError( | ||
"Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." | ||
); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) | ||
return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) | ||
return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for ( | ||
var _i = arr[Symbol.iterator](), _s; | ||
!(_n = (_s = _i.next()).done); | ||
_n = true | ||
) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
const EventEmitter = require("./vendor/eventemitter3"); | ||
const inject = _ref => { | ||
let _ref$module = _slicedToArray(_ref.module, 2), | ||
id = _ref$module[0], | ||
code = _ref$module[1], | ||
sourceURL = _ref.sourceURL; // Some engines do not support `sourceURL` as a comment. We expose a | ||
const inject = ({ module: [id, code], sourceURL }) => { | ||
// Some engines do not support `sourceURL` as a comment. We expose a | ||
// `globalEvalWithSourceUrl` function to handle updates in that case. | ||
if (global.globalEvalWithSourceUrl) { | ||
@@ -120,2 +32,7 @@ global.globalEvalWithSourceUrl(code, sourceURL); | ||
class HMRClient extends EventEmitter { | ||
_isEnabled = false; | ||
_pendingUpdate = null; | ||
_queue = []; | ||
_state = "opening"; | ||
constructor(url) { | ||
@@ -125,10 +42,2 @@ super(); // Access the global WebSocket object only after enabling the client, | ||
_defineProperty(this, "_isEnabled", false); | ||
_defineProperty(this, "_pendingUpdate", null); | ||
_defineProperty(this, "_queue", []); | ||
_defineProperty(this, "_state", "opening"); | ||
this._ws = new global.WebSocket(url); | ||
@@ -135,0 +44,0 @@ |
@@ -22,4 +22,3 @@ /** | ||
const EMPTY = {}; | ||
const _ref = {}, | ||
hasOwnProperty = _ref.hasOwnProperty; | ||
const { hasOwnProperty } = {}; | ||
@@ -285,6 +284,3 @@ if (__DEV__) { | ||
if (!module && nativeRequire) { | ||
const _unpackModuleId = unpackModuleId(moduleId), | ||
segmentId = _unpackModuleId.segmentId, | ||
localId = _unpackModuleId.localId; | ||
const { segmentId, localId } = unpackModuleId(moduleId); | ||
nativeRequire(localId, segmentId); | ||
@@ -300,11 +296,7 @@ module = modules[moduleId]; | ||
throw moduleThrewError(moduleId, module.error); | ||
} // `metroRequire` calls into the require polyfill itself are not analyzed and | ||
// replaced so that they use numeric module IDs. | ||
// The systrace module will expose itself on the metroRequire function so that | ||
// it can be used here. | ||
// TODO(t9759686) Scan polyfills for dependencies, too | ||
} | ||
if (__DEV__) { | ||
var Systrace = metroRequire.Systrace, | ||
Refresh = metroRequire.Refresh; | ||
var Systrace = requireSystrace(); | ||
var Refresh = requireRefresh(); | ||
} // We must optimistically mark module as initialized before running the | ||
@@ -315,5 +307,3 @@ // factory to keep any require cycles inside the factory from causing an | ||
module.isInitialized = true; | ||
const _module = module, | ||
factory = _module.factory, | ||
dependencyMap = _module.dependencyMap; | ||
const { factory, dependencyMap } = module; | ||
@@ -326,3 +316,3 @@ if (__DEV__) { | ||
if (__DEV__) { | ||
// $FlowFixMe: we know that __DEV__ is const and `Systrace` exists | ||
// $FlowIgnore: we know that __DEV__ is const and `Systrace` exists | ||
Systrace.beginEvent("JS_require_" + (module.verboseName || moduleId)); | ||
@@ -371,3 +361,3 @@ } | ||
if (__DEV__) { | ||
// $FlowFixMe: we know that __DEV__ is const and `Systrace` exists | ||
// $FlowIgnore: we know that __DEV__ is const and `Systrace` exists | ||
Systrace.endEvent(); | ||
@@ -473,3 +463,3 @@ | ||
const Refresh = metroRequire.Refresh; | ||
const Refresh = requireRefresh(); | ||
const refreshBoundaryIDs = new Set(); // In this loop, we will traverse the dependency tree upwards from the | ||
@@ -705,3 +695,3 @@ // changed module. Updates "bubble" up to the closest accepted parent. | ||
const hot = mod.hot; | ||
const { hot } = mod; | ||
@@ -781,4 +771,3 @@ if (!hot) { | ||
} else { | ||
// This is attached in setUpDeveloperTools. | ||
const Refresh = metroRequire.Refresh; | ||
const Refresh = requireRefresh(); | ||
@@ -930,1 +919,20 @@ if (Refresh != null) { | ||
} | ||
if (__DEV__) { | ||
// The metro require polyfill can not have module dependencies. | ||
// The Systrace and ReactRefresh dependencies are, therefore, made publicly | ||
// available. Ideally, the dependency would be inversed in a way that | ||
// Systrace / ReactRefresh could integrate into Metro rather than | ||
// having to make them publicly available. | ||
var requireSystrace = function requireSystrace() { | ||
return ( | ||
global[__METRO_GLOBAL_PREFIX__ + "__SYSTRACE"] || metroRequire.Systrace | ||
); | ||
}; | ||
var requireRefresh = function requireRefresh() { | ||
return ( | ||
global[__METRO_GLOBAL_PREFIX__ + "__ReactRefresh"] || metroRequire.Refresh | ||
); | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79422
1284