@riboseinc/anafero-cli 0.0.17 → 0.0.19

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
@@ -132635,10 +132635,12 @@ var VersionWorkspace = function({
132635
132635
  const [, fragment] = expandResourcePath(path);
132636
132636
  dispatch({ type: "activated_resource", uri });
132637
132637
  if (fragment) {
132638
- window.location.hash = fragment;
132638
+ setTimeout(() => {
132639
+ setQueuedFragment(fragment.slice(1));
132640
+ }, 200);
132639
132641
  }
132640
132642
  } else {
132641
- console.warn("When popping state, could not resolve resource URI or locate resource path");
132643
+ console.warn("While popping state, could not resolve resource URI or locate resource path", uri, history.state?.res);
132642
132644
  return;
132643
132645
  }
132644
132646
  };
@@ -132660,7 +132662,11 @@ var VersionWorkspace = function({
132660
132662
  dispatch({ type: "activated_resource", uri: res });
132661
132663
  }
132662
132664
  }, [expandResourcePath, locateResource, state.activeResourceURI]);
132665
+ const [resourceContainerElement, setResourceContainerElement] = (0, import_react218.useState)(null);
132663
132666
  const setUpInterceptor = (0, import_react218.useCallback)((resourcesRef) => {
132667
+ if (resourcesRef) {
132668
+ setResourceContainerElement(resourcesRef);
132669
+ }
132664
132670
  intercept_nav_default(resourcesRef, {
132665
132671
  // shadowDom: true,
132666
132672
  }, function handleIntercept(evt, el) {
@@ -132669,12 +132675,12 @@ var VersionWorkspace = function({
132669
132675
  return;
132670
132676
  }
132671
132677
  const url2 = new URL(href, document.baseURI);
132672
- const absoluteHref = url2.pathname;
132678
+ const absoluteHref = decodeURIComponent(url2.pathname);
132673
132679
  const resourceURI = reverseResource(absoluteHref);
132674
132680
  if (resourceURI) {
132675
132681
  dispatch({ type: "activated_resource", uri: resourceURI });
132676
132682
  if (url2.hash) {
132677
- window.location.hash = url2.hash;
132683
+ setQueuedFragment(decodeURIComponent(url2.hash.slice(1)));
132678
132684
  }
132679
132685
  evt.stopPropagation();
132680
132686
  evt.preventDefault();
@@ -132716,6 +132722,50 @@ var VersionWorkspace = function({
132716
132722
  }, [hierarchy, state.expandedResourceURIs, actualSelected]);
132717
132723
  const routerProps = (0, import_react218.useMemo)(() => ({ router: { navigate } }), [navigate]);
132718
132724
  const isLoading = Object.values(resourceDeps).find((val) => typeof val === "function");
132725
+ const [queuedFragment, setQueuedFragment] = (0, import_react218.useState)("");
132726
+ const scrollToResource = (0, import_react218.useCallback)(() => {
132727
+ if (!queuedFragment) {
132728
+ return;
132729
+ }
132730
+ if (!resourceContainerElement) {
132731
+ console.warn("Cannot scroll to resource: no resource container element");
132732
+ return;
132733
+ }
132734
+ const el = document.getElementById(queuedFragment) ?? resourceContainerElement.querySelector(`[about="${queuedFragment}"]`);
132735
+ if (el) {
132736
+ try {
132737
+ el.scrollIntoView();
132738
+ } catch (e2) {
132739
+ console.error("Failed to scroll element into view", queuedFragment);
132740
+ }
132741
+ setQueuedFragment("");
132742
+ } else {
132743
+ console.error("Element not found for resource to scroll to", queuedFragment);
132744
+ }
132745
+ }, [resourceContainerElement, queuedFragment]);
132746
+ (0, import_react218.useEffect)(() => {
132747
+ if (!isLoading && queuedFragment && resourceContainerElement) {
132748
+ const resourceID = queuedFragment;
132749
+ window.location.hash = `#${encodeURIComponent(resourceID)}`;
132750
+ const observer = new MutationObserver(scrollToResource);
132751
+ scrollToResource();
132752
+ observer.observe(resourceContainerElement, {
132753
+ attributes: false,
132754
+ childList: true,
132755
+ characterData: false,
132756
+ subtree: true
132757
+ });
132758
+ const timeout2 = setTimeout(() => {
132759
+ setQueuedFragment("");
132760
+ }, 5e3);
132761
+ return function() {
132762
+ observer.disconnect();
132763
+ window.clearTimeout(timeout2);
132764
+ };
132765
+ }
132766
+ return function() {
132767
+ };
132768
+ }, [isLoading, queuedFragment, scrollToResource, resourceContainerElement]);
132719
132769
  const lastVisibleResourceMarkerIntersection = useInView({
132720
132770
  threshold: 0,
132721
132771
  initialInView: true