src-WRIQ2NEL.mjs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import "./chunk-ZKNUHGJ4.mjs";
  2. // node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/walker.js
  3. var WalkerBase = class {
  4. constructor() {
  5. this.should_skip = false;
  6. this.should_remove = false;
  7. this.replacement = null;
  8. this.context = {
  9. skip: () => this.should_skip = true,
  10. remove: () => this.should_remove = true,
  11. replace: (node) => this.replacement = node
  12. };
  13. }
  14. replace(parent, prop, index, node) {
  15. if (parent) {
  16. if (index !== null) {
  17. parent[prop][index] = node;
  18. } else {
  19. parent[prop] = node;
  20. }
  21. }
  22. }
  23. remove(parent, prop, index) {
  24. if (parent) {
  25. if (index !== null) {
  26. parent[prop].splice(index, 1);
  27. } else {
  28. delete parent[prop];
  29. }
  30. }
  31. }
  32. };
  33. // node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/sync.js
  34. var SyncWalker = class extends WalkerBase {
  35. constructor(enter, leave) {
  36. super();
  37. this.enter = enter;
  38. this.leave = leave;
  39. }
  40. visit(node, parent, prop, index) {
  41. if (node) {
  42. if (this.enter) {
  43. const _should_skip = this.should_skip;
  44. const _should_remove = this.should_remove;
  45. const _replacement = this.replacement;
  46. this.should_skip = false;
  47. this.should_remove = false;
  48. this.replacement = null;
  49. this.enter.call(this.context, node, parent, prop, index);
  50. if (this.replacement) {
  51. node = this.replacement;
  52. this.replace(parent, prop, index, node);
  53. }
  54. if (this.should_remove) {
  55. this.remove(parent, prop, index);
  56. }
  57. const skipped = this.should_skip;
  58. const removed = this.should_remove;
  59. this.should_skip = _should_skip;
  60. this.should_remove = _should_remove;
  61. this.replacement = _replacement;
  62. if (skipped)
  63. return node;
  64. if (removed)
  65. return null;
  66. }
  67. for (const key in node) {
  68. const value = node[key];
  69. if (typeof value !== "object") {
  70. continue;
  71. } else if (Array.isArray(value)) {
  72. for (let i = 0; i < value.length; i += 1) {
  73. if (value[i] !== null && typeof value[i].type === "string") {
  74. if (!this.visit(value[i], node, key, i)) {
  75. i--;
  76. }
  77. }
  78. }
  79. } else if (value !== null && typeof value.type === "string") {
  80. this.visit(value, node, key, null);
  81. }
  82. }
  83. if (this.leave) {
  84. const _replacement = this.replacement;
  85. const _should_remove = this.should_remove;
  86. this.replacement = null;
  87. this.should_remove = false;
  88. this.leave.call(this.context, node, parent, prop, index);
  89. if (this.replacement) {
  90. node = this.replacement;
  91. this.replace(parent, prop, index, node);
  92. }
  93. if (this.should_remove) {
  94. this.remove(parent, prop, index);
  95. }
  96. const removed = this.should_remove;
  97. this.replacement = _replacement;
  98. this.should_remove = _should_remove;
  99. if (removed)
  100. return null;
  101. }
  102. }
  103. return node;
  104. }
  105. };
  106. // node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/async.js
  107. var AsyncWalker = class extends WalkerBase {
  108. constructor(enter, leave) {
  109. super();
  110. this.enter = enter;
  111. this.leave = leave;
  112. }
  113. async visit(node, parent, prop, index) {
  114. if (node) {
  115. if (this.enter) {
  116. const _should_skip = this.should_skip;
  117. const _should_remove = this.should_remove;
  118. const _replacement = this.replacement;
  119. this.should_skip = false;
  120. this.should_remove = false;
  121. this.replacement = null;
  122. await this.enter.call(this.context, node, parent, prop, index);
  123. if (this.replacement) {
  124. node = this.replacement;
  125. this.replace(parent, prop, index, node);
  126. }
  127. if (this.should_remove) {
  128. this.remove(parent, prop, index);
  129. }
  130. const skipped = this.should_skip;
  131. const removed = this.should_remove;
  132. this.should_skip = _should_skip;
  133. this.should_remove = _should_remove;
  134. this.replacement = _replacement;
  135. if (skipped)
  136. return node;
  137. if (removed)
  138. return null;
  139. }
  140. for (const key in node) {
  141. const value = node[key];
  142. if (typeof value !== "object") {
  143. continue;
  144. } else if (Array.isArray(value)) {
  145. for (let i = 0; i < value.length; i += 1) {
  146. if (value[i] !== null && typeof value[i].type === "string") {
  147. if (!await this.visit(value[i], node, key, i)) {
  148. i--;
  149. }
  150. }
  151. }
  152. } else if (value !== null && typeof value.type === "string") {
  153. await this.visit(value, node, key, null);
  154. }
  155. }
  156. if (this.leave) {
  157. const _replacement = this.replacement;
  158. const _should_remove = this.should_remove;
  159. this.replacement = null;
  160. this.should_remove = false;
  161. await this.leave.call(this.context, node, parent, prop, index);
  162. if (this.replacement) {
  163. node = this.replacement;
  164. this.replace(parent, prop, index, node);
  165. }
  166. if (this.should_remove) {
  167. this.remove(parent, prop, index);
  168. }
  169. const removed = this.should_remove;
  170. this.replacement = _replacement;
  171. this.should_remove = _should_remove;
  172. if (removed)
  173. return null;
  174. }
  175. }
  176. return node;
  177. }
  178. };
  179. // node_modules/.pnpm/estree-walker@3.0.1/node_modules/estree-walker/src/index.js
  180. function walk(ast, { enter, leave }) {
  181. const instance = new SyncWalker(enter, leave);
  182. return instance.visit(ast, null);
  183. }
  184. async function asyncWalk(ast, { enter, leave }) {
  185. const instance = new AsyncWalker(enter, leave);
  186. return await instance.visit(ast, null);
  187. }
  188. export {
  189. asyncWalk,
  190. walk
  191. };