Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

getCallsite.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _callsites() {
  7. const data = _interopRequireDefault(require('callsites'));
  8. _callsites = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _gracefulFs() {
  14. const data = require('graceful-fs');
  15. _gracefulFs = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _sourceMap() {
  21. const data = require('source-map');
  22. _sourceMap = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _interopRequireDefault(obj) {
  28. return obj && obj.__esModule ? obj : {default: obj};
  29. }
  30. /**
  31. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  32. *
  33. * This source code is licensed under the MIT license found in the
  34. * LICENSE file in the root directory of this source tree.
  35. */
  36. // Copied from https://github.com/rexxars/sourcemap-decorate-callsites/blob/5b9735a156964973a75dc62fd2c7f0c1975458e8/lib/index.js#L113-L158
  37. const addSourceMapConsumer = (callsite, consumer) => {
  38. const getLineNumber = callsite.getLineNumber;
  39. const getColumnNumber = callsite.getColumnNumber;
  40. let position = null;
  41. function getPosition() {
  42. if (!position) {
  43. position = consumer.originalPositionFor({
  44. column: getColumnNumber.call(callsite) || -1,
  45. line: getLineNumber.call(callsite) || -1
  46. });
  47. }
  48. return position;
  49. }
  50. Object.defineProperties(callsite, {
  51. getColumnNumber: {
  52. value() {
  53. return getPosition().column || getColumnNumber.call(callsite);
  54. },
  55. writable: false
  56. },
  57. getLineNumber: {
  58. value() {
  59. return getPosition().line || getLineNumber.call(callsite);
  60. },
  61. writable: false
  62. }
  63. });
  64. };
  65. var _default = (level, sourceMaps) => {
  66. const levelAfterThisCall = level + 1;
  67. const stack = (0, _callsites().default)()[levelAfterThisCall];
  68. const sourceMapFileName =
  69. sourceMaps === null || sourceMaps === void 0
  70. ? void 0
  71. : sourceMaps.get(stack.getFileName() || '');
  72. if (sourceMapFileName) {
  73. try {
  74. const sourceMap = (0, _gracefulFs().readFileSync)(
  75. sourceMapFileName,
  76. 'utf8'
  77. ); // @ts-expect-error: Not allowed to pass string
  78. addSourceMapConsumer(
  79. stack,
  80. new (_sourceMap().SourceMapConsumer)(sourceMap)
  81. );
  82. } catch {
  83. // ignore
  84. }
  85. }
  86. return stack;
  87. };
  88. exports.default = _default;