bobe 0.0.51 → 0.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -416,6 +416,7 @@ interface BaseNode {
416
416
  type: ASTNodeType;
417
417
  loc?: SourceLocation;
418
418
  hasError?: boolean;
419
+ parent?: BaseNode;
419
420
  }
420
421
  interface Program extends BaseNode {
421
422
  type: NodeType.Program;
@@ -487,6 +488,7 @@ declare class Compiler {
487
488
  tokenizer: Tokenizer;
488
489
  hooks: ParseHooks;
489
490
  errors: ParseError[];
491
+ currentParent?: BaseNode;
490
492
  constructor(tokenizer: Tokenizer, hooks?: ParseHooks);
491
493
  private addError;
492
494
  /**
package/dist/index.umd.js CHANGED
@@ -1320,12 +1320,16 @@
1320
1320
  }
1321
1321
  function NodeHook(target, context) {
1322
1322
  return function (_node) {
1323
+ const prevParent = this.currentParent;
1323
1324
  const hook = this.hooks[context.name];
1324
1325
  const node = {
1325
1326
  loc: {}
1326
1327
  };
1328
+ node.parent = prevParent;
1327
1329
  hook?.enter?.call(this, node);
1330
+ this.currentParent = node;
1328
1331
  const result = target.call(this, node);
1332
+ this.currentParent = prevParent;
1329
1333
  hook?.leave?.call(this, node);
1330
1334
  return result;
1331
1335
  };