@riboseinc/anafero-cli 0.0.56 → 0.0.58
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/CLI.tsx +4 -1
- package/bootstrap.css +11 -6
- package/bootstrap.css.map +2 -2
- package/bootstrap.js +62 -28
- package/bootstrap.js.map +4 -4
- package/build-site.css +11 -6
- package/build-site.mjs +99 -76
- package/package.json +1 -1
package/bootstrap.js
CHANGED
|
@@ -72212,6 +72212,23 @@ schema (${ast._tag}): ${ast}`;
|
|
|
72212
72212
|
}
|
|
72213
72213
|
});
|
|
72214
72214
|
|
|
72215
|
+
// ../anafero/search.mts
|
|
72216
|
+
function preprocessStringForIndexing(text) {
|
|
72217
|
+
return text.normalize("NFKD").replace(/\p{Diacritic}/gu, "").trim();
|
|
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))
|
|
72222
|
+
);
|
|
72223
|
+
}
|
|
72224
|
+
var init_search = __esm({
|
|
72225
|
+
"../anafero/search.mts"() {
|
|
72226
|
+
"use strict";
|
|
72227
|
+
init_relations();
|
|
72228
|
+
init_URI();
|
|
72229
|
+
}
|
|
72230
|
+
});
|
|
72231
|
+
|
|
72215
72232
|
// ../anafero/index.mts
|
|
72216
72233
|
var anafero_exports = {};
|
|
72217
72234
|
__export(anafero_exports, {
|
|
@@ -72230,6 +72247,7 @@ schema (${ast._tag}): ${ast}`;
|
|
|
72230
72247
|
VersioningSchema: () => VersioningSchema,
|
|
72231
72248
|
dedupeGraph: () => dedupeGraph,
|
|
72232
72249
|
dedupeResourceRelationList: () => dedupeResourceRelationList,
|
|
72250
|
+
extractRelationsForIndexing: () => extractRelationsForIndexing,
|
|
72233
72251
|
fillInLocale: () => fillInLocale,
|
|
72234
72252
|
gatherDescribedResourcesFromJsonifiedProseMirrorNode: () => gatherDescribedResourcesFromJsonifiedProseMirrorNode,
|
|
72235
72253
|
gatherTextFromJsonifiedProseMirrorNode: () => gatherTextFromJsonifiedProseMirrorNode,
|
|
@@ -72238,6 +72256,7 @@ schema (${ast._tag}): ${ast}`;
|
|
|
72238
72256
|
isURIString: () => isURIString,
|
|
72239
72257
|
makeDummyInMemoryCache: () => makeDummyInMemoryCache,
|
|
72240
72258
|
parseModuleRef: () => parseModuleRef,
|
|
72259
|
+
preprocessStringForIndexing: () => preprocessStringForIndexing,
|
|
72241
72260
|
resolveChain: () => resolveChain,
|
|
72242
72261
|
stripLeadingSlash: () => stripLeadingSlash,
|
|
72243
72262
|
stripTrailingSlash: () => stripTrailingSlash,
|
|
@@ -72259,6 +72278,7 @@ schema (${ast._tag}): ${ast}`;
|
|
|
72259
72278
|
init_path_utils();
|
|
72260
72279
|
init_graph_query();
|
|
72261
72280
|
init_URI();
|
|
72281
|
+
init_search();
|
|
72262
72282
|
}
|
|
72263
72283
|
});
|
|
72264
72284
|
|
|
@@ -109555,6 +109575,9 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109555
109575
|
}
|
|
109556
109576
|
}
|
|
109557
109577
|
|
|
109578
|
+
// Nav.tsx
|
|
109579
|
+
init_anafero();
|
|
109580
|
+
|
|
109558
109581
|
// style.module.css
|
|
109559
109582
|
var style_default = {
|
|
109560
109583
|
floatingSubresourceLink: "style_floatingSubresourceLink",
|
|
@@ -109602,16 +109625,21 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109602
109625
|
);
|
|
109603
109626
|
};
|
|
109604
109627
|
var MAX_SEARCH_RESULT_COUNT = 100;
|
|
109628
|
+
function resultRefToResourceURI(ref) {
|
|
109629
|
+
return ref;
|
|
109630
|
+
}
|
|
109605
109631
|
var Search = function({ index, selected, onSelect, query, getPlainTitle, locateResource, getContainingPageURI, onEditQueryText }) {
|
|
109606
109632
|
const [debouncedQuery] = a(query.text, 200);
|
|
109607
109633
|
const [showMore, setShowMore] = (0, import_react204.useState)(false);
|
|
109608
109634
|
const [matches2, error] = (0, import_react204.useMemo)(() => {
|
|
109609
109635
|
if (index && debouncedQuery.trim() !== "") {
|
|
109610
|
-
const normalizedQuery =
|
|
109636
|
+
const normalizedQuery = preprocessStringForIndexing(
|
|
109637
|
+
debouncedQuery.replace(/:/g, " ").replace(/\*/g, " ")
|
|
109638
|
+
);
|
|
109611
109639
|
const tokens = import_lunr.default.tokenizer(normalizedQuery);
|
|
109612
109640
|
console.debug("Search: tokens", tokens);
|
|
109613
109641
|
const escapedQuery = normalizedQuery.replaceAll(" ", "*");
|
|
109614
|
-
const pipelineOut = index.pipeline.
|
|
109642
|
+
const pipelineOut = index.pipeline.run(tokens);
|
|
109615
109643
|
console.debug("Search: pipeline result for", normalizedQuery, "is", pipelineOut);
|
|
109616
109644
|
console.debug("pip", index?.pipeline?._stack);
|
|
109617
109645
|
console.debug("searchpip", index?.searchPipeline);
|
|
@@ -109619,9 +109647,11 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109619
109647
|
let exact;
|
|
109620
109648
|
try {
|
|
109621
109649
|
exact = (index.query((query2) => {
|
|
109622
|
-
|
|
109623
|
-
|
|
109624
|
-
|
|
109650
|
+
for (const t2 of tokens) {
|
|
109651
|
+
query2.term(t2, {
|
|
109652
|
+
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109653
|
+
});
|
|
109654
|
+
}
|
|
109625
109655
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT);
|
|
109626
109656
|
} catch (e2) {
|
|
109627
109657
|
exact = [];
|
|
@@ -109630,15 +109660,13 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109630
109660
|
const full = exact.length < 1 || showMore ? (index.query((query2) => {
|
|
109631
109661
|
for (const t2 of tokens) {
|
|
109632
109662
|
query2.term(t2, {
|
|
109633
|
-
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109634
|
-
wildcard: import_lunr.default.Query.wildcard.LEADING | import_lunr.default.Query.wildcard.TRAILING
|
|
109663
|
+
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109635
109664
|
});
|
|
109636
109665
|
}
|
|
109637
109666
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
|
|
109638
109667
|
const partial5 = exact.length < 1 && full.length < 1 || showMore ? (index.query((query2) => {
|
|
109639
109668
|
query2.term(tokens, {
|
|
109640
|
-
presence: import_lunr.default.Query.presence.OPTIONAL
|
|
109641
|
-
wildcard: import_lunr.default.Query.wildcard.LEADING | import_lunr.default.Query.wildcard.TRAILING
|
|
109669
|
+
presence: import_lunr.default.Query.presence.OPTIONAL
|
|
109642
109670
|
});
|
|
109643
109671
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
|
|
109644
109672
|
return [{ exact, full, partial: partial5 }, null];
|
|
@@ -109661,25 +109689,26 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109661
109689
|
}) ?? []).reduce((prev, curr) => ({ ...prev, ...curr }), {});
|
|
109662
109690
|
}, [matches2]);
|
|
109663
109691
|
const resultMetadata = (0, import_react204.useMemo)(() => {
|
|
109664
|
-
return (Object.
|
|
109665
|
-
const
|
|
109692
|
+
return (Object.keys(results).map((ref) => {
|
|
109693
|
+
const resourceURI = resultRefToResourceURI(ref);
|
|
109694
|
+
const title = getPlainTitle(resourceURI);
|
|
109666
109695
|
let path;
|
|
109667
109696
|
try {
|
|
109668
|
-
path = locateResource(
|
|
109697
|
+
path = locateResource(resourceURI);
|
|
109669
109698
|
} catch (e2) {
|
|
109670
|
-
console.error("Failed to get path for
|
|
109699
|
+
console.error("Failed to get resource path for result", ref);
|
|
109671
109700
|
path = void 0;
|
|
109672
109701
|
}
|
|
109673
109702
|
let pageResource;
|
|
109674
109703
|
try {
|
|
109675
|
-
const
|
|
109676
|
-
const title2 = getPlainTitle(
|
|
109677
|
-
pageResource = { uri, title: title2 };
|
|
109704
|
+
const pageURI = getContainingPageURI(resourceURI);
|
|
109705
|
+
const title2 = getPlainTitle(pageURI);
|
|
109706
|
+
pageResource = { uri: pageURI, title: title2 };
|
|
109678
109707
|
} catch (e2) {
|
|
109679
|
-
console.error("Failed to get containing page resource URI for",
|
|
109708
|
+
console.error("Failed to get containing page resource URI for", ref);
|
|
109680
109709
|
pageResource = void 0;
|
|
109681
109710
|
}
|
|
109682
|
-
return { [ref]: { path, title, pageResource } };
|
|
109711
|
+
return { [ref]: { uri: resourceURI, path, title, pageResource } };
|
|
109683
109712
|
}) ?? []).reduce((prev, curr) => ({ ...prev, ...curr }), {});
|
|
109684
109713
|
}, [results, getPlainTitle, locateResource, getContainingPageURI]);
|
|
109685
109714
|
const resultArray = (0, import_react204.useMemo)(() => {
|
|
@@ -109695,15 +109724,16 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109695
109724
|
setShowMore(false);
|
|
109696
109725
|
}, [debouncedQuery]);
|
|
109697
109726
|
const renderItem = (0, import_react204.useCallback)((result) => {
|
|
109698
|
-
const
|
|
109727
|
+
const meta = resultMetadata[result.ref];
|
|
109728
|
+
const title = meta?.title ?? "Untitled";
|
|
109699
109729
|
return /* @__PURE__ */ import_react204.default.createElement(
|
|
109700
109730
|
$c1d7fb2ec91bae71$export$6d08773d2e66f8f2,
|
|
109701
109731
|
{
|
|
109702
109732
|
key: result.ref,
|
|
109703
109733
|
textValue: title
|
|
109704
109734
|
},
|
|
109705
|
-
/* @__PURE__ */ import_react204.default.createElement($cd449e8defa988f0$export$5f1af8db9871e1d6, { UNSAFE_className: style_default.navListViewItemWithLink }, /* @__PURE__ */ import_react204.default.createElement($3c5235ac12f2c9bb$export$a6c7ac8248d6e38a, { href:
|
|
109706
|
-
/* @__PURE__ */ import_react204.default.createElement($cd449e8defa988f0$export$5f1af8db9871e1d6, { slot: "description" },
|
|
109735
|
+
/* @__PURE__ */ import_react204.default.createElement($cd449e8defa988f0$export$5f1af8db9871e1d6, { UNSAFE_className: style_default.navListViewItemWithLink }, /* @__PURE__ */ import_react204.default.createElement($3c5235ac12f2c9bb$export$a6c7ac8248d6e38a, { href: meta?.path ?? "javascript: void 0;" }, title)),
|
|
109736
|
+
/* @__PURE__ */ import_react204.default.createElement($cd449e8defa988f0$export$5f1af8db9871e1d6, { slot: "description" }, meta?.pageResource?.title ?? "")
|
|
109707
109737
|
);
|
|
109708
109738
|
}, [showMore, getPlainTitle, resultMetadata]);
|
|
109709
109739
|
const showMoreButton = matches2.exact.length > 0 || matches2.full.length > 0 ? /* @__PURE__ */ import_react204.default.createElement("a", { onClick: () => setShowMore(!showMore) }, "(", showMore ? "Show fewer" : "Check for more matches", ")") : null;
|
|
@@ -110098,6 +110128,7 @@ schema (${ast._tag}): ${ast}`;
|
|
|
110098
110128
|
className,
|
|
110099
110129
|
requestedResourceURI,
|
|
110100
110130
|
searchQueryText,
|
|
110131
|
+
hideBreadcrumbs,
|
|
110101
110132
|
useDependency,
|
|
110102
110133
|
locateResource,
|
|
110103
110134
|
document: document2,
|
|
@@ -110249,7 +110280,7 @@ schema (${ast._tag}): ${ast}`;
|
|
|
110249
110280
|
className: `${style_default.resource} ${className ?? ""}`,
|
|
110250
110281
|
"aria-selected": ariaSelected
|
|
110251
110282
|
},
|
|
110252
|
-
/* @__PURE__ */ import_react211.default.createElement(ResourceBreadcrumbs, { parents: resourceNav.breadcrumbs }),
|
|
110283
|
+
!hideBreadcrumbs ? /* @__PURE__ */ import_react211.default.createElement(ResourceBreadcrumbs, { parents: resourceNav.breadcrumbs }) : null,
|
|
110253
110284
|
content.content ? /* @__PURE__ */ import_react211.default.createElement(ResourceHelmet, { ...content.content }) : null,
|
|
110254
110285
|
/* @__PURE__ */ import_react211.default.createElement(
|
|
110255
110286
|
Layout,
|
|
@@ -110339,14 +110370,17 @@ schema (${ast._tag}): ${ast}`;
|
|
|
110339
110370
|
return lunrIdx;
|
|
110340
110371
|
}
|
|
110341
110372
|
console.debug("Lunr: initializing");
|
|
110342
|
-
const
|
|
110343
|
-
if (
|
|
110344
|
-
console.debug(`Lunr: enabling extra languages ${
|
|
110345
|
-
for (const lang of
|
|
110346
|
-
LANGUAGE_SUPPORT[lang]
|
|
110373
|
+
const supportedLanguages = ["en", ...Object.keys(LANGUAGE_SUPPORT)];
|
|
110374
|
+
if (supportedLanguages.length > 1) {
|
|
110375
|
+
console.debug(`Lunr: enabling extra languages ${supportedLanguages.join(", ")}`);
|
|
110376
|
+
for (const lang of supportedLanguages) {
|
|
110377
|
+
if (LANGUAGE_SUPPORT[lang]) {
|
|
110378
|
+
LANGUAGE_SUPPORT[lang](import_lunr2.default);
|
|
110379
|
+
}
|
|
110347
110380
|
}
|
|
110348
110381
|
(0, import_lunr5.default)(import_lunr2.default);
|
|
110349
|
-
import_lunr2.default.multiLanguage(...
|
|
110382
|
+
import_lunr2.default.multiLanguage(...supportedLanguages);
|
|
110383
|
+
const nonDefaultLanguages = supportedLanguages.filter((l) => l !== "en");
|
|
110350
110384
|
const lunrTokenizer = import_lunr2.default.tokenizer;
|
|
110351
110385
|
import_lunr2.default.tokenizer = function(x) {
|
|
110352
110386
|
const baseLunrTokens = lunrTokenizer(x);
|