@riboseinc/anafero-cli 0.0.55 → 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 +39 -29
- package/bootstrap.js.map +3 -3
- package/build-site.mjs +155 -140
- package/package.json +1 -1
package/bootstrap.js
CHANGED
|
@@ -69039,7 +69039,9 @@ schema (${ast._tag}): ${ast}`;
|
|
|
69039
69039
|
// TODO: rich ProseMirror labels?
|
|
69040
69040
|
labelInPlainText: String$2.pipe(nonEmptyString3()),
|
|
69041
69041
|
// TODO: proper schema for ISO language IDs
|
|
69042
|
-
primaryLanguageID: String$2.pipe(optional2)
|
|
69042
|
+
primaryLanguageID: String$2.pipe(optional2),
|
|
69043
|
+
/** License/copyright for the resource in question. */
|
|
69044
|
+
license: Any2.pipe(optional2)
|
|
69043
69045
|
}));
|
|
69044
69046
|
DEFAULT_LOCALE = {
|
|
69045
69047
|
ar: "ar-AE",
|
|
@@ -109600,16 +109602,19 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109600
109602
|
);
|
|
109601
109603
|
};
|
|
109602
109604
|
var MAX_SEARCH_RESULT_COUNT = 100;
|
|
109605
|
+
function resultRefToResourceURI(ref) {
|
|
109606
|
+
return ref;
|
|
109607
|
+
}
|
|
109603
109608
|
var Search = function({ index, selected, onSelect, query, getPlainTitle, locateResource, getContainingPageURI, onEditQueryText }) {
|
|
109604
109609
|
const [debouncedQuery] = a(query.text, 200);
|
|
109605
109610
|
const [showMore, setShowMore] = (0, import_react204.useState)(false);
|
|
109606
109611
|
const [matches2, error] = (0, import_react204.useMemo)(() => {
|
|
109607
109612
|
if (index && debouncedQuery.trim() !== "") {
|
|
109608
|
-
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();
|
|
109609
109614
|
const tokens = import_lunr.default.tokenizer(normalizedQuery);
|
|
109610
109615
|
console.debug("Search: tokens", tokens);
|
|
109611
109616
|
const escapedQuery = normalizedQuery.replaceAll(" ", "*");
|
|
109612
|
-
const pipelineOut = index.pipeline.
|
|
109617
|
+
const pipelineOut = index.pipeline.run(tokens);
|
|
109613
109618
|
console.debug("Search: pipeline result for", normalizedQuery, "is", pipelineOut);
|
|
109614
109619
|
console.debug("pip", index?.pipeline?._stack);
|
|
109615
109620
|
console.debug("searchpip", index?.searchPipeline);
|
|
@@ -109617,9 +109622,11 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109617
109622
|
let exact;
|
|
109618
109623
|
try {
|
|
109619
109624
|
exact = (index.query((query2) => {
|
|
109620
|
-
|
|
109621
|
-
|
|
109622
|
-
|
|
109625
|
+
for (const t2 of tokens) {
|
|
109626
|
+
query2.term(t2, {
|
|
109627
|
+
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109628
|
+
});
|
|
109629
|
+
}
|
|
109623
109630
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT);
|
|
109624
109631
|
} catch (e2) {
|
|
109625
109632
|
exact = [];
|
|
@@ -109628,15 +109635,13 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109628
109635
|
const full = exact.length < 1 || showMore ? (index.query((query2) => {
|
|
109629
109636
|
for (const t2 of tokens) {
|
|
109630
109637
|
query2.term(t2, {
|
|
109631
|
-
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109632
|
-
wildcard: import_lunr.default.Query.wildcard.LEADING | import_lunr.default.Query.wildcard.TRAILING
|
|
109638
|
+
presence: import_lunr.default.Query.presence.REQUIRED
|
|
109633
109639
|
});
|
|
109634
109640
|
}
|
|
109635
109641
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
|
|
109636
109642
|
const partial5 = exact.length < 1 && full.length < 1 || showMore ? (index.query((query2) => {
|
|
109637
109643
|
query2.term(tokens, {
|
|
109638
|
-
presence: import_lunr.default.Query.presence.OPTIONAL
|
|
109639
|
-
wildcard: import_lunr.default.Query.wildcard.LEADING | import_lunr.default.Query.wildcard.TRAILING
|
|
109644
|
+
presence: import_lunr.default.Query.presence.OPTIONAL
|
|
109640
109645
|
});
|
|
109641
109646
|
}) ?? []).slice(0, MAX_SEARCH_RESULT_COUNT) : [];
|
|
109642
109647
|
return [{ exact, full, partial: partial5 }, null];
|
|
@@ -109659,25 +109664,26 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109659
109664
|
}) ?? []).reduce((prev, curr) => ({ ...prev, ...curr }), {});
|
|
109660
109665
|
}, [matches2]);
|
|
109661
109666
|
const resultMetadata = (0, import_react204.useMemo)(() => {
|
|
109662
|
-
return (Object.
|
|
109663
|
-
const
|
|
109667
|
+
return (Object.keys(results).map((ref) => {
|
|
109668
|
+
const resourceURI = resultRefToResourceURI(ref);
|
|
109669
|
+
const title = getPlainTitle(resourceURI);
|
|
109664
109670
|
let path;
|
|
109665
109671
|
try {
|
|
109666
|
-
path = locateResource(
|
|
109672
|
+
path = locateResource(resourceURI);
|
|
109667
109673
|
} catch (e2) {
|
|
109668
|
-
console.error("Failed to get path for
|
|
109674
|
+
console.error("Failed to get resource path for result", ref);
|
|
109669
109675
|
path = void 0;
|
|
109670
109676
|
}
|
|
109671
109677
|
let pageResource;
|
|
109672
109678
|
try {
|
|
109673
|
-
const
|
|
109674
|
-
const title2 = getPlainTitle(
|
|
109675
|
-
pageResource = { uri, title: title2 };
|
|
109679
|
+
const pageURI = getContainingPageURI(resourceURI);
|
|
109680
|
+
const title2 = getPlainTitle(pageURI);
|
|
109681
|
+
pageResource = { uri: pageURI, title: title2 };
|
|
109676
109682
|
} catch (e2) {
|
|
109677
|
-
console.error("Failed to get containing page resource URI for",
|
|
109683
|
+
console.error("Failed to get containing page resource URI for", ref);
|
|
109678
109684
|
pageResource = void 0;
|
|
109679
109685
|
}
|
|
109680
|
-
return { [ref]: { path, title, pageResource } };
|
|
109686
|
+
return { [ref]: { uri: resourceURI, path, title, pageResource } };
|
|
109681
109687
|
}) ?? []).reduce((prev, curr) => ({ ...prev, ...curr }), {});
|
|
109682
109688
|
}, [results, getPlainTitle, locateResource, getContainingPageURI]);
|
|
109683
109689
|
const resultArray = (0, import_react204.useMemo)(() => {
|
|
@@ -109693,15 +109699,16 @@ schema (${ast._tag}): ${ast}`;
|
|
|
109693
109699
|
setShowMore(false);
|
|
109694
109700
|
}, [debouncedQuery]);
|
|
109695
109701
|
const renderItem = (0, import_react204.useCallback)((result) => {
|
|
109696
|
-
const
|
|
109702
|
+
const meta = resultMetadata[result.ref];
|
|
109703
|
+
const title = meta?.title ?? "Untitled";
|
|
109697
109704
|
return /* @__PURE__ */ import_react204.default.createElement(
|
|
109698
109705
|
$c1d7fb2ec91bae71$export$6d08773d2e66f8f2,
|
|
109699
109706
|
{
|
|
109700
109707
|
key: result.ref,
|
|
109701
109708
|
textValue: title
|
|
109702
109709
|
},
|
|
109703
|
-
/* @__PURE__ */ import_react204.default.createElement($cd449e8defa988f0$export$5f1af8db9871e1d6, { UNSAFE_className: style_default.navListViewItemWithLink }, /* @__PURE__ */ import_react204.default.createElement($3c5235ac12f2c9bb$export$a6c7ac8248d6e38a, { href:
|
|
109704
|
-
/* @__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 ?? "")
|
|
109705
109712
|
);
|
|
109706
109713
|
}, [showMore, getPlainTitle, resultMetadata]);
|
|
109707
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;
|
|
@@ -110337,14 +110344,17 @@ schema (${ast._tag}): ${ast}`;
|
|
|
110337
110344
|
return lunrIdx;
|
|
110338
110345
|
}
|
|
110339
110346
|
console.debug("Lunr: initializing");
|
|
110340
|
-
const
|
|
110341
|
-
if (
|
|
110342
|
-
console.debug(`Lunr: enabling extra languages ${
|
|
110343
|
-
for (const lang of
|
|
110344
|
-
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
|
+
}
|
|
110345
110354
|
}
|
|
110346
110355
|
(0, import_lunr5.default)(import_lunr2.default);
|
|
110347
|
-
import_lunr2.default.multiLanguage(...
|
|
110356
|
+
import_lunr2.default.multiLanguage(...supportedLanguages);
|
|
110357
|
+
const nonDefaultLanguages = supportedLanguages.filter((l) => l !== "en");
|
|
110348
110358
|
const lunrTokenizer = import_lunr2.default.tokenizer;
|
|
110349
110359
|
import_lunr2.default.tokenizer = function(x) {
|
|
110350
110360
|
const baseLunrTokens = lunrTokenizer(x);
|
|
@@ -110365,7 +110375,7 @@ schema (${ast._tag}): ${ast}`;
|
|
|
110365
110375
|
const lunrStopWordFilter = import_lunr2.default.stopWordFilter;
|
|
110366
110376
|
import_lunr2.default.stopWordFilter = function(token) {
|
|
110367
110377
|
return lunrStopWordFilter(token) && !nonDefaultLanguages.map(
|
|
110368
|
-
(lang) => import_lunr2.default[lang].stopWordFilter(token)
|
|
110378
|
+
(lang) => !!import_lunr2.default[lang].stopWordFilter(token)
|
|
110369
110379
|
).includes(false) ? token : void 0;
|
|
110370
110380
|
};
|
|
110371
110381
|
}
|