@riboseinc/anafero-cli 0.0.43 → 0.0.44
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 +4 -1
- package/bootstrap.js.map +2 -2
- package/build-site.mjs +137 -50
- package/package.json +1 -1
- package/riboseinc-anafero-cli-0.0.44.tgz +0 -0
- package/riboseinc-anafero-cli-0.0.43.tgz +0 -0
package/build-site.mjs
CHANGED
|
@@ -316479,7 +316479,11 @@ function processAttributes(el, locateResource, reverseResource, onIntegrityViola
|
|
|
316479
316479
|
|
|
316480
316480
|
// ../anafero/ContentReader.mts
|
|
316481
316481
|
init_cjs_shim();
|
|
316482
|
-
var makeContentReader = async function(entryPointURI, storeAdapters,
|
|
316482
|
+
var makeContentReader = async function(entryPointURI, storeAdapters, findContentAdapter, { fetchBlob, reportProgress, decodeXML, cache: cache3 }) {
|
|
316483
|
+
const canonicalURIs = {};
|
|
316484
|
+
const originalURIs = {};
|
|
316485
|
+
const contentAdapters = {};
|
|
316486
|
+
const resourceReaders = {};
|
|
316483
316487
|
let totalPathCount = 0;
|
|
316484
316488
|
let totalRelationCount = 0;
|
|
316485
316489
|
let doneRelationCount = 0;
|
|
@@ -316488,54 +316492,110 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
|
|
|
316488
316492
|
await processRelations(entryPointURI, relationsProgress);
|
|
316489
316493
|
relationsProgress(null);
|
|
316490
316494
|
const [hierarchyProgress] = reportProgress("prepare site structure");
|
|
316491
|
-
processHierarchy(
|
|
316492
|
-
|
|
316493
|
-
|
|
316495
|
+
processHierarchy(
|
|
316496
|
+
canonicalURIs[entryPointURI] ?? entryPointURI,
|
|
316497
|
+
"",
|
|
316498
|
+
function reportHierarchyProgress(state) {
|
|
316499
|
+
hierarchyProgress({ state });
|
|
316500
|
+
}
|
|
316501
|
+
);
|
|
316494
316502
|
hierarchyProgress(null);
|
|
316495
316503
|
}
|
|
316496
316504
|
await process14();
|
|
316497
|
-
async function processRelations(entryPointURI2, onProgress) {
|
|
316505
|
+
async function processRelations(entryPointURI2, onProgress, _seenEntryPoints) {
|
|
316506
|
+
const seenEntryPoints = _seenEntryPoints ?? /* @__PURE__ */ new Set();
|
|
316507
|
+
async function expandURI(uri) {
|
|
316508
|
+
const originalURI2 = originalURIs[uri];
|
|
316509
|
+
const isFileURI = (originalURI2 ?? uri).startsWith("file:");
|
|
316510
|
+
let expanded;
|
|
316511
|
+
if (isFileURI) {
|
|
316512
|
+
const fullFileURI = originalURI2 ?? (entryPointURI2 === uri ? originalURI2 ?? uri : joinFileURI(entryPointURI2, uri));
|
|
316513
|
+
try {
|
|
316514
|
+
resourceReaders[fullFileURI] ??= await startReader(fullFileURI);
|
|
316515
|
+
const canonicalRootResourceURI = resourceReaders[fullFileURI]?.getCanonicalRootURI?.() ?? uri;
|
|
316516
|
+
canonicalURIs[fullFileURI] = canonicalRootResourceURI;
|
|
316517
|
+
originalURIs[canonicalRootResourceURI] = fullFileURI;
|
|
316518
|
+
expanded = canonicalRootResourceURI;
|
|
316519
|
+
} catch (e3) {
|
|
316520
|
+
expanded = fullFileURI;
|
|
316521
|
+
}
|
|
316522
|
+
} else {
|
|
316523
|
+
expanded = `${uri}---${entryPointURI2}`;
|
|
316524
|
+
}
|
|
316525
|
+
return expanded;
|
|
316526
|
+
}
|
|
316527
|
+
const subjectRelations = {};
|
|
316498
316528
|
function handleRelations(triples) {
|
|
316499
|
-
const
|
|
316500
|
-
for (const [s2, predicate, target] of triples) {
|
|
316529
|
+
for (const [s2, predicate, t3] of triples) {
|
|
316501
316530
|
const subject = s2 === ROOT_SUBJECT ? entryPointURI2 : s2;
|
|
316531
|
+
const target = t3;
|
|
316502
316532
|
subjectRelations[subject] ??= [];
|
|
316503
316533
|
subjectRelations[subject].push({ predicate, target });
|
|
316504
|
-
cache3.add(`edges-from/${subject}/${predicate}`, [target]);
|
|
316505
|
-
}
|
|
316506
|
-
for (const [subject, relations] of Object.entries(subjectRelations)) {
|
|
316507
|
-
cache3.add(`edges-from/${subject}`, relations);
|
|
316508
|
-
cache3.add(`${entryPointURI2}/subjects`, [subject]);
|
|
316509
316534
|
}
|
|
316510
316535
|
doneRelationCount += triples.length;
|
|
316511
316536
|
onProgress({ done: doneRelationCount, total: totalRelationCount });
|
|
316512
316537
|
}
|
|
316513
|
-
const
|
|
316514
|
-
|
|
316515
|
-
|
|
316516
|
-
reader
|
|
316517
|
-
|
|
316518
|
-
|
|
316519
|
-
|
|
316520
|
-
|
|
316538
|
+
const canonicalURI = await expandURI(entryPointURI2);
|
|
316539
|
+
const originalURI = originalURIs[canonicalURI] ?? canonicalURI;
|
|
316540
|
+
const reader = resourceReaders[originalURI];
|
|
316541
|
+
if (reader) {
|
|
316542
|
+
totalRelationCount += reader.estimateRelationCount();
|
|
316543
|
+
onProgress({ total: totalRelationCount });
|
|
316544
|
+
reader.discoverAllResources(handleRelations, {
|
|
316545
|
+
onProgress: function(msg) {
|
|
316546
|
+
onProgress({
|
|
316547
|
+
state: `${decodeURIComponent(canonicalURI)}->\u2026->${msg}`
|
|
316548
|
+
});
|
|
316549
|
+
}
|
|
316550
|
+
});
|
|
316551
|
+
}
|
|
316552
|
+
for (const [subject, relations] of Object.entries(subjectRelations)) {
|
|
316553
|
+
delete subjectRelations[subject];
|
|
316554
|
+
const expandedSubject = await expandURI(subject);
|
|
316555
|
+
const expandedRelations = [];
|
|
316556
|
+
for (const { predicate, target } of relations) {
|
|
316557
|
+
let expandedTarget;
|
|
316558
|
+
expandedTarget = isURIString(target) ? await expandURI(target) : target;
|
|
316559
|
+
cache3.add(`edges-from/${expandedSubject}/${predicate}`, [expandedTarget]);
|
|
316560
|
+
expandedRelations.push({ predicate, target: expandedTarget });
|
|
316521
316561
|
}
|
|
316522
|
-
|
|
316562
|
+
cache3.add(`edges-from/${expandedSubject}`, expandedRelations);
|
|
316563
|
+
cache3.add(`${entryPointURI2}/subjects`, [expandedSubject]);
|
|
316564
|
+
}
|
|
316523
316565
|
for (const subject of cache3.iterate(`${entryPointURI2}/subjects`)) {
|
|
316524
316566
|
for (const relation of cache3.iterate(`edges-from/${subject}`)) {
|
|
316525
316567
|
if (isURIString(relation.target)) {
|
|
316526
|
-
if (!
|
|
316527
|
-
|
|
316528
|
-
|
|
316529
|
-
|
|
316530
|
-
|
|
316531
|
-
|
|
316568
|
+
if (!seenEntryPoints.has(relation.target)) {
|
|
316569
|
+
seenEntryPoints.add(relation.target);
|
|
316570
|
+
const originalURI2 = originalURIs[relation.target] ?? relation.target;
|
|
316571
|
+
const isFileURI = originalURI2.startsWith("file:");
|
|
316572
|
+
if (isFileURI) {
|
|
316573
|
+
if (resourceReaders[originalURI2]) {
|
|
316574
|
+
await processRelations(
|
|
316575
|
+
relation.target,
|
|
316576
|
+
onProgress,
|
|
316577
|
+
seenEntryPoints
|
|
316578
|
+
);
|
|
316579
|
+
} else {
|
|
316580
|
+
cache3.add(
|
|
316581
|
+
"unresolved-relations",
|
|
316582
|
+
[[subject, relation.predicate, relation.target]]
|
|
316583
|
+
);
|
|
316584
|
+
console.debug(
|
|
316585
|
+
"Not processing relations for",
|
|
316586
|
+
relation.target,
|
|
316587
|
+
originalURI2
|
|
316588
|
+
);
|
|
316589
|
+
}
|
|
316532
316590
|
}
|
|
316591
|
+
} else {
|
|
316592
|
+
console.debug("URI relation is seen again", relation.target);
|
|
316533
316593
|
}
|
|
316534
316594
|
}
|
|
316535
316595
|
}
|
|
316536
316596
|
}
|
|
316537
316597
|
}
|
|
316538
|
-
function maybeGetPathComponent(relation) {
|
|
316598
|
+
function maybeGetPathComponent(contentAdapter, relation) {
|
|
316539
316599
|
if (!isURIString(relation.target) || contentAdapter.crossReferences?.(relation)) {
|
|
316540
316600
|
return null;
|
|
316541
316601
|
}
|
|
@@ -316611,6 +316671,11 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
|
|
|
316611
316671
|
function getResourceGraph(resourceURI) {
|
|
316612
316672
|
if (!cache3.has(`graphs/${resourceURI}`)) {
|
|
316613
316673
|
cache3.add(`graphs/${resourceURI}`, []);
|
|
316674
|
+
const contentAdapter = contentAdapters[resourceURI];
|
|
316675
|
+
if (!contentAdapter) {
|
|
316676
|
+
console.error("Resource does not have associated content adapter on record", resourceURI);
|
|
316677
|
+
throw new Error("Resource does not have associated content adapter on record");
|
|
316678
|
+
}
|
|
316614
316679
|
const queue = [resourceURI];
|
|
316615
316680
|
while (queue.length > 0) {
|
|
316616
316681
|
const currentResource = queue.pop();
|
|
@@ -316637,7 +316702,8 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
|
|
|
316637
316702
|
}
|
|
316638
316703
|
return cache3.list(`graphs/${resourceURI}`);
|
|
316639
316704
|
}
|
|
316640
|
-
function processResourceContents(resourceURI, containingResourcePath, _seen) {
|
|
316705
|
+
function processResourceContents(contentAdapter, resourceURI, containingResourcePath, _seen) {
|
|
316706
|
+
contentAdapters[resourceURI] = contentAdapter;
|
|
316641
316707
|
const seen = _seen ?? /* @__PURE__ */ new Set();
|
|
316642
316708
|
cache3.set({
|
|
316643
316709
|
[`path-for/${resourceURI}`]: `${containingResourcePath}#${resourceURI}`
|
|
@@ -316650,15 +316716,18 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
|
|
|
316650
316716
|
continue;
|
|
316651
316717
|
} else {
|
|
316652
316718
|
seen.add(key);
|
|
316653
|
-
processResourceContents(rel.target, containingResourcePath, seen);
|
|
316719
|
+
processResourceContents(contentAdapter, rel.target, containingResourcePath, seen);
|
|
316654
316720
|
}
|
|
316655
316721
|
}
|
|
316656
316722
|
}
|
|
316657
316723
|
}
|
|
316658
316724
|
function processHierarchy(resourceURI, pathPrefix, onProgress) {
|
|
316725
|
+
const canonicalURI = canonicalURIs[resourceURI] ?? resourceURI;
|
|
316726
|
+
const contentAdapter = findContentAdapter(canonicalURI);
|
|
316727
|
+
contentAdapters[canonicalURI] = contentAdapter;
|
|
316659
316728
|
cache3.add("all-paths", [pathPrefix]);
|
|
316660
|
-
cache3.set({ [pathPrefix]:
|
|
316661
|
-
cache3.set({ [`path-for/${
|
|
316729
|
+
cache3.set({ [pathPrefix]: canonicalURI });
|
|
316730
|
+
cache3.set({ [`path-for/${canonicalURI}`]: pathPrefix });
|
|
316662
316731
|
onProgress(`${pathPrefix ?? "/"}: ${resourceURI}`);
|
|
316663
316732
|
totalPathCount += 1;
|
|
316664
316733
|
const parentPath = pathPrefix !== "" ? pathPrefix.includes("/") ? pathPrefix.slice(0, pathPrefix.lastIndexOf("/")) : "" : null;
|
|
@@ -316676,8 +316745,8 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
|
|
|
316676
316745
|
[`${pathPrefix}/parents`]: parentPaths
|
|
316677
316746
|
});
|
|
316678
316747
|
}
|
|
316679
|
-
for (const rel of generateRelations(
|
|
316680
|
-
const maybePathComponent = maybeGetPathComponent(rel);
|
|
316748
|
+
for (const rel of generateRelations(canonicalURI)) {
|
|
316749
|
+
const maybePathComponent = maybeGetPathComponent(contentAdapter, rel);
|
|
316681
316750
|
if (maybePathComponent) {
|
|
316682
316751
|
if (!isValidPathComponent(maybePathComponent)) {
|
|
316683
316752
|
console.error("Generated path component is not valid", maybePathComponent, rel);
|
|
@@ -316685,26 +316754,31 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
|
|
|
316685
316754
|
}
|
|
316686
316755
|
const newPath = pathPrefix ? `${pathPrefix}/${maybePathComponent}` : maybePathComponent;
|
|
316687
316756
|
processHierarchy(rel.target, newPath, onProgress);
|
|
316688
|
-
} else {
|
|
316689
|
-
processResourceContents(rel.target, pathPrefix);
|
|
316757
|
+
} else if (isURIString(rel.target)) {
|
|
316758
|
+
processResourceContents(contentAdapter, rel.target, pathPrefix);
|
|
316690
316759
|
}
|
|
316691
316760
|
}
|
|
316692
316761
|
}
|
|
316762
|
+
function getCachedResourceURIForPath(path3) {
|
|
316763
|
+
const resourceURI = cache3.get(path3);
|
|
316764
|
+
if (!resourceURI) {
|
|
316765
|
+
throw new Error("Unable to obtain resource URI for path");
|
|
316766
|
+
}
|
|
316767
|
+
const canonicalURI = canonicalURIs[resourceURI] ?? resourceURI;
|
|
316768
|
+
return canonicalURI;
|
|
316769
|
+
}
|
|
316693
316770
|
function* generateAllPaths() {
|
|
316694
316771
|
for (const path3 of cache3.iterate("all-paths")) {
|
|
316695
|
-
const resourceURI =
|
|
316696
|
-
if (!resourceURI) {
|
|
316697
|
-
throw new Error("Have path, but not its resource URI during processing");
|
|
316698
|
-
}
|
|
316772
|
+
const resourceURI = getCachedResourceURIForPath(path3);
|
|
316699
316773
|
yield {
|
|
316700
316774
|
path: path3,
|
|
316701
316775
|
resourceURI,
|
|
316702
316776
|
directDescendants: cache3.has(`${path3}/direct-descendants`) ? cache3.list(`${path3}/direct-descendants`).map((path4) => {
|
|
316703
|
-
const res =
|
|
316777
|
+
const res = getCachedResourceURIForPath(path4);
|
|
316704
316778
|
return [`/${path4}`, res, getResourceGraph(res)];
|
|
316705
316779
|
}) : [],
|
|
316706
316780
|
parentChain: path3 !== "" ? cache3.list(`${path3}/parents`).map((path4) => {
|
|
316707
|
-
const res =
|
|
316781
|
+
const res = getCachedResourceURIForPath(path4);
|
|
316708
316782
|
return [`/${path4}`, res, getResourceGraph(res)];
|
|
316709
316783
|
}) : []
|
|
316710
316784
|
};
|
|
@@ -316905,15 +316979,21 @@ async function* generateVersion(cfg, fetchBlobAtThisVersion, {
|
|
|
316905
316979
|
).join("\n");
|
|
316906
316980
|
const extraHead = `${dependencyCSS}
|
|
316907
316981
|
${inject.head ?? ""}`;
|
|
316908
|
-
const
|
|
316909
|
-
|
|
316910
|
-
|
|
316982
|
+
const findContentAdapter = function(resourceURI) {
|
|
316983
|
+
for (const [moduleID, contentAdapter] of Object.entries(contentAdapters)) {
|
|
316984
|
+
if (contentAdapter.canGenerateContent(resourceURI)) {
|
|
316985
|
+
return [moduleID, contentAdapter];
|
|
316986
|
+
}
|
|
316987
|
+
}
|
|
316988
|
+
throw new Error(`No content adapters report capability to generate content for ${resourceURI}`);
|
|
316911
316989
|
};
|
|
316912
316990
|
const [contentReaderInitProgress, contentReaderSubtask] = reportProgress("read source data");
|
|
316913
316991
|
const reader = await makeContentReader(
|
|
316914
316992
|
cfg.entryPoint,
|
|
316915
316993
|
Object.values(storeAdapters),
|
|
316916
|
-
|
|
316994
|
+
function _findContentAdapter(resourceURI) {
|
|
316995
|
+
return findContentAdapter(resourceURI)[1];
|
|
316996
|
+
},
|
|
316917
316997
|
{
|
|
316918
316998
|
fetchBlob: fetchBlobAtThisVersion,
|
|
316919
316999
|
decodeXML,
|
|
@@ -316947,6 +317027,13 @@ ${inject.head ?? ""}`;
|
|
|
316947
317027
|
const [allPathProgress, pathSubtask] = reportProgress("build page content", { total: totalPaths, done: done11 });
|
|
316948
317028
|
const hierarchicalResources = reader.generatePaths();
|
|
316949
317029
|
for (const { path: path3, resourceURI, parentChain, directDescendants } of hierarchicalResources) {
|
|
317030
|
+
let contentAdapter;
|
|
317031
|
+
try {
|
|
317032
|
+
contentAdapter = findContentAdapter(resourceURI)?.[1];
|
|
317033
|
+
} catch (e3) {
|
|
317034
|
+
console.error("Unable to find content adapter for resource", resourceURI, e3);
|
|
317035
|
+
continue;
|
|
317036
|
+
}
|
|
316950
317037
|
done11 += 1;
|
|
316951
317038
|
allPathProgress({ total: totalPaths, done: done11 });
|
|
316952
317039
|
if (path3.startsWith("/")) {
|
|
@@ -317024,14 +317111,14 @@ ${inject.head ?? ""}`;
|
|
|
317024
317111
|
{ head: extraHead, tail: inject.tail, htmlAttrs: inject.htmlAttrs },
|
|
317025
317112
|
maybeMainTitle ?? "Workspace",
|
|
317026
317113
|
resourceMeta.primaryLanguageID ?? maybePrimaryLanguageID ?? "en",
|
|
317027
|
-
function describe(relations2) {
|
|
317028
|
-
const maybeAdapter = findContentAdapter(
|
|
317114
|
+
function describe(relations2, uri) {
|
|
317115
|
+
const maybeAdapter = findContentAdapter(uri);
|
|
317029
317116
|
return maybeAdapter ? maybeAdapter[1].describe(relations2) : null;
|
|
317030
317117
|
},
|
|
317031
317118
|
function generateContent(relations2, uri) {
|
|
317032
317119
|
if (!contentCache[uri]) {
|
|
317033
317120
|
let content;
|
|
317034
|
-
const maybeAdapter = findContentAdapter(
|
|
317121
|
+
const maybeAdapter = findContentAdapter(uri);
|
|
317035
317122
|
if (maybeAdapter) {
|
|
317036
317123
|
try {
|
|
317037
317124
|
content = maybeAdapter[1].generateContent(
|
|
@@ -317060,7 +317147,7 @@ ${inject.head ?? ""}`;
|
|
|
317060
317147
|
resourceGraph.push([inPageResourceID, "isDefinedBy", `${path3}/resource.json`]);
|
|
317061
317148
|
resourceDescriptions[inPageResourceID] = {
|
|
317062
317149
|
primaryLanguageID: maybePrimaryLanguageID,
|
|
317063
|
-
...
|
|
317150
|
+
...maybeAdapter[1].describe(relativeGraph(relations2, inPageResourceID))
|
|
317064
317151
|
};
|
|
317065
317152
|
} else {
|
|
317066
317153
|
console.warn(
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|