@arms/rum-bundler-plugin-core
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -448,2 +448,6 @@ (function (global, factory) { | ||
function isValidUUID(uuid) { | ||
var UUID_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/; | ||
return UUID_REGEX.test(uuid); | ||
} | ||
function generateUUID() { | ||
@@ -478,3 +482,3 @@ return generateGUID(); | ||
var SUPPORT_EXTENSIONS = ['.js', '.cjs', '.mjs']; | ||
function handleUUIDInjection(_x, _x2, _x3) { | ||
function handleUUIDInjection(_x, _x2, _x3, _x4) { | ||
return _handleUUIDInjection.apply(this, arguments); | ||
@@ -490,3 +494,3 @@ } | ||
function _handleUUIDInjection() { | ||
_handleUUIDInjection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(bundlePaths, logger, bundleToolType) { | ||
_handleUUIDInjection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(bundlePaths, logger, bundleToolType, uuidManual) { | ||
var successCount, failedCount, sourceMapCount, sourceFilePaths, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, sourceFilePath, sourceFileContent, sourceMapPath, uuid, totalFiles; | ||
@@ -511,3 +515,3 @@ return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) { | ||
_context.next = 38; | ||
_context.next = 39; | ||
break; | ||
@@ -526,73 +530,77 @@ } | ||
if (sourceMapPath) { | ||
_context.next = 21; | ||
sourceMapCount++; | ||
} | ||
// 注入 UUID | ||
uuid = getExsitingUUID(sourceFileContent); | ||
if (uuid) { | ||
_context.next = 25; | ||
break; | ||
} | ||
return _context.abrupt("continue", 35); | ||
case 21: | ||
sourceMapCount++; | ||
// 注入 UUID | ||
uuid = getExsitingUUID(sourceFileContent) || generateUUID(); | ||
uuid = isValidUUID(uuidManual) ? uuidManual : generateUUID(); | ||
_context.next = 25; | ||
return injectUUIDIntoSourceFile(sourceFileContent, sourceFilePath, uuid, bundleToolType); | ||
case 25: | ||
_context.next = 27; | ||
if (!sourceMapPath) { | ||
_context.next = 28; | ||
break; | ||
} | ||
_context.next = 28; | ||
return injectUUIDIntoSourceMap(sourceMapPath, uuid); | ||
case 27: | ||
case 28: | ||
successCount++; | ||
_context.next = 35; | ||
_context.next = 36; | ||
break; | ||
case 30: | ||
_context.prev = 30; | ||
case 31: | ||
_context.prev = 31; | ||
_context.t0 = _context["catch"](12); | ||
logger.error(_context.t0.message); | ||
failedCount++; | ||
return _context.abrupt("continue", 35); | ||
case 35: | ||
return _context.abrupt("continue", 36); | ||
case 36: | ||
_iteratorAbruptCompletion = false; | ||
_context.next = 8; | ||
break; | ||
case 38: | ||
_context.next = 44; | ||
case 39: | ||
_context.next = 45; | ||
break; | ||
case 40: | ||
_context.prev = 40; | ||
case 41: | ||
_context.prev = 41; | ||
_context.t1 = _context["catch"](6); | ||
_didIteratorError = true; | ||
_iteratorError = _context.t1; | ||
case 44: | ||
_context.prev = 44; | ||
case 45: | ||
_context.prev = 45; | ||
_context.prev = 46; | ||
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) { | ||
_context.next = 49; | ||
_context.next = 50; | ||
break; | ||
} | ||
_context.next = 49; | ||
_context.next = 50; | ||
return _iterator["return"](); | ||
case 49: | ||
_context.prev = 49; | ||
case 50: | ||
_context.prev = 50; | ||
if (!_didIteratorError) { | ||
_context.next = 52; | ||
_context.next = 53; | ||
break; | ||
} | ||
throw _iteratorError; | ||
case 52: | ||
return _context.finish(49); | ||
case 53: | ||
return _context.finish(44); | ||
return _context.finish(50); | ||
case 54: | ||
return _context.finish(45); | ||
case 55: | ||
if (!sourceMapCount) { | ||
logger.warn('No source maps found for the bundle. Please ensure that source map generation is enabled in your bundler configuration'); | ||
} else { | ||
totalFiles = successCount + failedCount; | ||
logger.info("UUID Injection Update: ".concat(successCount, " successes, ").concat(failedCount, " failures. Total files processed: ").concat(totalFiles)); | ||
} | ||
case 55: | ||
totalFiles = successCount + failedCount; | ||
logger.info("UUID Injection Update: ".concat(successCount, " successes, ").concat(failedCount, " failures. Total files processed: ").concat(totalFiles)); | ||
case 58: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, null, [[6, 40, 44, 54], [12, 30], [45,, 49, 53]]); | ||
}, _callee, null, [[6, 41, 45, 55], [12, 31], [46,, 50, 54]]); | ||
})); | ||
return _handleUUIDInjection.apply(this, arguments); | ||
} | ||
function findSourceMapPath(_x4, _x5, _x6) { | ||
function findSourceMapPath(_x5, _x6, _x7) { | ||
return _findSourceMapPath.apply(this, arguments); | ||
@@ -659,5 +667,5 @@ } | ||
} | ||
var debugIdUUIDMatch = sourceFileContent.match(/\/\/# debugId=([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/); | ||
if (debugIdUUIDMatch) { | ||
return debugIdUUIDMatch[1]; | ||
var rumUUIDMatch = sourceFileContent.match(/armsRum-uuid-([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/); | ||
if (rumUUIDMatch) { | ||
return rumUUIDMatch[1]; | ||
} | ||
@@ -673,3 +681,3 @@ return ''; | ||
*/ | ||
function injectUUIDIntoSourceFile(_x7, _x8, _x9, _x10) { | ||
function injectUUIDIntoSourceFile(_x8, _x9, _x10, _x11) { | ||
return _injectUUIDIntoSourceFile.apply(this, arguments); | ||
@@ -716,3 +724,3 @@ } | ||
} | ||
function injectUUIDIntoSourceMap(_x11, _x12) { | ||
function injectUUIDIntoSourceMap(_x12, _x13) { | ||
return _injectUUIDIntoSourceMap.apply(this, arguments); | ||
@@ -758,5 +766,7 @@ } | ||
_ref$debug = _ref.debug, | ||
debug = _ref$debug === void 0 ? true : _ref$debug; | ||
debug = _ref$debug === void 0 ? true : _ref$debug, | ||
_ref$uuid = _ref.uuid, | ||
uuid = _ref$uuid === void 0 ? '' : _ref$uuid; | ||
var logger = createLogger({ | ||
debug: debug, | ||
enable: debug, | ||
prefix: 'ARMS RUM' | ||
@@ -767,3 +777,3 @@ }); | ||
plugins.push(UUIDInjectionPlugin(function (bundlePaths) { | ||
return handleUUIDInjection(bundlePaths, logger, bundleToolType); | ||
return handleUUIDInjection(bundlePaths, logger, bundleToolType, uuid); | ||
})); | ||
@@ -770,0 +780,0 @@ return plugins; |
{ | ||
"name": "@arms/rum-bundler-plugin-core", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "rum bundler plugin core", | ||
@@ -36,2 +36,2 @@ "author": "ly403664 <ly403664@alibaba-inc.com>", | ||
} | ||
} | ||
} |
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
31205
772