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 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "NodePath", {
  6. enumerable: true,
  7. get: function () {
  8. return _path.default;
  9. }
  10. });
  11. Object.defineProperty(exports, "Scope", {
  12. enumerable: true,
  13. get: function () {
  14. return _scope.default;
  15. }
  16. });
  17. Object.defineProperty(exports, "Hub", {
  18. enumerable: true,
  19. get: function () {
  20. return _hub.default;
  21. }
  22. });
  23. exports.visitors = exports.default = void 0;
  24. var _context = require("./context");
  25. var visitors = require("./visitors");
  26. exports.visitors = visitors;
  27. var t = require("@babel/types");
  28. var cache = require("./cache");
  29. var _path = require("./path");
  30. var _scope = require("./scope");
  31. var _hub = require("./hub");
  32. function traverse(parent, opts = {}, scope, state, parentPath) {
  33. if (!parent) return;
  34. if (!opts.noScope && !scope) {
  35. if (parent.type !== "Program" && parent.type !== "File") {
  36. throw new Error("You must pass a scope and parentPath unless traversing a Program/File. " + `Instead of that you tried to traverse a ${parent.type} node without ` + "passing scope and parentPath.");
  37. }
  38. }
  39. if (!t.VISITOR_KEYS[parent.type]) {
  40. return;
  41. }
  42. visitors.explode(opts);
  43. traverse.node(parent, opts, scope, state, parentPath);
  44. }
  45. var _default = traverse;
  46. exports.default = _default;
  47. traverse.visitors = visitors;
  48. traverse.verify = visitors.verify;
  49. traverse.explode = visitors.explode;
  50. traverse.cheap = function (node, enter) {
  51. return t.traverseFast(node, enter);
  52. };
  53. traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
  54. const keys = t.VISITOR_KEYS[node.type];
  55. if (!keys) return;
  56. const context = new _context.default(scope, opts, state, parentPath);
  57. for (const key of keys) {
  58. if (skipKeys && skipKeys[key]) continue;
  59. if (context.visit(node, key)) return;
  60. }
  61. };
  62. traverse.clearNode = function (node, opts) {
  63. t.removeProperties(node, opts);
  64. cache.path.delete(node);
  65. };
  66. traverse.removeProperties = function (tree, opts) {
  67. t.traverseFast(tree, traverse.clearNode, opts);
  68. return tree;
  69. };
  70. function hasDenylistedType(path, state) {
  71. if (path.node.type === state.type) {
  72. state.has = true;
  73. path.stop();
  74. }
  75. }
  76. traverse.hasType = function (tree, type, denylistTypes) {
  77. if (denylistTypes != null && denylistTypes.includes(tree.type)) return false;
  78. if (tree.type === type) return true;
  79. const state = {
  80. has: false,
  81. type: type
  82. };
  83. traverse(tree, {
  84. noScope: true,
  85. denylist: denylistTypes,
  86. enter: hasDenylistedType
  87. }, null, state);
  88. return state.has;
  89. };
  90. traverse.cache = cache;