@atlassian/chippy 0.0.1-beta.1 → 0.0.1-beta.2

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.
Files changed (54) hide show
  1. package/README.md +142 -54
  2. package/bin/chippy.mjs +53 -95
  3. package/bin/pack.mjs +20 -0
  4. package/bin/skill-dir.mjs +15 -0
  5. package/lib/avalanche.js +54 -23
  6. package/lib/avalanche.js.map +2 -2
  7. package/lib/bootstrap.js +20 -1
  8. package/lib/bootstrap.js.map +3 -3
  9. package/lib/extension/avalanche.es.js +173 -34
  10. package/lib/extension/avalanche.es.js.map +1 -1
  11. package/lib/extension/chippy-page-bridge.js +164 -44
  12. package/lib/mcp-skill/README.md +2 -4
  13. package/lib/mcp-skill/SKILL.md +21 -16
  14. package/lib/mcp-skill/extension/armed-reload-startup.js +83 -0
  15. package/lib/mcp-skill/extension/avalanche.es.js +173 -34
  16. package/lib/mcp-skill/extension/avalanche.es.js.map +1 -1
  17. package/lib/mcp-skill/extension/avalanche.iife.js +173 -34
  18. package/lib/mcp-skill/extension/avalanche.iife.js.map +1 -1
  19. package/lib/mcp-skill/extension/background.js +2 -0
  20. package/lib/mcp-skill/extension/chippy-page-bridge.js +164 -44
  21. package/lib/mcp-skill/extension/content-script.js +23 -0
  22. package/lib/mcp-skill/extension/devtools-hook-shim.js +18 -1
  23. package/lib/mcp-skill/extension/early-bootstrap.js +3 -1
  24. package/lib/mcp-skill/extension/manifest.json +1 -1
  25. package/lib/mcp-skill/extension/panel-settings.js +2 -20
  26. package/lib/mcp-skill/extension/startup-handoff.js +30 -0
  27. package/lib/mcp-skill/references/README.md +2 -2
  28. package/lib/mcp-skill/references/avalanche-detector.md +3 -3
  29. package/lib/mcp-skill/references/browser-runtime-api.md +4 -4
  30. package/lib/mcp-skill/references/command-output-formats.md +12 -2
  31. package/lib/mcp-skill/references/command-surface.md +6 -6
  32. package/lib/mcp-skill/references/mode-a-injection.md +43 -9
  33. package/lib/mcp-skill/references/playwright-cli-setup.md +5 -5
  34. package/lib/mcp-skill/references/playwright-probes.md +1 -1
  35. package/lib/mcp-skill/references/recipes.txt +1 -1
  36. package/lib/mcp-skill/references/stability-render.md +4 -4
  37. package/lib/mcp-skill/references/test-mode-playbook.md +2 -1
  38. package/lib/mcp-skill/references/troubleshooting.md +6 -1
  39. package/lib/mcp-skill/scripts/chippy-helper-server.js +116 -58
  40. package/lib/mcp-skill/scripts/chippy.sh +41 -7
  41. package/lib/mcp-skill/scripts/helper-access.js +20 -6
  42. package/lib/mcp-skill/scripts/helper-proxy.js +87 -0
  43. package/lib/mcp-skill/scripts/page-socket-trust.js +81 -0
  44. package/lib/plugin.js.map +2 -2
  45. package/lib/storybook/connection-fallback.jsx +1 -1
  46. package/lib/storybook/manager-owner.js +42 -0
  47. package/lib/storybook/manager.jsx +22 -0
  48. package/lib/storybook/preview.js +53 -18
  49. package/lib/storybook/setup.js +15 -4
  50. package/lib/types/chippy-bridge/fiber-source.d.ts +14 -3
  51. package/lib/types/chippy-bridge/react-renderer.d.ts +30 -5
  52. package/lib/types/chippy-bridge/recorded-source.d.ts +44 -0
  53. package/lib/types/debug-render/core.d.ts +6 -0
  54. package/package.json +3 -1
package/lib/avalanche.js CHANGED
@@ -86,8 +86,6 @@ function getFiberSourceCandidate(fiber) {
86
86
  }
87
87
  function getFiberSource(fiber) {
88
88
  if (!fiber) return null;
89
- const recorded = recordedSource(fiber);
90
- if (recorded) return recorded;
91
89
  const cached = resolvedFiberSources.get(fiber);
92
90
  if (cached !== void 0) return cached;
93
91
  return getFiberSourceCandidate(fiber);
@@ -645,13 +643,42 @@ function getReactRenderers(scope = globalThis) {
645
643
  }
646
644
  return out;
647
645
  }
648
- function getDispatcherRef(scope = globalThis) {
646
+ function dispatcherSlotOf(injected) {
647
+ if (!injected || typeof injected !== "object") return null;
648
+ const owner = injected;
649
+ if (typeof owner.H !== "undefined") return { owner, key: "H" };
650
+ if ("current" in owner) return { owner, key: "current" };
651
+ return null;
652
+ }
653
+ function getDispatcherSlot(scope = globalThis) {
649
654
  for (const renderer of getReactRenderers(scope)) {
650
- const ref = renderer.currentDispatcherRef;
651
- if (ref && typeof ref === "object") return ref;
655
+ const slot = dispatcherSlotOf(renderer.currentDispatcherRef);
656
+ if (slot) return slot;
652
657
  }
653
658
  return null;
654
659
  }
660
+ var modernRefs = /* @__PURE__ */ new WeakMap();
661
+ function dispatcherRefOf(slot) {
662
+ if (slot.key === "current") return slot.owner;
663
+ let ref = modernRefs.get(slot.owner);
664
+ if (!ref) {
665
+ const { owner } = slot;
666
+ ref = {
667
+ get current() {
668
+ return owner.H;
669
+ },
670
+ set current(value) {
671
+ owner.H = value;
672
+ }
673
+ };
674
+ modernRefs.set(owner, ref);
675
+ }
676
+ return ref;
677
+ }
678
+ function getDispatcherRef(scope = globalThis) {
679
+ const slot = getDispatcherSlot(scope);
680
+ return slot ? dispatcherRefOf(slot) : null;
681
+ }
655
682
 
656
683
  // src/debug-render/core.ts
657
684
  function parseStackFrames2(stack) {
@@ -706,11 +733,14 @@ var HOOK_PRIMITIVE = {
706
733
  function isReactInternalFrameName(name) {
707
734
  return name === "atlDispatcherHook" || name === "record" || name.startsWith("Object.") || name === "renderWithHooks" || name === "updateFunctionComponent" || name === "mountIndeterminateComponent" || name === "beginWork" || /^beginWork\$/.test(name) || name === "performUnitOfWork" || name === "workLoopSync" || name === "renderRootSync" || name === "performConcurrentWorkOnRoot" || name === "workLoop" || name === "flushWork";
708
735
  }
736
+ function isHookFrameName(name) {
737
+ return /^use[A-Z0-9_]/.test(name.slice(name.lastIndexOf(".") + 1));
738
+ }
709
739
  function deriveComponentName(frames) {
710
740
  for (const { name } of frames) {
711
741
  if (!name) continue;
712
742
  if (isReactInternalFrameName(name)) continue;
713
- if (/^use[A-Z0-9_]/.test(name)) continue;
743
+ if (isHookFrameName(name)) continue;
714
744
  return name;
715
745
  }
716
746
  return "Unknown";
@@ -721,7 +751,7 @@ function createDebugRender(options = {}) {
721
751
  const patchedDispatchers = /* @__PURE__ */ new WeakMap();
722
752
  let installed = false;
723
753
  let originalDescriptor = void 0;
724
- let dispatcherRef = null;
754
+ let dispatcherSlot = null;
725
755
  let lastSeenDispatcher = null;
726
756
  function record(primitive, args) {
727
757
  const stack = new Error().stack || "";
@@ -773,15 +803,16 @@ function createDebugRender(options = {}) {
773
803
  }
774
804
  function install() {
775
805
  if (installed) return { ok: true };
776
- const ref = getDispatcherRef();
777
- if (!ref) return { ok: false, reason: "ReactCurrentDispatcher not found" };
778
- dispatcherRef = ref;
779
- patchDispatcher(ref.current);
780
- lastSeenDispatcher = ref.current;
781
- originalDescriptor = Object.getOwnPropertyDescriptor(ref, "current") || null;
782
- let stored = ref.current;
806
+ const slot = getDispatcherSlot();
807
+ if (!slot) return { ok: false, reason: "ReactCurrentDispatcher not found" };
808
+ dispatcherSlot = slot;
809
+ const { owner, key } = slot;
810
+ patchDispatcher(owner[key]);
811
+ lastSeenDispatcher = owner[key];
812
+ originalDescriptor = Object.getOwnPropertyDescriptor(owner, key) || null;
813
+ let stored = owner[key];
783
814
  try {
784
- Object.defineProperty(ref, "current", {
815
+ Object.defineProperty(owner, key, {
785
816
  configurable: true,
786
817
  get() {
787
818
  return stored;
@@ -795,7 +826,7 @@ function createDebugRender(options = {}) {
795
826
  }
796
827
  });
797
828
  } catch (e) {
798
- dispatcherRef = null;
829
+ dispatcherSlot = null;
799
830
  return { ok: false, reason: "cannot define property on ReactCurrentDispatcher" };
800
831
  }
801
832
  installed = true;
@@ -803,12 +834,13 @@ function createDebugRender(options = {}) {
803
834
  }
804
835
  function uninstall() {
805
836
  if (!installed) return;
806
- if (dispatcherRef) {
837
+ if (dispatcherSlot) {
838
+ const { owner, key } = dispatcherSlot;
807
839
  try {
808
840
  if (originalDescriptor) {
809
- Object.defineProperty(dispatcherRef, "current", originalDescriptor);
841
+ Object.defineProperty(owner, key, originalDescriptor);
810
842
  } else {
811
- Object.defineProperty(dispatcherRef, "current", {
843
+ Object.defineProperty(owner, key, {
812
844
  configurable: true,
813
845
  writable: true,
814
846
  enumerable: true,
@@ -820,7 +852,7 @@ function createDebugRender(options = {}) {
820
852
  }
821
853
  unpatchDispatcher(lastSeenDispatcher);
822
854
  installed = false;
823
- dispatcherRef = null;
855
+ dispatcherSlot = null;
824
856
  originalDescriptor = void 0;
825
857
  lastSeenDispatcher = null;
826
858
  }
@@ -837,8 +869,7 @@ function createDebugRender(options = {}) {
837
869
  const g = globalThis;
838
870
  const hasDevtoolsHook = !!g.__REACT_DEVTOOLS_GLOBAL_HOOK__;
839
871
  const rendererCount = getReactRenderers().length;
840
- const ref = dispatcherRef || getDispatcherRef();
841
- const hasDispatcherRef = !!ref;
872
+ const hasDispatcherRef = !!(dispatcherSlot || getDispatcherSlot());
842
873
  let totalCapturedEvents = 0;
843
874
  for (const list of eventsByComponent.values()) totalCapturedEvents += list.length;
844
875
  let reason;
@@ -877,7 +908,7 @@ function createDebugRender(options = {}) {
877
908
  uninstall,
878
909
  reset,
879
910
  isInstalled: () => installed,
880
- dispatcherRef: () => dispatcherRef || getDispatcherRef(),
911
+ dispatcherRef: () => dispatcherSlot ? dispatcherRefOf(dispatcherSlot) : getDispatcherRef(),
881
912
  rawEvents,
882
913
  allComponents,
883
914
  status,