@riboseinc/anafero-cli 0.0.17 → 0.0.18

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/bootstrap.js CHANGED
@@ -132617,6 +132617,18 @@ var VersionWorkspace = function({
132617
132617
  hasFragment ? `#${rpath.split("#")[1]}` : null
132618
132618
  ];
132619
132619
  }, [expandUnversionedPath]);
132620
+ const scrollToResource = (0, import_react218.useCallback)((resourceURI) => {
132621
+ const el = document.getElementById(resourceURI) ?? document.querySelector(`[about="${resourceURI}"]`);
132622
+ if (el) {
132623
+ try {
132624
+ el.scrollIntoView();
132625
+ } catch (e2) {
132626
+ console.error("Failed to scroll element into view", resourceURI);
132627
+ }
132628
+ } else {
132629
+ console.error("Element not found for resource to scroll to", resourceURI);
132630
+ }
132631
+ }, []);
132620
132632
  (0, import_react218.useEffect)(() => {
132621
132633
  const handlePopState = function() {
132622
132634
  const uri = typeof history.state?.res === "string" ? history.state.res : void 0;
@@ -132635,10 +132647,12 @@ var VersionWorkspace = function({
132635
132647
  const [, fragment] = expandResourcePath(path);
132636
132648
  dispatch({ type: "activated_resource", uri });
132637
132649
  if (fragment) {
132638
- window.location.hash = fragment;
132650
+ setTimeout(() => {
132651
+ setQueuedFragment(fragment.slice(1));
132652
+ }, 200);
132639
132653
  }
132640
132654
  } else {
132641
- console.warn("When popping state, could not resolve resource URI or locate resource path");
132655
+ console.warn("While popping state, could not resolve resource URI or locate resource path", uri, history.state?.res);
132642
132656
  return;
132643
132657
  }
132644
132658
  };
@@ -132660,6 +132674,7 @@ var VersionWorkspace = function({
132660
132674
  dispatch({ type: "activated_resource", uri: res });
132661
132675
  }
132662
132676
  }, [expandResourcePath, locateResource, state.activeResourceURI]);
132677
+ const [queuedFragment, setQueuedFragment] = (0, import_react218.useState)("");
132663
132678
  const setUpInterceptor = (0, import_react218.useCallback)((resourcesRef) => {
132664
132679
  intercept_nav_default(resourcesRef, {
132665
132680
  // shadowDom: true,
@@ -132669,12 +132684,12 @@ var VersionWorkspace = function({
132669
132684
  return;
132670
132685
  }
132671
132686
  const url2 = new URL(href, document.baseURI);
132672
- const absoluteHref = url2.pathname;
132687
+ const absoluteHref = decodeURIComponent(url2.pathname);
132673
132688
  const resourceURI = reverseResource(absoluteHref);
132674
132689
  if (resourceURI) {
132675
132690
  dispatch({ type: "activated_resource", uri: resourceURI });
132676
132691
  if (url2.hash) {
132677
- window.location.hash = url2.hash;
132692
+ setQueuedFragment(decodeURIComponent(url2.hash.slice(1)));
132678
132693
  }
132679
132694
  evt.stopPropagation();
132680
132695
  evt.preventDefault();
@@ -132716,6 +132731,16 @@ var VersionWorkspace = function({
132716
132731
  }, [hierarchy, state.expandedResourceURIs, actualSelected]);
132717
132732
  const routerProps = (0, import_react218.useMemo)(() => ({ router: { navigate } }), [navigate]);
132718
132733
  const isLoading = Object.values(resourceDeps).find((val) => typeof val === "function");
132734
+ (0, import_react218.useEffect)(() => {
132735
+ if (!isLoading && queuedFragment) {
132736
+ const elID = queuedFragment;
132737
+ window.location.hash = `#${encodeURIComponent(elID)}`;
132738
+ setTimeout(() => {
132739
+ scrollToResource(elID);
132740
+ setQueuedFragment("");
132741
+ }, 500);
132742
+ }
132743
+ }, [isLoading, queuedFragment]);
132719
132744
  const lastVisibleResourceMarkerIntersection = useInView({
132720
132745
  threshold: 0,
132721
132746
  initialInView: true