@riboseinc/anafero-cli 0.0.56 → 0.0.57
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 +35 -27
- package/bootstrap.js.map +3 -3
- package/build-site.mjs +19 -18
- package/package.json +1 -1
package/bootstrap.js
CHANGED
|
@@ -109602,16 +109602,19 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109602
109602
|
);
|
|
109603
109603
|
};
|
|
109604
109604
|
var MAX_SEARCH_RESULT_COUNT = 100;
|
|
109605
|
+
function resultRefToResourceURI(ref) {
|
|
109606
|
+
return ref;
|
|
109607
|
+
}
|
|
109605
109608
|
var Search = function({ index, selected, onSelect, query, getPlainTitle, locateResource, getContainingPageURI, onEditQueryText }) {
|
|
109606
109609
|
const [debouncedQuery] = a(query.text, 200);
|
|
109607
109610
|
const [showMore, setShowMore] = (0, import_react204.useState)(false);
|
|
109608
109611
|
const [matches2, error] = (0, import_react204.useMemo)(() => {
|
|
109609
109612
|
if (index && debouncedQuery.trim() !== "") {
|
|
109610
|
-
const normalizedQuery = debouncedQuery.replace(/:/g, " ").normalize("NFKD").replace(/\p{Diacritic}/gu, "").trim();
|
|
109613
|
+
const normalizedQuery = debouncedQuery.replace(/:/g, " ").replace(/\*/g, " ").normalize("NFKD").replace(/\p{Diacritic}/gu, "").trim();
|
|
109611
109614
|
const tokens = import_lunr.default.tokenizer(normalizedQuery);
|
|
109612
109615
|
console.debug("Search: tokens", tokens);
|
|
109613
109616
|
const escapedQuery = normalizedQuery.replaceAll(" ", "*");
|
|
109614
|
-
const pipelineOut = index.pipeline.
|
|
109617
|
+
const pipelineOut = index.pipeline.run(tokens);
|
|
109615
109618
|
console.debug("Search: pipeline result for", normalizedQuery, "is", pipelineOut);
|
|
109616
109619
|
console.debug("pip", index?.pipeline?._stack);
|
|
109617
109620
|
console.debug("searchpip", index?.searchPipeline);
|
|
@@ -109619,9 +109622,11 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109619
109622
|
let exact;
|
|
109620
109623
|
try {
|
|
109621
109624
|
exact = (index.query((query2) => {
|
|
109622
|
-
|
|
109623
|
-
|
|
109624
|
-
|
|
109625
|
+
for (const t2 of tokens) {
|
|
109626
|
+
query2.term(t2, {
|
|
109627
|
+
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109628
|
+
});
|
|
109629
|
+
}
|
|
109625
109630
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT);
|
|
109626
109631
|
} catch (e2) {
|
|
109627
109632
|
exact = [];
|
|
@@ -109630,15 +109635,13 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109630
109635
|
const full = exact.length < 1 || showMore ? (index.query((query2) => {
|
|
109631
109636
|
for (const t2 of tokens) {
|
|
109632
109637
|
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
|
|
109638
|
+
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109635
109639
|
});
|
|
109636
109640
|
}
|
|
109637
109641
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
|
|
109638
109642
|
const partial5 = exact.length < 1 && full.length < 1 || showMore ? (index.query((query2) => {
|
|
109639
109643
|
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
|
|
109644
|
+
presence: import_lunr.default.Query.presence.OPTIONAL
|
|
109642
109645
|
});
|
|
109643
109646
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
|
|
109644
109647
|
return [{ exact, full, partial: partial5 }, null];
|
|
@@ -109661,25 +109664,26 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109661
109664
|
}) ?? []).reduce((prev, curr) => ({ ...prev, ...curr }), {});
|
|
109662
109665
|
}, [matches2]);
|
|
109663
109666
|
const resultMetadata = (0, import_react204.useMemo)(() => {
|
|
109664
|
-
return (Object.
|
|
109665
|
-
const
|
|
109667
|
+
return (Object.keys(results).map((ref) => {
|
|
109668
|
+
const resourceURI = resultRefToResourceURI(ref);
|
|
109669
|
+
const title = getPlainTitle(resourceURI);
|
|
109666
109670
|
let path;
|
|
109667
109671
|
try {
|
|
109668
|
-
path = locateResource(
|
|
109672
|
+
path = locateResource(resourceURI);
|
|
109669
109673
|
} catch (e2) {
|
|
109670
|
-
console.error("Failed to get path for
|
|
109674
|
+
console.error("Failed to get resource path for result", ref);
|
|
109671
109675
|
path = void 0;
|
|
109672
109676
|
}
|
|
109673
109677
|
let pageResource;
|
|
109674
109678
|
try {
|
|
109675
|
-
const
|
|
109676
|
-
const title2 = getPlainTitle(
|
|
109677
|
-
pageResource = { uri, title: title2 };
|
|
109679
|
+
const pageURI = getContainingPageURI(resourceURI);
|
|
109680
|
+
const title2 = getPlainTitle(pageURI);
|
|
109681
|
+
pageResource = { uri: pageURI, title: title2 };
|
|
109678
109682
|
} catch (e2) {
|
|
109679
|
-
console.error("Failed to get containing page resource URI for",
|
|
109683
|
+
console.error("Failed to get containing page resource URI for", ref);
|
|
109680
109684
|
pageResource = void 0;
|
|
109681
109685
|
}
|
|
109682
|
-
return { [ref]: { path, title, pageResource } };
|
|
109686
|
+
return { [ref]: { uri: resourceURI, path, title, pageResource } };
|
|
109683
109687
|
}) ?? []).reduce((prev, curr) => ({ ...prev, ...curr }), {});
|
|
109684
109688
|
}, [results, getPlainTitle, locateResource, getContainingPageURI]);
|
|
109685
109689
|
const resultArray = (0, import_react204.useMemo)(() => {
|
|
@@ -109695,15 +109699,16 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109695
109699
|
setShowMore(false);
|
|
109696
109700
|
}, [debouncedQuery]);
|
|
109697
109701
|
const renderItem = (0, import_react204.useCallback)((result) => {
|
|
109698
|
-
const
|
|
109702
|
+
const meta = resultMetadata[result.ref];
|
|
109703
|
+
const title = meta?.title ?? "Untitled";
|
|
109699
109704
|
return /* @__PURE__ */ import_react204.default.createElement(
|
|
109700
109705
|
$c1d7fb2ec91bae71$export$6d08773d2e66f8f2,
|
|
109701
109706
|
{
|
|
109702
109707
|
key: result.ref,
|
|
109703
109708
|
textValue: title
|
|
109704
109709
|
},
|
|
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" },
|
|
109710
|
+
/* @__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)),
|
|
109711
|
+
/* @__PURE__ */ import_react204.default.createElement($cd449e8defa988f0$export$5f1af8db9871e1d6, { slot: "description" }, meta?.pageResource?.title ?? "")
|
|
109707
109712
|
);
|
|
109708
109713
|
}, [showMore, getPlainTitle, resultMetadata]);
|
|
109709
109714
|
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;
|
|
@@ -110339,14 +110344,17 @@ schema (${ast._tag}): ${ast}`;
|
|
|
110339
110344
|
return lunrIdx;
|
|
110340
110345
|
}
|
|
110341
110346
|
console.debug("Lunr: initializing");
|
|
110342
|
-
const
|
|
110343
|
-
if (
|
|
110344
|
-
console.debug(`Lunr: enabling extra languages ${
|
|
110345
|
-
for (const lang of
|
|
110346
|
-
LANGUAGE_SUPPORT[lang]
|
|
110347
|
+
const supportedLanguages = ["en", ...Object.keys(LANGUAGE_SUPPORT)];
|
|
110348
|
+
if (supportedLanguages.length > 1) {
|
|
110349
|
+
console.debug(`Lunr: enabling extra languages ${supportedLanguages.join(", ")}`);
|
|
110350
|
+
for (const lang of supportedLanguages) {
|
|
110351
|
+
if (LANGUAGE_SUPPORT[lang]) {
|
|
110352
|
+
LANGUAGE_SUPPORT[lang](import_lunr2.default);
|
|
110353
|
+
}
|
|
110347
110354
|
}
|
|
110348
110355
|
(0, import_lunr5.default)(import_lunr2.default);
|
|
110349
|
-
import_lunr2.default.multiLanguage(...
|
|
110356
|
+
import_lunr2.default.multiLanguage(...supportedLanguages);
|
|
110357
|
+
const nonDefaultLanguages = supportedLanguages.filter((l) => l !== "en");
|
|
110350
110358
|
const lunrTokenizer = import_lunr2.default.tokenizer;
|
|
110351
110359
|
import_lunr2.default.tokenizer = function(x) {
|
|
110352
110360
|
const baseLunrTokens = lunrTokenizer(x);
|