src-WIQNDB4Q.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-5JVO2UWC.js');
  2. // node_modules/.pnpm/estree-walker@3.0.3/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. /**
  15. * @template {Node} Parent
  16. * @param {Parent | null | undefined} parent
  17. * @param {keyof Parent | null | undefined} prop
  18. * @param {number | null | undefined} index
  19. * @param {Node} node
  20. */
  21. replace(parent, prop, index, node) {
  22. if (parent && prop) {
  23. if (index != null) {
  24. parent[prop][index] = node;
  25. } else {
  26. parent[prop] = node;
  27. }
  28. }
  29. }
  30. /**
  31. * @template {Node} Parent
  32. * @param {Parent | null | undefined} parent
  33. * @param {keyof Parent | null | undefined} prop
  34. * @param {number | null | undefined} index
  35. */
  36. remove(parent, prop, index) {
  37. if (parent && prop) {
  38. if (index !== null && index !== void 0) {
  39. parent[prop].splice(index, 1);
  40. } else {
  41. delete parent[prop];
  42. }
  43. }
  44. }
  45. };
  46. // node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
  47. var SyncWalker = class extends WalkerBase {
  48. /**
  49. *
  50. * @param {SyncHandler} [enter]
  51. * @param {SyncHandler} [leave]
  52. */
  53. constructor(enter, leave) {
  54. super();
  55. this.should_skip = false;
  56. this.should_remove = false;
  57. this.replacement = null;
  58. this.context = {
  59. skip: () => this.should_skip = true,
  60. remove: () => this.should_remove = true,
  61. replace: (node) => this.replacement = node
  62. };
  63. this.enter = enter;
  64. this.leave = leave;
  65. }
  66. /**
  67. * @template {Node} Parent
  68. * @param {Node} node
  69. * @param {Parent | null} parent
  70. * @param {keyof Parent} [prop]
  71. * @param {number | null} [index]
  72. * @returns {Node | null}
  73. */
  74. visit(node, parent, prop, index) {
  75. if (node) {
  76. if (this.enter) {
  77. const _should_skip = this.should_skip;
  78. const _should_remove = this.should_remove;
  79. const _replacement = this.replacement;
  80. this.should_skip = false;
  81. this.should_remove = false;
  82. this.replacement = null;
  83. this.enter.call(this.context, node, parent, prop, index);
  84. if (this.replacement) {
  85. node = this.replacement;
  86. this.replace(parent, prop, index, node);
  87. }
  88. if (this.should_remove) {
  89. this.remove(parent, prop, index);
  90. }
  91. const skipped = this.should_skip;
  92. const removed = this.should_remove;
  93. this.should_skip = _should_skip;
  94. this.should_remove = _should_remove;
  95. this.replacement = _replacement;
  96. if (skipped)
  97. return node;
  98. if (removed)
  99. return null;
  100. }
  101. let key;
  102. for (key in node) {
  103. const value = node[key];
  104. if (value && typeof value === "object") {
  105. if (Array.isArray(value)) {
  106. const nodes = (
  107. /** @type {Array<unknown>} */
  108. value
  109. );
  110. for (let i = 0; i < nodes.length; i += 1) {
  111. const item = nodes[i];
  112. if (isNode(item)) {
  113. if (!this.visit(item, node, key, i)) {
  114. i--;
  115. }
  116. }
  117. }
  118. } else if (isNode(value)) {
  119. this.visit(value, node, key, null);
  120. }
  121. }
  122. }
  123. if (this.leave) {
  124. const _replacement = this.replacement;
  125. const _should_remove = this.should_remove;
  126. this.replacement = null;
  127. this.should_remove = false;
  128. this.leave.call(this.context, node, parent, prop, index);
  129. if (this.replacement) {
  130. node = this.replacement;
  131. this.replace(parent, prop, index, node);
  132. }
  133. if (this.should_remove) {
  134. this.remove(parent, prop, index);
  135. }
  136. const removed = this.should_remove;
  137. this.replacement = _replacement;
  138. this.should_remove = _should_remove;
  139. if (removed)
  140. return null;
  141. }
  142. }
  143. return node;
  144. }
  145. };
  146. function isNode(value) {
  147. return value !== null && typeof value === "object" && "type" in value && typeof value.type === "string";
  148. }
  149. // node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/async.js
  150. var AsyncWalker = class extends WalkerBase {
  151. /**
  152. *
  153. * @param {AsyncHandler} [enter]
  154. * @param {AsyncHandler} [leave]
  155. */
  156. constructor(enter, leave) {
  157. super();
  158. this.should_skip = false;
  159. this.should_remove = false;
  160. this.replacement = null;
  161. this.context = {
  162. skip: () => this.should_skip = true,
  163. remove: () => this.should_remove = true,
  164. replace: (node) => this.replacement = node
  165. };
  166. this.enter = enter;
  167. this.leave = leave;
  168. }
  169. /**
  170. * @template {Node} Parent
  171. * @param {Node} node
  172. * @param {Parent | null} parent
  173. * @param {keyof Parent} [prop]
  174. * @param {number | null} [index]
  175. * @returns {Promise<Node | null>}
  176. */
  177. async visit(node, parent, prop, index) {
  178. if (node) {
  179. if (this.enter) {
  180. const _should_skip = this.should_skip;
  181. const _should_remove = this.should_remove;
  182. const _replacement = this.replacement;
  183. this.should_skip = false;
  184. this.should_remove = false;
  185. this.replacement = null;
  186. await this.enter.call(this.context, node, parent, prop, index);
  187. if (this.replacement) {
  188. node = this.replacement;
  189. this.replace(parent, prop, index, node);
  190. }
  191. if (this.should_remove) {
  192. this.remove(parent, prop, index);
  193. }
  194. const skipped = this.should_skip;
  195. const removed = this.should_remove;
  196. this.should_skip = _should_skip;
  197. this.should_remove = _should_remove;
  198. this.replacement = _replacement;
  199. if (skipped)
  200. return node;
  201. if (removed)
  202. return null;
  203. }
  204. let key;
  205. for (key in node) {
  206. const value = node[key];
  207. if (value && typeof value === "object") {
  208. if (Array.isArray(value)) {
  209. const nodes = (
  210. /** @type {Array<unknown>} */
  211. value
  212. );
  213. for (let i = 0; i < nodes.length; i += 1) {
  214. const item = nodes[i];
  215. if (isNode2(item)) {
  216. if (!await this.visit(item, node, key, i)) {
  217. i--;
  218. }
  219. }
  220. }
  221. } else if (isNode2(value)) {
  222. await this.visit(value, node, key, null);
  223. }
  224. }
  225. }
  226. if (this.leave) {
  227. const _replacement = this.replacement;
  228. const _should_remove = this.should_remove;
  229. this.replacement = null;
  230. this.should_remove = false;
  231. await this.leave.call(this.context, node, parent, prop, index);
  232. if (this.replacement) {
  233. node = this.replacement;
  234. this.replace(parent, prop, index, node);
  235. }
  236. if (this.should_remove) {
  237. this.remove(parent, prop, index);
  238. }
  239. const removed = this.should_remove;
  240. this.replacement = _replacement;
  241. this.should_remove = _should_remove;
  242. if (removed)
  243. return null;
  244. }
  245. }
  246. return node;
  247. }
  248. };
  249. function isNode2(value) {
  250. return value !== null && typeof value === "object" && "type" in value && typeof value.type === "string";
  251. }
  252. // node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
  253. function walk(ast, { enter, leave }) {
  254. const instance = new SyncWalker(enter, leave);
  255. return instance.visit(ast, null);
  256. }
  257. async function asyncWalk(ast, { enter, leave }) {
  258. const instance = new AsyncWalker(enter, leave);
  259. return await instance.visit(ast, null);
  260. }
  261. exports.asyncWalk = asyncWalk; exports.walk = walk;
  262. exports.default = module.exports;