@riboseinc/anafero-cli 0.0.65 → 0.0.66

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
@@ -110916,15 +110916,15 @@ schema (${ast._tag}): ${ast}`;
110916
110916
  }
110917
110917
  }, [locateResource, state.activeResourceURI]);
110918
110918
  const [resourceContainerElement, setResourceContainerElement] = (0, import_react212.useState)(null);
110919
- const setUpInterceptor = (0, import_react212.useCallback)((resourcesRef) => {
110920
- if (resourcesRef) {
110921
- setResourceContainerElement(resourcesRef);
110919
+ (0, import_react212.useEffect)(() => {
110920
+ if (!resourceContainerElement || !getVersionRelativePath) {
110921
+ return;
110922
110922
  }
110923
- intercept_nav_default(resourcesRef, {
110923
+ const cleanUpInterceptor = intercept_nav_default(resourceContainerElement, {
110924
110924
  // shadowDom: true,
110925
110925
  }, function handleIntercept(evt, el) {
110926
110926
  const href = el.getAttribute("href");
110927
- if (!href || !getVersionRelativePath) {
110927
+ if (!href) {
110928
110928
  return;
110929
110929
  }
110930
110930
  const url2 = new URL(href, document.baseURI);
@@ -110944,7 +110944,18 @@ schema (${ast._tag}): ${ast}`;
110944
110944
  return true;
110945
110945
  }
110946
110946
  });
110947
- }, [reverseResource, getVersionRelativePath, getContainingPageResourceURI]);
110947
+ return cleanUpInterceptor;
110948
+ }, [
110949
+ resourceContainerElement,
110950
+ reverseResource,
110951
+ getVersionRelativePath,
110952
+ getContainingPageResourceURI
110953
+ ]);
110954
+ const refResourceContainerElement = (0, import_react212.useCallback)((resourcesRef) => {
110955
+ if (resourcesRef) {
110956
+ setResourceContainerElement(resourcesRef);
110957
+ }
110958
+ }, [setResourceContainerElement]);
110948
110959
  const [queuedFragment, setQueuedFragment] = (0, import_react212.useState)("");
110949
110960
  const jumpTo = (0, import_react212.useCallback)((uri) => {
110950
110961
  if (getContainingPageResourceURI(uri) === uri) {
@@ -110959,7 +110970,7 @@ schema (${ast._tag}): ${ast}`;
110959
110970
  console.error("Unable to reverse resource URI for path", path);
110960
110971
  throw new Error("Unable to reverse resource URI for path");
110961
110972
  }
110962
- console.debug("Navigating & activating resource", resourceURI);
110973
+ console.debug("Navigating & activating resource via router", resourceURI);
110963
110974
  dispatch({ type: "activated_resource", uri: resourceURI, pageURI: getContainingPageResourceURI(resourceURI) });
110964
110975
  }, [reverseResource, jumpTo, getContainingPageResourceURI]);
110965
110976
  const pageMap = (0, import_react212.useMemo)(
@@ -111129,7 +111140,7 @@ schema (${ast._tag}): ${ast}`;
111129
111140
  type: "deactivated_browsing_mode"
111130
111141
  }), [])
111131
111142
  }
111132
- ), /* @__PURE__ */ import_react212.default.createElement("main", { id: "resources", ref: setUpInterceptor }, /* @__PURE__ */ import_react212.default.createElement($7167f8da3cce35e4$export$2881499e37b75b9a, { theme: $bf24a13e98395dd3$export$bca14c5b3b88a9c9, locale }, state.visibleResourceURIs.map((uri, idx) => {
111143
+ ), /* @__PURE__ */ import_react212.default.createElement("main", { id: "resources", ref: refResourceContainerElement }, /* @__PURE__ */ import_react212.default.createElement($7167f8da3cce35e4$export$2881499e37b75b9a, { theme: $bf24a13e98395dd3$export$bca14c5b3b88a9c9, locale }, state.visibleResourceURIs.map((uri, idx) => {
111133
111144
  const isActive2 = uri === activePageResourceURI;
111134
111145
  const isOnlyOneShown = state.visibleResourceURIs.length < 2;
111135
111146
  const isMarkedActive = !isOnlyOneShown && isActive2;
@@ -111280,7 +111291,10 @@ schema (${ast._tag}): ${ast}`;
111280
111291
  if (!parentPath) {
111281
111292
  throw new Error("getAdjacentResource: missing parentPath");
111282
111293
  }
111283
- const parentNavPath = [parentPath, "resource-nav.json"].join("/");
111294
+ const parentNavPath = [
111295
+ parentPath === "/" ? "" : parentPath,
111296
+ "resource-nav.json"
111297
+ ].join("/");
111284
111298
  const parentNav = decodeUnknownSync(ResourceNavSchema)(await (await fetch(parentNavPath, { signal })).json());
111285
111299
  const currentPathTail = currentPath.slice(currentPath.lastIndexOf("/") + 1);
111286
111300
  const children = parentNav.children.map(
@@ -111331,16 +111345,14 @@ schema (${ast._tag}): ${ast}`;
111331
111345
 
111332
111346
  // bootstrap.tsx
111333
111347
  patchLunr();
111334
- getExtensionImports().then(setUpExtensionImportMap).then(initApp);
111335
- function initApp() {
111348
+ getExtensionImports().then(setUpExtensionImportMap).then(hydrateApp);
111349
+ function hydrateApp() {
111336
111350
  const appRoot = document.getElementById("app");
111337
111351
  if (!appRoot) {
111338
111352
  console.error("Can\u2019t initialize the app: missing root");
111339
111353
  return;
111340
111354
  }
111341
- const useStrictMode2 = document.documentElement.dataset.useReactStrict === "true";
111342
111355
  const originalHTML = appRoot.innerHTML;
111343
- document.body.style.height = `${appRoot.clientHeight}px`;
111344
111356
  const app = /* @__PURE__ */ import_react213.default.createElement(ErrorBoundaryWithCustomView_default, { fallback: /* @__PURE__ */ import_react213.default.createElement(
111345
111357
  "div",
111346
111358
  {
@@ -111348,17 +111360,23 @@ schema (${ast._tag}): ${ast}`;
111348
111360
  suppressHydrationWarning: true
111349
111361
  }
111350
111362
  ) }, /* @__PURE__ */ import_react213.default.createElement(AppLoader, null));
111363
+ holdBodyHeightUntilHydrationIsComplete(appRoot.clientHeight);
111364
+ const useStrictMode2 = document.documentElement.dataset.useReactStrict === "true";
111351
111365
  (0, import_client.hydrateRoot)(
111352
111366
  appRoot,
111353
111367
  useStrictMode2 ? /* @__PURE__ */ import_react213.default.createElement(import_react214.StrictMode, null, app) : app
111354
111368
  );
111355
- const observer = new MutationObserver(function cleanUpLoad() {
111369
+ }
111370
+ function holdBodyHeightUntilHydrationIsComplete(heightInPx) {
111371
+ document.body.style.height = `${heightInPx}px`;
111372
+ function unsetHeightAndDisconnectObserverIfHydrated() {
111356
111373
  const hasInitialized = !!document.documentElement.getAttribute("data-react-helmet");
111357
111374
  if (hasInitialized) {
111358
111375
  setTimeout(() => document.body.style.removeProperty("height"), 500);
111359
111376
  observer.disconnect();
111360
111377
  }
111361
- });
111378
+ }
111379
+ const observer = new MutationObserver(unsetHeightAndDisconnectObserverIfHydrated);
111362
111380
  observer.observe(document.documentElement, {
111363
111381
  attributes: true,
111364
111382
  childList: false,