@riboseinc/anafero-cli 0.0.65 → 0.0.67

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
@@ -72214,12 +72214,48 @@ schema (${ast._tag}): ${ast}`;
72214
72214
 
72215
72215
  // ../anafero/search.mts
72216
72216
  function preprocessStringForIndexing(text) {
72217
- return text.normalize("NFKD").replace(/\p{Diacritic}/gu, "").trim();
72217
+ return text.normalize("NFKD").replace(/\p{Diacritic}/gu, "").replace(/[\p{P}$+<=>^`|~]/gu, " ").replace(/[\u200B-\u200D\uFEFF]/g, "").trim();
72218
72218
  }
72219
- function extractRelationsForIndexing(uri, graph, isDefinedSubject) {
72220
- return graph.filter(
72221
- ([s, p, o2]) => p === "hasPart" && (s === uri || s === ROOT_SUBJECT) && !o2.startsWith("data:") && (!isURIString(o2) || !isDefinedSubject(o2))
72219
+ function extractRelationsForIndexing(uri, graph, isIndexable, isAlreadyIndexed, _seen, _log) {
72220
+ const seen = _seen ?? /* @__PURE__ */ new Set();
72221
+ seen.add(uri);
72222
+ const nonData = graph.filter(
72223
+ ([, , o2]) => !o2.startsWith("data:")
72222
72224
  );
72225
+ const immediateGraph = nonData.filter(
72226
+ ([s, ,]) => s === uri || s === ROOT_SUBJECT
72227
+ );
72228
+ const references = immediateGraph.filter(
72229
+ ([, , o2]) => isURIString(o2)
72230
+ );
72231
+ const indexable = immediateGraph.filter(
72232
+ ([s, p, o2]) => !isURIString(o2) && isIndexable([s, p, o2])
72233
+ ).map(([, , o2]) => o2).filter((o2) => o2.trim() !== "");
72234
+ for (const [, , o2] of references) {
72235
+ if (_log) {
72236
+ console.debug(
72237
+ "search: processing triple object",
72238
+ { o: o2, isAlreadyIndexed: isAlreadyIndexed(o2) }
72239
+ );
72240
+ }
72241
+ if (!isAlreadyIndexed(o2) && !seen.has(o2)) {
72242
+ indexable.push(...extractRelationsForIndexing(
72243
+ o2,
72244
+ graph,
72245
+ isIndexable,
72246
+ isAlreadyIndexed,
72247
+ seen,
72248
+ _log
72249
+ ));
72250
+ }
72251
+ }
72252
+ if (_log) {
72253
+ console.debug(
72254
+ "search: obtained indexable from graph",
72255
+ { uri, graph, indexable }
72256
+ );
72257
+ }
72258
+ return indexable;
72223
72259
  }
72224
72260
  var init_search = __esm({
72225
72261
  "../anafero/search.mts"() {
@@ -109636,7 +109672,7 @@ schema (${ast._tag}): ${ast}`;
109636
109672
  const debouncedQueryTrimmed = debouncedQuery.trim();
109637
109673
  if (index && debouncedQueryTrimmed !== "") {
109638
109674
  const normalizedQuery = preprocessStringForIndexing(
109639
- debouncedQuery.replace(/:/g, " ").replace(/\*/g, " ")
109675
+ debouncedQuery.replace(/\*/g, " ")
109640
109676
  );
109641
109677
  const tokens = import_lunr.default.tokenizer(normalizedQuery);
109642
109678
  console.debug("Search: tokens", tokens);
@@ -110916,15 +110952,15 @@ schema (${ast._tag}): ${ast}`;
110916
110952
  }
110917
110953
  }, [locateResource, state.activeResourceURI]);
110918
110954
  const [resourceContainerElement, setResourceContainerElement] = (0, import_react212.useState)(null);
110919
- const setUpInterceptor = (0, import_react212.useCallback)((resourcesRef) => {
110920
- if (resourcesRef) {
110921
- setResourceContainerElement(resourcesRef);
110955
+ (0, import_react212.useEffect)(() => {
110956
+ if (!resourceContainerElement || !getVersionRelativePath) {
110957
+ return;
110922
110958
  }
110923
- intercept_nav_default(resourcesRef, {
110959
+ const cleanUpInterceptor = intercept_nav_default(resourceContainerElement, {
110924
110960
  // shadowDom: true,
110925
110961
  }, function handleIntercept(evt, el) {
110926
110962
  const href = el.getAttribute("href");
110927
- if (!href || !getVersionRelativePath) {
110963
+ if (!href) {
110928
110964
  return;
110929
110965
  }
110930
110966
  const url2 = new URL(href, document.baseURI);
@@ -110944,7 +110980,18 @@ schema (${ast._tag}): ${ast}`;
110944
110980
  return true;
110945
110981
  }
110946
110982
  });
110947
- }, [reverseResource, getVersionRelativePath, getContainingPageResourceURI]);
110983
+ return cleanUpInterceptor;
110984
+ }, [
110985
+ resourceContainerElement,
110986
+ reverseResource,
110987
+ getVersionRelativePath,
110988
+ getContainingPageResourceURI
110989
+ ]);
110990
+ const refResourceContainerElement = (0, import_react212.useCallback)((resourcesRef) => {
110991
+ if (resourcesRef) {
110992
+ setResourceContainerElement(resourcesRef);
110993
+ }
110994
+ }, [setResourceContainerElement]);
110948
110995
  const [queuedFragment, setQueuedFragment] = (0, import_react212.useState)("");
110949
110996
  const jumpTo = (0, import_react212.useCallback)((uri) => {
110950
110997
  if (getContainingPageResourceURI(uri) === uri) {
@@ -110959,7 +111006,7 @@ schema (${ast._tag}): ${ast}`;
110959
111006
  console.error("Unable to reverse resource URI for path", path);
110960
111007
  throw new Error("Unable to reverse resource URI for path");
110961
111008
  }
110962
- console.debug("Navigating & activating resource", resourceURI);
111009
+ console.debug("Navigating & activating resource via router", resourceURI);
110963
111010
  dispatch({ type: "activated_resource", uri: resourceURI, pageURI: getContainingPageResourceURI(resourceURI) });
110964
111011
  }, [reverseResource, jumpTo, getContainingPageResourceURI]);
110965
111012
  const pageMap = (0, import_react212.useMemo)(
@@ -111129,7 +111176,7 @@ schema (${ast._tag}): ${ast}`;
111129
111176
  type: "deactivated_browsing_mode"
111130
111177
  }), [])
111131
111178
  }
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) => {
111179
+ ), /* @__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
111180
  const isActive2 = uri === activePageResourceURI;
111134
111181
  const isOnlyOneShown = state.visibleResourceURIs.length < 2;
111135
111182
  const isMarkedActive = !isOnlyOneShown && isActive2;
@@ -111280,7 +111327,10 @@ schema (${ast._tag}): ${ast}`;
111280
111327
  if (!parentPath) {
111281
111328
  throw new Error("getAdjacentResource: missing parentPath");
111282
111329
  }
111283
- const parentNavPath = [parentPath, "resource-nav.json"].join("/");
111330
+ const parentNavPath = [
111331
+ parentPath === "/" ? "" : parentPath,
111332
+ "resource-nav.json"
111333
+ ].join("/");
111284
111334
  const parentNav = decodeUnknownSync(ResourceNavSchema)(await (await fetch(parentNavPath, { signal })).json());
111285
111335
  const currentPathTail = currentPath.slice(currentPath.lastIndexOf("/") + 1);
111286
111336
  const children = parentNav.children.map(
@@ -111331,16 +111381,14 @@ schema (${ast._tag}): ${ast}`;
111331
111381
 
111332
111382
  // bootstrap.tsx
111333
111383
  patchLunr();
111334
- getExtensionImports().then(setUpExtensionImportMap).then(initApp);
111335
- function initApp() {
111384
+ getExtensionImports().then(setUpExtensionImportMap).then(hydrateApp);
111385
+ function hydrateApp() {
111336
111386
  const appRoot = document.getElementById("app");
111337
111387
  if (!appRoot) {
111338
111388
  console.error("Can\u2019t initialize the app: missing root");
111339
111389
  return;
111340
111390
  }
111341
- const useStrictMode2 = document.documentElement.dataset.useReactStrict === "true";
111342
111391
  const originalHTML = appRoot.innerHTML;
111343
- document.body.style.height = `${appRoot.clientHeight}px`;
111344
111392
  const app = /* @__PURE__ */ import_react213.default.createElement(ErrorBoundaryWithCustomView_default, { fallback: /* @__PURE__ */ import_react213.default.createElement(
111345
111393
  "div",
111346
111394
  {
@@ -111348,17 +111396,23 @@ schema (${ast._tag}): ${ast}`;
111348
111396
  suppressHydrationWarning: true
111349
111397
  }
111350
111398
  ) }, /* @__PURE__ */ import_react213.default.createElement(AppLoader, null));
111399
+ holdBodyHeightUntilHydrationIsComplete(appRoot.clientHeight);
111400
+ const useStrictMode2 = document.documentElement.dataset.useReactStrict === "true";
111351
111401
  (0, import_client.hydrateRoot)(
111352
111402
  appRoot,
111353
111403
  useStrictMode2 ? /* @__PURE__ */ import_react213.default.createElement(import_react214.StrictMode, null, app) : app
111354
111404
  );
111355
- const observer = new MutationObserver(function cleanUpLoad() {
111405
+ }
111406
+ function holdBodyHeightUntilHydrationIsComplete(heightInPx) {
111407
+ document.body.style.height = `${heightInPx}px`;
111408
+ function unsetHeightAndDisconnectObserverIfHydrated() {
111356
111409
  const hasInitialized = !!document.documentElement.getAttribute("data-react-helmet");
111357
111410
  if (hasInitialized) {
111358
111411
  setTimeout(() => document.body.style.removeProperty("height"), 500);
111359
111412
  observer.disconnect();
111360
111413
  }
111361
- });
111414
+ }
111415
+ const observer = new MutationObserver(unsetHeightAndDisconnectObserverIfHydrated);
111362
111416
  observer.observe(document.documentElement, {
111363
111417
  attributes: true,
111364
111418
  childList: false,