@riboseinc/anafero-cli 0.0.27 → 0.0.29

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.
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { resolve, isAbsolute, join } from 'node:path';
10
- import { readFile } from 'node:fs/promises';
10
+ import { readFile, writeFile } from 'node:fs/promises';
11
11
 
12
12
  import { Logger, Effect } from 'effect';
13
13
  import { NodeContext, NodeRuntime } from '@effect/platform-node';
@@ -66,7 +66,8 @@ Effect.
66
66
 
67
67
  async function buildBootstrapScript(opts: ReportingOptions) {
68
68
  const { logLevel } = opts;
69
- return await esbuild({
69
+ const outfile = join(PACKAGE_ROOT, 'bootstrap.js');
70
+ const result = await esbuild({
70
71
  entryPoints: [
71
72
  './bootstrap.tsx',
72
73
  //join(PACKAGE_ROOT, 'site', 'index.tsx'),
@@ -81,7 +82,7 @@ async function buildBootstrapScript(opts: ReportingOptions) {
81
82
  treeShaking: true,
82
83
  sourcemap: true,
83
84
  platform: 'browser',
84
- outfile: join(PACKAGE_ROOT, 'bootstrap.js'),
85
+ outfile,
85
86
  //outdir: 'layout',
86
87
  write: true,
87
88
  loader: {
@@ -92,6 +93,23 @@ async function buildBootstrapScript(opts: ReportingOptions) {
92
93
  },
93
94
  logLevel,
94
95
  });
96
+
97
+
98
+ // This unbreaks react-aria’s virtualizer ScrollView
99
+ // interfering with ProseMirror
100
+ //
101
+ // Ideally, this could be an esbuild plugin.
102
+ // Even more ideally, a proper package manager patch
103
+ // (yarn patch didn’t work for me).
104
+ console.debug("Patching ProseMirror");
105
+ let contents = await readFile(outfile, 'utf8');
106
+ contents = contents.replace(
107
+ 'if (!runCustomHandler(view, event)',
108
+ 'if (event && !runCustomHandler(view, event)',
109
+ );
110
+ await writeFile(outfile, contents);
111
+
112
+ return result;
95
113
  }
96
114
 
97
115
  /**
package/build-site.css CHANGED
@@ -31050,6 +31050,9 @@ tbody.vars_bd693cb4_hm005a_spectrum-Table-body .vars_bd693cb4_hm005a_spectrum-Ta
31050
31050
  #resources > * {
31051
31051
  background: transparent;
31052
31052
  }
31053
+ #resources {
31054
+ padding-bottom: 40vh;
31055
+ }
31053
31056
  }
31054
31057
  .style_floatingSubresourceLink {
31055
31058
  .style_floatingSubresourceLinkAnchor {
@@ -31164,6 +31167,11 @@ tbody.vars_bd693cb4_hm005a_spectrum-Table-body .vars_bd693cb4_hm005a_spectrum-Ta
31164
31167
  }
31165
31168
  }
31166
31169
  }
31170
+ .style_navListView {
31171
+ background: var(--spectrum-alias-background-color-default);
31172
+ border: none;
31173
+ border-radius: 0;
31174
+ }
31167
31175
  .style_browserBar {
31168
31176
  position: fixed;
31169
31177
  left: 0;
package/build-site.mjs CHANGED
@@ -28274,7 +28274,7 @@ var require_parser = __commonJS({
28274
28274
  }
28275
28275
  }
28276
28276
  function fromCodePoint() {
28277
- var MAX_SIZE2 = 16384;
28277
+ var MAX_SIZE = 16384;
28278
28278
  var codeUnits = [];
28279
28279
  var highSurrogate;
28280
28280
  var lowSurrogate;
@@ -28294,7 +28294,7 @@ var require_parser = __commonJS({
28294
28294
  lowSurrogate = codePoint % 1024 + 56320;
28295
28295
  codeUnits.push(highSurrogate, lowSurrogate);
28296
28296
  }
28297
- if (index + 1 == length3 || codeUnits.length > MAX_SIZE2) {
28297
+ if (index + 1 == length3 || codeUnits.length > MAX_SIZE) {
28298
28298
  result += String.fromCharCode.apply(null, codeUnits);
28299
28299
  codeUnits.length = 0;
28300
28300
  }
@@ -312877,6 +312877,17 @@ function gatherDescribedResourcesFromJsonifiedProseMirrorNode(jsonifiedNode, _ac
312877
312877
  }
312878
312878
  return accumulator;
312879
312879
  }
312880
+ function gatherTextFromJsonifiedProseMirrorNode(jsonifiedNode) {
312881
+ if (jsonifiedNode?.type === "text") {
312882
+ return typeof jsonifiedNode.text === "string" ? jsonifiedNode.text ?? "" : "";
312883
+ } else {
312884
+ if (Array.isArray(jsonifiedNode?.content) && jsonifiedNode.content.length > 0) {
312885
+ return jsonifiedNode.content.map(gatherTextFromJsonifiedProseMirrorNode).join("\n");
312886
+ } else {
312887
+ return "";
312888
+ }
312889
+ }
312890
+ }
312880
312891
  function fillInLocale(langID) {
312881
312892
  if (langID.indexOf("-") >= 1) {
312882
312893
  return langID;
@@ -313046,44 +313057,15 @@ __export(anafero_exports, {
313046
313057
  VersioningSchema: () => VersioningSchema,
313047
313058
  dedupeGraph: () => dedupeGraph,
313048
313059
  dedupeResourceRelationList: () => dedupeResourceRelationList,
313049
- enableNewLunrJaTokenizer: () => enableNewLunrJaTokenizer,
313050
313060
  fillInLocale: () => fillInLocale,
313051
313061
  gatherDescribedResourcesFromJsonifiedProseMirrorNode: () => gatherDescribedResourcesFromJsonifiedProseMirrorNode,
313062
+ gatherTextFromJsonifiedProseMirrorNode: () => gatherTextFromJsonifiedProseMirrorNode,
313052
313063
  makeDummyInMemoryCache: () => makeDummyInMemoryCache,
313053
313064
  parseModuleRef: () => parseModuleRef,
313054
313065
  titleSchema: () => titleSchema
313055
313066
  });
313056
313067
  init_cjs_shim();
313057
313068
 
313058
- // ../anafero/search.mts
313059
- init_cjs_shim();
313060
- var MIN_SIZE = 2;
313061
- var MAX_SIZE = 6;
313062
- function enableNewLunrJaTokenizer(lunr2) {
313063
- lunr2.ja.tokenizer = function(obj) {
313064
- if (!arguments.length || obj == null || obj === void 0) return [];
313065
- let str = obj.toString().toLowerCase().replace(/^\s+/, "").replace(/\s+$/, "");
313066
- if (str.length === 0) return [];
313067
- const ngrams = (text9, minSize = 2, maxSize = 6) => {
313068
- let results = [];
313069
- for (let size17 = minSize; size17 <= maxSize; size17++) {
313070
- for (let i2 = 0; i2 <= text9.length - size17; i2++) {
313071
- let token = text9.substring(i2, i2 + size17);
313072
- results.push({
313073
- str: token,
313074
- metadata: { position: [i2, i2 + size17 - 1], index: i2 }
313075
- });
313076
- }
313077
- }
313078
- return results;
313079
- };
313080
- const tokens = ngrams(str, MIN_SIZE, Math.min(MAX_SIZE, str.length));
313081
- return tokens.map(
313082
- (tokenData) => new lunr2.Token(tokenData.str, tokenData.metadata)
313083
- );
313084
- };
313085
- }
313086
-
313087
313069
  // ../anafero/TitleSchema.mts
313088
313070
  init_cjs_shim();
313089
313071
  var titleSchema = new Schema({
@@ -316012,6 +315994,7 @@ var style_default = {
316012
315994
  active: "style_active",
316013
315995
  "is-disabled": "style_is-disabled",
316014
315996
  resourceBreadcrumbsNav: "style_resourceBreadcrumbsNav",
315997
+ navListView: "style_navListView",
316015
315998
  browserBar: "style_browserBar",
316016
315999
  browserBarTitle: "style_browserBarTitle",
316017
316000
  browserBarToolbar: "style_browserBarToolbar",
@@ -316074,6 +316057,7 @@ var BrowserBar = function({
316074
316057
  {
316075
316058
  "aria-label": "Loading\u2026",
316076
316059
  minValue: 0,
316060
+ isIndeterminate: loadProgress.total - 0.1 < loadProgress.total - loadProgress.done || loadProgress.total - loadProgress.done < 0.1,
316077
316061
  maxValue: loadProgress.total,
316078
316062
  value: loadProgress.done
316079
316063
  }
@@ -316556,7 +316540,8 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
316556
316540
  if (isURIString(rel.target) && !contentAdapter.crossReferences?.(rel)) {
316557
316541
  const key = JSON.stringify({ rel, resourceURI, containingResourcePath });
316558
316542
  if (seen.has(key)) {
316559
- throw new Error(`Duplicate ${rel.predicate} to ${rel.target} from ${resourceURI} at ${containingResourcePath}`);
316543
+ console.warn(`Ignoring duplicate relation ${rel.predicate} to ${rel.target} from ${resourceURI} at ${containingResourcePath}`);
316544
+ continue;
316560
316545
  } else {
316561
316546
  seen.add(key);
316562
316547
  processResourceContents(rel.target, containingResourcePath, seen);
@@ -316629,6 +316614,17 @@ var makeContentReader = async function(entryPointURI, storeAdapters, contentAdap
316629
316614
  return [];
316630
316615
  }
316631
316616
  },
316617
+ exists: function exists4(resourceURI) {
316618
+ return cache3.has(`path-for/${resourceURI}`);
316619
+ },
316620
+ findContainingPageResourceURI: function findPageURI(resourceURI) {
316621
+ const path3 = cache3.get(`path-for/${resourceURI}`);
316622
+ if (path3.indexOf("#")) {
316623
+ return cache3.get(path3.split("#")[0]);
316624
+ } else {
316625
+ return resourceURI;
316626
+ }
316627
+ },
316632
316628
  findURL: function findURL(resourceURI) {
316633
316629
  const maybePath = cache3.get(`path-for/${resourceURI}`);
316634
316630
  if (maybePath) {
@@ -316674,9 +316670,10 @@ function joinFileURI(baseFileURI, fileURI) {
316674
316670
  // ../anafero/process.mts
316675
316671
  (0, import_lunr_stemmer.default)(import_lunr.default);
316676
316672
  (0, import_tinyseg.default)(import_lunr.default);
316677
- (0, import_lunr2.default)(import_lunr.default);
316678
- (0, import_lunr3.default)(import_lunr.default);
316679
- (0, import_lunr4.default)(import_lunr.default);
316673
+ var lunrLanguageSupport = {
316674
+ ja: import_lunr3.default,
316675
+ fr: import_lunr2.default
316676
+ };
316680
316677
  var encoder = new TextEncoder();
316681
316678
  var decoder = new TextDecoder();
316682
316679
  function* generateResourceAssets(resourceURI, relations, parentChain, directDescendants, resourceProps, expandVersionedPath, getDOMStub, inject, workspaceTitle, primaryLanguageID, describe, generateContent) {
@@ -316863,6 +316860,12 @@ ${inject.head ?? ""}`;
316863
316860
  }
316864
316861
  if (!maybePrimaryLanguageID) {
316865
316862
  if (resourceMeta.primaryLanguageID) {
316863
+ console.debug(
316864
+ "Setting primary language ID:",
316865
+ resourceMeta.primaryLanguageID,
316866
+ "based on resource",
316867
+ resourceURI
316868
+ );
316866
316869
  maybePrimaryLanguageID = resourceMeta.primaryLanguageID;
316867
316870
  }
316868
316871
  } else if (!resourceMeta.primaryLanguageID) {
@@ -316936,13 +316939,21 @@ ${inject.head ?? ""}`;
316936
316939
  if (content) {
316937
316940
  const describedResourceIDs = gatherDescribedResourcesFromJsonifiedProseMirrorNode(content.contentDoc);
316938
316941
  for (const inPageResourceID of describedResourceIDs) {
316939
- const pathWithFragment = `${path3}#${encodeURIComponent(inPageResourceID)}`;
316940
- resourceMap[pathWithFragment] = inPageResourceID;
316941
- resourceGraph.push([inPageResourceID, "isDefinedBy", `${path3}/resource.json`]);
316942
- resourceDescriptions[inPageResourceID] = {
316943
- primaryLanguageID: maybePrimaryLanguageID,
316944
- ...contentAdapter.describe(relativeGraph(relations2, inPageResourceID))
316945
- };
316942
+ if (reader.exists(inPageResourceID)) {
316943
+ const pathWithFragment = `${path3}#${encodeURIComponent(inPageResourceID)}`;
316944
+ resourceMap[pathWithFragment] = inPageResourceID;
316945
+ resourceGraph.push([inPageResourceID, "isDefinedBy", `${path3}/resource.json`]);
316946
+ resourceDescriptions[inPageResourceID] = {
316947
+ primaryLanguageID: maybePrimaryLanguageID,
316948
+ ...contentAdapter.describe(relativeGraph(relations2, inPageResourceID))
316949
+ };
316950
+ } else {
316951
+ console.warn(
316952
+ "Subresource on page does not exist in the graph",
316953
+ path3,
316954
+ inPageResourceID
316955
+ );
316956
+ }
316946
316957
  }
316947
316958
  }
316948
316959
  } else {
@@ -316973,8 +316984,11 @@ ${inject.head ?? ""}`;
316973
316984
  const [indexProgress] = reportProgress("build search index");
316974
316985
  import_lunr.default.utils.warn = console.warn;
316975
316986
  const lunrIndex = (0, import_lunr.default)(function() {
316976
- if (maybePrimaryLanguageID && import_lunr.default.hasOwnProperty(maybePrimaryLanguageID)) {
316977
- console.debug(`Primary language is \u201C${maybePrimaryLanguageID}\u201D, enabling multi-language Lunr mode & mixed tokenizer`);
316987
+ console.debug(`Search index: primary language is \u201C${maybePrimaryLanguageID}\u201D`);
316988
+ if (maybePrimaryLanguageID && maybePrimaryLanguageID !== "en" && lunrLanguageSupport[maybePrimaryLanguageID]) {
316989
+ console.debug("Search index: enabling multi-language Lunr mode & mixed tokenizer");
316990
+ lunrLanguageSupport[maybePrimaryLanguageID](import_lunr.default);
316991
+ (0, import_lunr4.default)(import_lunr.default);
316978
316992
  this.use(import_lunr.default.multiLanguage("en", maybePrimaryLanguageID));
316979
316993
  this.tokenizer = function(x2) {
316980
316994
  return import_lunr.default.tokenizer(x2).concat(import_lunr.default[maybePrimaryLanguageID].tokenizer(x2));
@@ -316982,37 +316996,31 @@ ${inject.head ?? ""}`;
316982
316996
  }
316983
316997
  this.ref("name");
316984
316998
  this.field("body");
316985
- for (const [uri, content] of Object.entries(contentCache)) {
316999
+ for (const [uri, desc] of Object.entries(resourceDescriptions)) {
316986
317000
  indexProgress({ state: `adding entry for ${uri}` });
316987
- const lang = resourceDescriptions[uri]?.primaryLanguageID;
317001
+ const lang = desc.primaryLanguageID;
316988
317002
  if (lang && lang !== maybePrimaryLanguageID && lang !== "en" && import_lunr.default.hasOwnProperty(lang)) {
316989
317003
  console.warn("Resource language is different from primary language, this may not work");
316990
317004
  this.use(import_lunr.default.multiLanguage("en", lang));
316991
317005
  }
316992
- if (content?.content) {
316993
- const { contentDoc, labelInPlainText } = content.content;
317006
+ const rels = reader.resolve(uri);
317007
+ const relationsExcludingReferences = rels.filter(
317008
+ ([s2, p3, o]) => p3 === "hasPart" && (s2 === ROOT_SUBJECT || s2 === uri) && !o.startsWith("data:") && (!isURIString(o) || !reader.exists(o))
317009
+ );
317010
+ const body = relationsExcludingReferences.map(([s2, p3, o]) => o).join("").trim();
317011
+ if (body) {
316994
317012
  const entry = {
316995
317013
  name: uri,
316996
- body: `${labelInPlainText} \u2014 ${gatherTextFromJsonifiedProseMirrorNode(contentDoc)}`
317014
+ body
316997
317015
  };
316998
317016
  this.add(entry);
317017
+ } else {
316999
317018
  }
317000
317019
  }
317001
317020
  });
317002
317021
  indexProgress(null);
317003
317022
  yield { "/search-index.json": encoder.encode(JSON.stringify(lunrIndex, null, 4)) };
317004
317023
  }
317005
- function gatherTextFromJsonifiedProseMirrorNode(jsonifiedNode) {
317006
- if (jsonifiedNode?.type === "text") {
317007
- return typeof jsonifiedNode.text === "string" ? jsonifiedNode.text ?? "" : "";
317008
- } else {
317009
- if (Array.isArray(jsonifiedNode?.content) && jsonifiedNode.content.length > 0) {
317010
- return jsonifiedNode.content.map(gatherTextFromJsonifiedProseMirrorNode).join("\n");
317011
- } else {
317012
- return "";
317013
- }
317014
- }
317015
- }
317016
317024
  async function* generateStaticSiteAssets(versions, currentVersionID, opts) {
317017
317025
  const versionIDsSorted = Array.from(Object.entries(versions)).toSorted(
317018
317026
  ([, ver1], [, ver2]) => ver2.timestamp.getTime() - ver1.timestamp.getTime()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riboseinc/anafero-cli",
3
3
  "type": "module",
4
- "version": "0.0.27",
4
+ "version": "0.0.29",
5
5
  "packageManager": "yarn@4.5.0",
6
6
  "bin": {
7
7
  "build-site": "build-site.mjs"
Binary file
Binary file