bippy 0.3.3 → 0.3.4

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.
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  // src/rdt-hook.ts
13
- var version = "0.3.3";
13
+ var version = "0.3.4";
14
14
  var BIPPY_INSTRUMENTATION_STRING = `bippy-${version}`;
15
15
  var objectDefineProperty = Object.defineProperty;
16
16
  var objectHasOwnProperty = Object.prototype.hasOwnProperty;
@@ -470,6 +470,72 @@ var getLatestFiber = (fiber) => {
470
470
  }
471
471
  return fiber;
472
472
  };
473
+ var diffFiber = (thisFiber, otherFiber) => {
474
+ const path = [];
475
+ const diffs = [];
476
+ const traverse = (current, other, currentPath) => {
477
+ if (current.type !== other.type) {
478
+ diffs.push({
479
+ path: [...currentPath],
480
+ type: "type",
481
+ thisFiber: current,
482
+ otherFiber: other
483
+ });
484
+ }
485
+ if (current.ref !== other.ref) {
486
+ diffs.push({
487
+ path: [...currentPath],
488
+ type: "ref",
489
+ thisFiber: current,
490
+ otherFiber: other
491
+ });
492
+ }
493
+ const currentProps = current.memoizedProps || {};
494
+ const otherProps = other.memoizedProps || {};
495
+ const allProps = /* @__PURE__ */ new Set([...Object.keys(currentProps), ...Object.keys(otherProps)]);
496
+ for (const prop of allProps) {
497
+ if (currentProps[prop] !== otherProps[prop]) {
498
+ diffs.push({
499
+ path: [...currentPath],
500
+ type: "props",
501
+ thisFiber: current,
502
+ otherFiber: other
503
+ });
504
+ break;
505
+ }
506
+ }
507
+ if (current.memoizedState !== other.memoizedState) {
508
+ diffs.push({
509
+ path: [...currentPath],
510
+ type: "state",
511
+ thisFiber: current,
512
+ otherFiber: other
513
+ });
514
+ }
515
+ if (current.child && other.child) {
516
+ traverse(current.child, other.child, [...currentPath, "child"]);
517
+ } else if (current.child || other.child) {
518
+ diffs.push({
519
+ path: [...currentPath],
520
+ type: "children",
521
+ thisFiber: current,
522
+ otherFiber: other
523
+ });
524
+ }
525
+ if (current.sibling && other.sibling) {
526
+ traverse(current.sibling, other.sibling, [...currentPath, "sibling"]);
527
+ } else if (current.sibling || other.sibling) {
528
+ diffs.push({
529
+ path: [...currentPath],
530
+ type: "children",
531
+ thisFiber: current,
532
+ otherFiber: other
533
+ });
534
+ }
535
+ };
536
+ traverse(thisFiber, otherFiber, path);
537
+ return diffs;
538
+ };
473
539
  var fiberId = 0;
474
540
  var fiberIdMap = /* @__PURE__ */ new WeakMap();
475
541
  var setFiberId = (fiber, id = fiberId++) => {
@@ -808,6 +874,7 @@ exports.createFiberVisitor = createFiberVisitor;
808
874
  exports.detectReactBuildType = detectReactBuildType;
809
875
  exports.didFiberCommit = didFiberCommit;
810
876
  exports.didFiberRender = didFiberRender;
877
+ exports.diffFiber = diffFiber;
811
878
  exports.fiberIdMap = fiberIdMap;
812
879
  exports.getDisplayName = getDisplayName;
813
880
  exports.getFiberFromHostInstance = getFiberFromHostInstance;