@3sln/trove 0.0.14 → 0.0.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3sln/trove",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "description": "Trove — a self-hostable, plugin-extensible Google Drive. Semantic search, pluggable storage (S3 / filesystem / NAS), and a VS Code-style contribution system with sandboxed plugins.",
6
6
  "repository": {
@@ -181,6 +181,25 @@ export class IndexingCoordinator {
181
181
  maxBytes: this.maxIndexBytes,
182
182
  readBytes: async () => readAll((await readRange()).stream),
183
183
  readText: async () => new TextDecoder().decode(await readAll((await readRange()).stream)),
184
+ /**
185
+ * Read `[start, end)` — HALF-OPEN, like every other range in JavaScript, converted
186
+ * to HTTP's inclusive form at this one boundary.
187
+ *
188
+ * `readBytes` reads the FRONT of a file, which is the wrong end of every container
189
+ * that keeps its index at the back: an MP4 written by an encoder that did not know
190
+ * its final size puts `moov` last, and a zip's central directory is always last. An
191
+ * indexer for either could not reach what it needed at all.
192
+ *
193
+ * Bounded per call by the same `maxIndexBytes` cap, so an indexer walking a 4 GB
194
+ * book still cannot pull it through host memory — it just has to ask in pieces,
195
+ * which is what walking a box chain does anyway.
196
+ */
197
+ readRange: async (start = 0, end = node.size) => {
198
+ const from = Math.max(0, Math.min(start, node.size));
199
+ const to = Math.min(end, from + this.maxIndexBytes, node.size);
200
+ if (to <= from) return new Uint8Array(0);
201
+ return readAll((await storage.get(node.storageKey, { range: { start: from, end: to - 1 } })).stream);
202
+ },
184
203
  // A time-limited URL a remote/isolated indexer can fetch the bytes from. S3-class
185
204
  // backends presign; everything else gets a URL this server signed. Either way it
186
205
  // must be ABSOLUTE — whoever receives it is not in this browser and not on this