@riboseinc/anafero-cli 0.0.10 → 0.0.11

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/build-site.mjs CHANGED
@@ -316933,25 +316933,38 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
316933
316933
  }
316934
316934
  }
316935
316935
  function* generateRelations(resourceURI) {
316936
- const chunkSize = 1e3;
316937
- let finished = false;
316938
- let cursor4 = 0;
316939
- while (!finished) {
316940
- const relations = cache3.list(
316941
- `edges-from/${resourceURI}`,
316942
- { start: cursor4, size: chunkSize }
316943
- );
316944
- if (relations.length > 0) {
316945
- yield* relations;
316946
- cursor4 += chunkSize;
316947
- } else {
316948
- finished = true;
316936
+ if (cache3.has(`edges-from/${resourceURI}`)) {
316937
+ const chunkSize = 1e3;
316938
+ let finished = false;
316939
+ let cursor4 = 0;
316940
+ while (!finished) {
316941
+ const relations = cache3.list(
316942
+ `edges-from/${resourceURI}`,
316943
+ { start: cursor4, size: chunkSize }
316944
+ );
316945
+ if (relations.length > 0) {
316946
+ yield* relations;
316947
+ cursor4 += chunkSize;
316948
+ } else {
316949
+ finished = true;
316950
+ }
316949
316951
  }
316950
316952
  }
316951
316953
  }
316954
+ function isInPageHierarchy(resourceURI) {
316955
+ if (cache3.has(`graphs/${resourceURI}`)) {
316956
+ try {
316957
+ const path3 = cache3.get(`path-for/${resourceURI}`);
316958
+ return path3 && path3.indexOf("#") < 1;
316959
+ } catch (e2) {
316960
+ return false;
316961
+ }
316962
+ } else {
316963
+ return false;
316964
+ }
316965
+ }
316952
316966
  function getResourceGraph(resourceURI) {
316953
316967
  if (!cache3.has(`graphs/${resourceURI}`)) {
316954
- const resourcePath = cache3.get(`path-for/${resourceURI}`);
316955
316968
  const queue = [resourceURI];
316956
316969
  while (queue.length > 0) {
316957
316970
  const currentResource = queue.pop();
@@ -316966,13 +316979,8 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
316966
316979
  target
316967
316980
  ])
316968
316981
  );
316969
- if (currentResource !== resourceURI) {
316970
- cache3.set({
316971
- [`path-for/${currentResource}`]: `${resourcePath}#${currentResource}`
316972
- });
316973
- }
316974
316982
  const newTargets = relations.filter(({ target }) => isURIString(target)).filter(
316975
- (rel) => !cache3.has(`path-for/${rel.target}`) && !contentAdapter.crossReferences?.(rel)
316983
+ (rel) => !isInPageHierarchy(rel.target) && !contentAdapter.crossReferences?.(rel)
316976
316984
  ).filter((rel) => !queue.includes(rel.target)).map(({ target }) => target);
316977
316985
  queue.push(...newTargets);
316978
316986
  }
@@ -316980,6 +316988,20 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
316980
316988
  }
316981
316989
  return cache3.list(`graphs/${resourceURI}`);
316982
316990
  }
316991
+ function processResourceContents(resourceURI, containingResourcePath) {
316992
+ if (containingResourcePath.indexOf("tocC/tocC_03/tocC_03_01/tocC_03_01_04") >= 0) {
316993
+ console.debug("Marking as contained", containingResourcePath, resourceURI);
316994
+ console.debug(`${containingResourcePath}#${resourceURI}`);
316995
+ }
316996
+ cache3.set({
316997
+ [`path-for/${resourceURI}`]: `${containingResourcePath}#${resourceURI}`
316998
+ });
316999
+ for (const rel of generateRelations(resourceURI)) {
317000
+ if (isURIString(rel.target) && !contentAdapter.crossReferences?.(rel)) {
317001
+ processResourceContents(containingResourcePath, rel.target);
317002
+ }
317003
+ }
317004
+ }
316983
317005
  function processHierarchy(resourceURI, pathPrefix, onProgress) {
316984
317006
  cache3.add("all-paths", [pathPrefix]);
316985
317007
  cache3.set({ [pathPrefix]: resourceURI });
@@ -317010,6 +317032,8 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
317010
317032
  const encodedComponent = maybePathComponent.replace(":", "_");
317011
317033
  const newPath = pathPrefix ? `${pathPrefix}/${encodedComponent}` : encodedComponent;
317012
317034
  processHierarchy(rel.target, newPath, onProgress);
317035
+ } else {
317036
+ processResourceContents(rel.target, pathPrefix);
317013
317037
  }
317014
317038
  }
317015
317039
  }
@@ -317313,6 +317337,8 @@ ${inject.head ?? ""}`;
317313
317337
  onIntegrityViolation: console.warn,
317314
317338
  reverseResource: (path4) => getReverseResourceMap()[path4],
317315
317339
  uri: resourceURI,
317340
+ // TODO: Consider slash-prepending the outcome of findURL,
317341
+ // if it’s reliably not slash-prepended
317316
317342
  locateResource: (uri) => expandVersionedPath(reader.findURL(uri))
317317
317343
  },
317318
317344
  expandVersionedPath,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riboseinc/anafero-cli",
3
3
  "type": "module",
4
- "version": "0.0.10",
4
+ "version": "0.0.11",
5
5
  "packageManager": "yarn@4.5.0",
6
6
  "bin": {
7
7
  "build-site": "build-site.mjs"
index 5a1dd26..11200ad 100644
Binary file