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.

index.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.run = run;
  6. function _traverse() {
  7. const data = require("@babel/traverse");
  8. _traverse = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. var _pluginPass = require("./plugin-pass");
  14. var _blockHoistPlugin = require("./block-hoist-plugin");
  15. var _normalizeOpts = require("./normalize-opts");
  16. var _normalizeFile = require("./normalize-file");
  17. var _generate = require("./file/generate");
  18. function* run(config, code, ast) {
  19. const file = yield* (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast);
  20. const opts = file.opts;
  21. try {
  22. yield* transformFile(file, config.passes);
  23. } catch (e) {
  24. var _opts$filename;
  25. e.message = `${(_opts$filename = opts.filename) != null ? _opts$filename : "unknown"}: ${e.message}`;
  26. if (!e.code) {
  27. e.code = "BABEL_TRANSFORM_ERROR";
  28. }
  29. throw e;
  30. }
  31. let outputCode, outputMap;
  32. try {
  33. if (opts.code !== false) {
  34. ({
  35. outputCode,
  36. outputMap
  37. } = (0, _generate.default)(config.passes, file));
  38. }
  39. } catch (e) {
  40. var _opts$filename2;
  41. e.message = `${(_opts$filename2 = opts.filename) != null ? _opts$filename2 : "unknown"}: ${e.message}`;
  42. if (!e.code) {
  43. e.code = "BABEL_GENERATE_ERROR";
  44. }
  45. throw e;
  46. }
  47. return {
  48. metadata: file.metadata,
  49. options: opts,
  50. ast: opts.ast === true ? file.ast : null,
  51. code: outputCode === undefined ? null : outputCode,
  52. map: outputMap === undefined ? null : outputMap,
  53. sourceType: file.ast.program.sourceType
  54. };
  55. }
  56. function* transformFile(file, pluginPasses) {
  57. for (const pluginPairs of pluginPasses) {
  58. const passPairs = [];
  59. const passes = [];
  60. const visitors = [];
  61. for (const plugin of pluginPairs.concat([(0, _blockHoistPlugin.default)()])) {
  62. const pass = new _pluginPass.default(file, plugin.key, plugin.options);
  63. passPairs.push([plugin, pass]);
  64. passes.push(pass);
  65. visitors.push(plugin.visitor);
  66. }
  67. for (const [plugin, pass] of passPairs) {
  68. const fn = plugin.pre;
  69. if (fn) {
  70. const result = fn.call(pass, file);
  71. yield* [];
  72. if (isThenable(result)) {
  73. throw new Error(`You appear to be using an plugin with an async .pre, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
  74. }
  75. }
  76. }
  77. const visitor = _traverse().default.visitors.merge(visitors, passes, file.opts.wrapPluginVisitorMethod);
  78. (0, _traverse().default)(file.ast, visitor, file.scope);
  79. for (const [plugin, pass] of passPairs) {
  80. const fn = plugin.post;
  81. if (fn) {
  82. const result = fn.call(pass, file);
  83. yield* [];
  84. if (isThenable(result)) {
  85. throw new Error(`You appear to be using an plugin with an async .post, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
  86. }
  87. }
  88. }
  89. }
  90. }
  91. function isThenable(val) {
  92. return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function";
  93. }