systraceProfileMiddleware.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = systraceProfileMiddleware;
  6. function _fs() {
  7. const data = _interopRequireDefault(require("fs"));
  8. _fs = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _cliTools() {
  14. const data = require("@react-native-community/cli-tools");
  15. _cliTools = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21. /**
  22. * Copyright (c) Facebook, Inc. and its affiliates.
  23. *
  24. * This source code is licensed under the MIT license found in the
  25. * LICENSE file in the root directory of this source tree.
  26. */
  27. function systraceProfileMiddleware(req, res) {
  28. _cliTools().logger.info('Dumping profile information...');
  29. const dumpName = `/tmp/dump_${Date.now()}.json`;
  30. _fs().default.writeFileSync(dumpName, req.rawBody);
  31. const response = `Your profile was saved at:\n${dumpName}\n\n` + 'On Google Chrome navigate to chrome://tracing and then click on "load" ' + 'to load and visualise your profile.\n\n' + 'This message is also printed to your console by the packager so you can copy it :)';
  32. _cliTools().logger.info(response);
  33. res.end(response);
  34. }
  35. //# sourceMappingURL=systraceProfileMiddleware.js.map