@riboseinc/anafero-cli 0.0.64 → 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
@@ -109633,7 +109633,8 @@ schema (${ast._tag}): ${ast}`;
109633
109633
  const [debouncedQuery] = a(query.text, 200);
109634
109634
  const [showMore, setShowMore] = (0, import_react204.useState)(false);
109635
109635
  const [matches2, error] = (0, import_react204.useMemo)(() => {
109636
- if (index && debouncedQuery.trim() !== "") {
109636
+ const debouncedQueryTrimmed = debouncedQuery.trim();
109637
+ if (index && debouncedQueryTrimmed !== "") {
109637
109638
  const normalizedQuery = preprocessStringForIndexing(
109638
109639
  debouncedQuery.replace(/:/g, " ").replace(/\*/g, " ")
109639
109640
  );
@@ -109660,9 +109661,13 @@ schema (${ast._tag}): ${ast}`;
109660
109661
  });
109661
109662
  }
109662
109663
  }) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
109664
+ const wildcardLeading = debouncedQueryTrimmed.startsWith("*") ?? void 0;
109665
+ const wildcardTrailing = debouncedQueryTrimmed.endsWith("*") ?? void 0;
109666
+ const wildcard = wildcardLeading && wildcardTrailing ? import_lunr.default.Query.wildcard.LEADING | import_lunr.default.Query.wildcard.TRAILING : wildcardLeading ? import_lunr.default.Query.wildcard.LEADING : wildcardTrailing ? import_lunr.default.Query.wildcard.TRAILING : import_lunr.default.Query.wildcard.NONE;
109663
109667
  const partial5 = exact.length < 1 && full.length < 1 || showMore ? (index.query((query2) => {
109664
109668
  query2.term(tokens, {
109665
- presence: import_lunr.default.Query.presence.OPTIONAL
109669
+ presence: import_lunr.default.Query.presence.OPTIONAL,
109670
+ wildcard
109666
109671
  });
109667
109672
  }) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
109668
109673
  return [{ exact, full, partial: partial5 }, null];
@@ -110911,15 +110916,15 @@ schema (${ast._tag}): ${ast}`;
110911
110916
  }
110912
110917
  }, [locateResource, state.activeResourceURI]);
110913
110918
  const [resourceContainerElement, setResourceContainerElement] = (0, import_react212.useState)(null);
110914
- const setUpInterceptor = (0, import_react212.useCallback)((resourcesRef) => {
110915
- if (resourcesRef) {
110916
- setResourceContainerElement(resourcesRef);
110919
+ (0, import_react212.useEffect)(() => {
110920
+ if (!resourceContainerElement || !getVersionRelativePath) {
110921
+ return;
110917
110922
  }
110918
- intercept_nav_default(resourcesRef, {
110923
+ const cleanUpInterceptor = intercept_nav_default(resourceContainerElement, {
110919
110924
  // shadowDom: true,
110920
110925
  }, function handleIntercept(evt, el) {
110921
110926
  const href = el.getAttribute("href");
110922
- if (!href || !getVersionRelativePath) {
110927
+ if (!href) {
110923
110928
  return;
110924
110929
  }
110925
110930
  const url2 = new URL(href, document.baseURI);
@@ -110939,7 +110944,18 @@ schema (${ast._tag}): ${ast}`;
110939
110944
  return true;
110940
110945
  }
110941
110946
  });
110942
- }, [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]);
110943
110959
  const [queuedFragment, setQueuedFragment] = (0, import_react212.useState)("");
110944
110960
  const jumpTo = (0, import_react212.useCallback)((uri) => {
110945
110961
  if (getContainingPageResourceURI(uri) === uri) {
@@ -110954,7 +110970,7 @@ schema (${ast._tag}): ${ast}`;
110954
110970
  console.error("Unable to reverse resource URI for path", path);
110955
110971
  throw new Error("Unable to reverse resource URI for path");
110956
110972
  }
110957
- console.debug("Navigating & activating resource", resourceURI);
110973
+ console.debug("Navigating & activating resource via router", resourceURI);
110958
110974
  dispatch({ type: "activated_resource", uri: resourceURI, pageURI: getContainingPageResourceURI(resourceURI) });
110959
110975
  }, [reverseResource, jumpTo, getContainingPageResourceURI]);
110960
110976
  const pageMap = (0, import_react212.useMemo)(
@@ -110966,7 +110982,6 @@ schema (${ast._tag}): ${ast}`;
110966
110982
  ))) {
110967
110983
  delete pageMap2[key];
110968
110984
  }
110969
- console.debug("Page map", pageMap2, resourceMap);
110970
110985
  return pageMap2;
110971
110986
  },
110972
110987
  [resourceMap]
@@ -111125,7 +111140,7 @@ schema (${ast._tag}): ${ast}`;
111125
111140
  type: "deactivated_browsing_mode"
111126
111141
  }), [])
111127
111142
  }
111128
- ), /* @__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) => {
111129
111144
  const isActive2 = uri === activePageResourceURI;
111130
111145
  const isOnlyOneShown = state.visibleResourceURIs.length < 2;
111131
111146
  const isMarkedActive = !isOnlyOneShown && isActive2;
@@ -111276,7 +111291,10 @@ schema (${ast._tag}): ${ast}`;
111276
111291
  if (!parentPath) {
111277
111292
  throw new Error("getAdjacentResource: missing parentPath");
111278
111293
  }
111279
- const parentNavPath = [parentPath, "resource-nav.json"].join("/");
111294
+ const parentNavPath = [
111295
+ parentPath === "/" ? "" : parentPath,
111296
+ "resource-nav.json"
111297
+ ].join("/");
111280
111298
  const parentNav = decodeUnknownSync(ResourceNavSchema)(await (await fetch(parentNavPath, { signal })).json());
111281
111299
  const currentPathTail = currentPath.slice(currentPath.lastIndexOf("/") + 1);
111282
111300
  const children = parentNav.children.map(
@@ -111327,16 +111345,14 @@ schema (${ast._tag}): ${ast}`;
111327
111345
 
111328
111346
  // bootstrap.tsx
111329
111347
  patchLunr();
111330
- getExtensionImports().then(setUpExtensionImportMap).then(initApp);
111331
- function initApp() {
111348
+ getExtensionImports().then(setUpExtensionImportMap).then(hydrateApp);
111349
+ function hydrateApp() {
111332
111350
  const appRoot = document.getElementById("app");
111333
111351
  if (!appRoot) {
111334
111352
  console.error("Can\u2019t initialize the app: missing root");
111335
111353
  return;
111336
111354
  }
111337
- const useStrictMode2 = document.documentElement.dataset.useReactStrict === "true";
111338
111355
  const originalHTML = appRoot.innerHTML;
111339
- document.body.style.height = `${appRoot.clientHeight}px`;
111340
111356
  const app = /* @__PURE__ */ import_react213.default.createElement(ErrorBoundaryWithCustomView_default, { fallback: /* @__PURE__ */ import_react213.default.createElement(
111341
111357
  "div",
111342
111358
  {
@@ -111344,17 +111360,23 @@ schema (${ast._tag}): ${ast}`;
111344
111360
  suppressHydrationWarning: true
111345
111361
  }
111346
111362
  ) }, /* @__PURE__ */ import_react213.default.createElement(AppLoader, null));
111363
+ holdBodyHeightUntilHydrationIsComplete(appRoot.clientHeight);
111364
+ const useStrictMode2 = document.documentElement.dataset.useReactStrict === "true";
111347
111365
  (0, import_client.hydrateRoot)(
111348
111366
  appRoot,
111349
111367
  useStrictMode2 ? /* @__PURE__ */ import_react213.default.createElement(import_react214.StrictMode, null, app) : app
111350
111368
  );
111351
- const observer = new MutationObserver(function cleanUpLoad() {
111369
+ }
111370
+ function holdBodyHeightUntilHydrationIsComplete(heightInPx) {
111371
+ document.body.style.height = `${heightInPx}px`;
111372
+ function unsetHeightAndDisconnectObserverIfHydrated() {
111352
111373
  const hasInitialized = !!document.documentElement.getAttribute("data-react-helmet");
111353
111374
  if (hasInitialized) {
111354
111375
  setTimeout(() => document.body.style.removeProperty("height"), 500);
111355
111376
  observer.disconnect();
111356
111377
  }
111357
- });
111378
+ }
111379
+ const observer = new MutationObserver(unsetHeightAndDisconnectObserverIfHydrated);
111358
111380
  observer.observe(document.documentElement, {
111359
111381
  attributes: true,
111360
111382
  childList: false,