wiki-graph-sdk 0.9.4 → 0.9.5

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.
Files changed (52) hide show
  1. package/dist/archives.cjs +237 -28
  2. package/dist/archives.cjs.map +1 -1
  3. package/dist/archives.d.ts +1 -1
  4. package/dist/archives.js +240 -28
  5. package/dist/archives.js.map +1 -1
  6. package/dist/conversions.cjs +64 -28
  7. package/dist/conversions.cjs.map +1 -1
  8. package/dist/conversions.js +64 -28
  9. package/dist/conversions.js.map +1 -1
  10. package/dist/default-worker.cjs +64 -28
  11. package/dist/default-worker.cjs.map +1 -1
  12. package/dist/default-worker.js +64 -28
  13. package/dist/default-worker.js.map +1 -1
  14. package/dist/embedding.cjs +64 -28
  15. package/dist/embedding.cjs.map +1 -1
  16. package/dist/embedding.js +64 -28
  17. package/dist/embedding.js.map +1 -1
  18. package/dist/gc.cjs +64 -28
  19. package/dist/gc.cjs.map +1 -1
  20. package/dist/gc.js +64 -28
  21. package/dist/gc.js.map +1 -1
  22. package/dist/{index-DQzLAnjf.d.ts → index-4YX4dv6Y.d.ts} +38 -2
  23. package/dist/index.cjs +240 -31
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +243 -31
  27. package/dist/index.js.map +1 -1
  28. package/dist/local-config.cjs +64 -28
  29. package/dist/local-config.cjs.map +1 -1
  30. package/dist/local-config.js +64 -28
  31. package/dist/local-config.js.map +1 -1
  32. package/dist/maintenance.cjs +64 -28
  33. package/dist/maintenance.cjs.map +1 -1
  34. package/dist/maintenance.js +64 -28
  35. package/dist/maintenance.js.map +1 -1
  36. package/dist/node-platform.cjs +64 -28
  37. package/dist/node-platform.cjs.map +1 -1
  38. package/dist/node-platform.js +64 -28
  39. package/dist/node-platform.js.map +1 -1
  40. package/dist/runtime-config.cjs +64 -28
  41. package/dist/runtime-config.cjs.map +1 -1
  42. package/dist/runtime-config.js +64 -28
  43. package/dist/runtime-config.js.map +1 -1
  44. package/dist/stage.cjs +64 -28
  45. package/dist/stage.cjs.map +1 -1
  46. package/dist/stage.js +64 -28
  47. package/dist/stage.js.map +1 -1
  48. package/dist/worker.cjs +64 -28
  49. package/dist/worker.cjs.map +1 -1
  50. package/dist/worker.js +64 -28
  51. package/dist/worker.js.map +1 -1
  52. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- export { h as WikiGraphArchiveChapterInspection, i as WikiGraphArchiveCover, j as WikiGraphArchiveCreateOptions, k as WikiGraphArchiveCreateResult, l as WikiGraphArchiveEvidenceOptions, m as WikiGraphArchiveExistsError, n as WikiGraphArchiveHandle, o as WikiGraphArchiveIndexArtifactInspection, p as WikiGraphArchiveIndexStatus, q as WikiGraphArchiveIndexSyncOptions, r as WikiGraphArchiveInspection, s as WikiGraphArchiveListOptions, W as WikiGraphArchiveManager, t as WikiGraphArchivePageOptions, u as WikiGraphArchiveRelatedOptions, v as WikiGraphArchiveScope, w as WikiGraphArchiveScopeOptions, x as WikiGraphArchiveSearchOptions, y as WikiGraphArchiveWriteOptions, z as WikiGraphChapterArtifactStatus, B as WikiGraphChapterMoveOptions, D as WikiGraphChapterResetStage, E as WikiGraphChapterSourceOptions, F as WikiGraphChapterTreeInput, G as WikiGraphOperationOptions, S as inspectWikiGraphArchive } from './index-DQzLAnjf.js';
1
+ export { h as WikiGraphArchiveChapterData, i as WikiGraphArchiveChapterInspection, j as WikiGraphArchiveCover, k as WikiGraphArchiveCreateOptions, l as WikiGraphArchiveCreateResult, m as WikiGraphArchiveEvidenceOptions, n as WikiGraphArchiveExistsError, o as WikiGraphArchiveExportResult, p as WikiGraphArchiveHandle, q as WikiGraphArchiveIndexArtifactInspection, r as WikiGraphArchiveIndexStatus, s as WikiGraphArchiveIndexSyncOptions, t as WikiGraphArchiveInspection, u as WikiGraphArchiveListOptions, W as WikiGraphArchiveManager, v as WikiGraphArchiveOverview, w as WikiGraphArchivePageOptions, x as WikiGraphArchiveRelatedOptions, y as WikiGraphArchiveSchemaInspection, z as WikiGraphArchiveScope, B as WikiGraphArchiveScopeOptions, D as WikiGraphArchiveSearchOptions, E as WikiGraphArchiveTocFile, F as WikiGraphArchiveTocItem, G as WikiGraphArchiveWriteOptions, H as WikiGraphChapterArtifactStatus, J as WikiGraphChapterMoveOptions, K as WikiGraphChapterResetStage, M as WikiGraphChapterSourceOptions, N as WikiGraphChapterTreeInput, O as WikiGraphOperationOptions, Z as inspectWikiGraphArchive } from './index-4YX4dv6Y.js';
2
2
  export { a as WikiGraphArchiveOwnershipError, W as WikiGraphArchiveTarget } from './target-CZ7elwmj.js';
3
3
  import 'wiki-graph-core';
4
4
  import './jobs-CRK-DZ40.js';
package/dist/archives.js CHANGED
@@ -14,10 +14,12 @@ import {
14
14
  assertArchiveQueryReady,
15
15
  resolveIndexedArchiveChapterScope,
16
16
  ensureWikiGraphArchiveSchemaCurrent,
17
+ readWikiGraphArchiveSchemaVersion,
17
18
  assertNoActiveBuildJobConflicts,
18
19
  assertNoActiveBuildJobs,
19
20
  deleteArchiveSearchSessions,
20
21
  createContinuationCursor,
22
+ createChapterReadingGraphObjectStream,
21
23
  deleteContinuationCursor,
22
24
  DirectoryDocument,
23
25
  findArchiveObjects,
@@ -43,6 +45,7 @@ import {
43
45
  setChapterSummary,
44
46
  setChapterTitle,
45
47
  getChapterTree,
48
+ getChapterDetails,
46
49
  WikiGraph as WikiGraph2,
47
50
  WikiGraphArchiveFile as WikiGraphArchiveFile2,
48
51
  WikiGraphDirectoryFile as WikiGraphDirectoryFile2,
@@ -51,6 +54,7 @@ import {
51
54
  writeWikgArchive,
52
55
  ObjectMetadataKind
53
56
  } from "wiki-graph-core";
57
+ import { copyFileContent } from "wiki-graph-core/platform";
54
58
 
55
59
  // src/conversions.ts
56
60
  import { createHash } from "crypto";
@@ -166,7 +170,7 @@ var NodeFile = class {
166
170
  }
167
171
  path;
168
172
  async getPhysicalIdentity() {
169
- const value = await fsPromises.stat(this.path).catch((error) => {
173
+ const value = await fsPromises.stat(toNodeFilesystemPath(this.path)).catch((error) => {
170
174
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
171
175
  return void 0;
172
176
  throw error;
@@ -179,7 +183,7 @@ var NodeFile = class {
179
183
  identity;
180
184
  name;
181
185
  async openReader() {
182
- const handle = await fsPromises.open(this.path, "r");
186
+ const handle = await fsPromises.open(toNodeFilesystemPath(this.path), "r");
183
187
  let closed = false;
184
188
  try {
185
189
  const stats = await handle.stat();
@@ -219,7 +223,7 @@ var NodeFile = class {
219
223
  }
220
224
  async getLastModified() {
221
225
  try {
222
- return (await fsPromises.stat(this.path)).mtimeMs;
226
+ return (await fsPromises.stat(toNodeFilesystemPath(this.path))).mtimeMs;
223
227
  } catch (error) {
224
228
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
225
229
  return void 0;
@@ -228,9 +232,14 @@ var NodeFile = class {
228
232
  }
229
233
  }
230
234
  async openWriter() {
231
- await fsPromises.mkdir(pathModule.dirname(this.path), { recursive: true });
235
+ await fsPromises.mkdir(
236
+ toNodeFilesystemPath(pathModule.dirname(this.path)),
237
+ {
238
+ recursive: true
239
+ }
240
+ );
232
241
  const temporary = `${this.path}.tmp-${crypto.randomUUID()}`;
233
- const handle = await fsPromises.open(temporary, "wx");
242
+ const handle = await fsPromises.open(toNodeFilesystemPath(temporary), "wx");
234
243
  let closed = false;
235
244
  return {
236
245
  write: async (data) => {
@@ -245,14 +254,17 @@ var NodeFile = class {
245
254
  commit: async () => {
246
255
  if (!closed) {
247
256
  await handle.close();
248
- await fsPromises.rename(temporary, this.path);
257
+ await fsPromises.rename(
258
+ toNodeFilesystemPath(temporary),
259
+ toNodeFilesystemPath(this.path)
260
+ );
249
261
  }
250
262
  closed = true;
251
263
  },
252
264
  abort: async () => {
253
265
  if (!closed) {
254
266
  await handle.close();
255
- await fsPromises.rm(temporary, { force: true });
267
+ await fsPromises.rm(toNodeFilesystemPath(temporary), { force: true });
256
268
  }
257
269
  closed = true;
258
270
  }
@@ -299,7 +311,7 @@ var NodeDirectory = class _NodeDirectory {
299
311
  }
300
312
  path;
301
313
  async getPhysicalIdentity() {
302
- const value = await fsPromises.stat(this.path).catch((error) => {
314
+ const value = await fsPromises.stat(toNodeFilesystemPath(this.path)).catch((error) => {
303
315
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
304
316
  return void 0;
305
317
  throw error;
@@ -315,7 +327,7 @@ var NodeDirectory = class _NodeDirectory {
315
327
  assertChildName(name);
316
328
  const file = new NodeFile(pathModule.join(this.path, name));
317
329
  try {
318
- return (await fsPromises.stat(file.path)).isFile() ? file : void 0;
330
+ return (await fsPromises.stat(toNodeFilesystemPath(file.path))).isFile() ? file : void 0;
319
331
  } catch (error) {
320
332
  if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
321
333
  return void 0;
@@ -324,7 +336,7 @@ var NodeDirectory = class _NodeDirectory {
324
336
  }
325
337
  async getLastModified() {
326
338
  try {
327
- return (await fsPromises.stat(this.path)).mtimeMs;
339
+ return (await fsPromises.stat(toNodeFilesystemPath(this.path))).mtimeMs;
328
340
  } catch (error) {
329
341
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
330
342
  return void 0;
@@ -336,7 +348,7 @@ var NodeDirectory = class _NodeDirectory {
336
348
  assertChildName(name);
337
349
  const directory = new _NodeDirectory(pathModule.join(this.path, name));
338
350
  try {
339
- return (await fsPromises.stat(directory.path)).isDirectory() ? directory : void 0;
351
+ return (await fsPromises.stat(toNodeFilesystemPath(directory.path))).isDirectory() ? directory : void 0;
340
352
  } catch (error) {
341
353
  if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
342
354
  return void 0;
@@ -344,7 +356,7 @@ var NodeDirectory = class _NodeDirectory {
344
356
  }
345
357
  }
346
358
  async list() {
347
- const entries = await fsPromises.readdir(this.path, {
359
+ const entries = await fsPromises.readdir(toNodeFilesystemPath(this.path), {
348
360
  withFileTypes: true
349
361
  });
350
362
  return entries.map(
@@ -353,26 +365,45 @@ var NodeDirectory = class _NodeDirectory {
353
365
  }
354
366
  async createFile(name) {
355
367
  assertChildName(name);
356
- await fsPromises.mkdir(this.path, { recursive: true });
368
+ await fsPromises.mkdir(toNodeFilesystemPath(this.path), {
369
+ recursive: true
370
+ });
357
371
  const file = new NodeFile(pathModule.join(this.path, name));
358
- await fsPromises.writeFile(file.path, "", { flag: "wx" });
372
+ await fsPromises.writeFile(toNodeFilesystemPath(file.path), "", {
373
+ flag: "wx"
374
+ });
359
375
  return file;
360
376
  }
361
377
  async createDirectory(name) {
362
378
  assertChildName(name);
363
- await fsPromises.mkdir(this.path, { recursive: true });
379
+ await fsPromises.mkdir(toNodeFilesystemPath(this.path), {
380
+ recursive: true
381
+ });
364
382
  const directory = new _NodeDirectory(pathModule.join(this.path, name));
365
- await fsPromises.mkdir(directory.path);
383
+ await fsPromises.mkdir(toNodeFilesystemPath(directory.path));
366
384
  return directory;
367
385
  }
368
386
  async remove(name, options) {
369
387
  assertChildName(name);
370
- await fsPromises.rm(pathModule.join(this.path, name), {
371
- force: true,
372
- recursive: options?.recursive === true
373
- });
388
+ await fsPromises.rm(
389
+ toNodeFilesystemPath(pathModule.join(this.path, name)),
390
+ {
391
+ force: true,
392
+ recursive: options?.recursive === true
393
+ }
394
+ );
374
395
  }
375
396
  };
397
+ function toNodeFilesystemPath(path) {
398
+ if (nodeProcess.platform !== "win32" || path.startsWith("\\\\?\\")) {
399
+ return path;
400
+ }
401
+ const absolute = pathModule.resolve(path);
402
+ if (absolute.startsWith("\\\\")) {
403
+ return `\\\\?\\UNC\\${absolute.slice(2)}`;
404
+ }
405
+ return `\\\\?\\${absolute}`;
406
+ }
376
407
  function encodeNodeResourceIdentity(kind, path) {
377
408
  return `node-${kind}:${Buffer.from(pathModule.resolve(path), "utf8").toString("base64url")}`;
378
409
  }
@@ -458,10 +489,14 @@ async function openNativeNodeDatabase(file, flags) {
458
489
  throw new TypeError("The Node database adapter requires a NodeFile");
459
490
  }
460
491
  return await new Promise((resolve4, reject) => {
461
- const database = new nodeSqlite3.Database(path, flags, (error) => {
462
- if (error) reject(error);
463
- else resolve4(database);
464
- });
492
+ const database = new nodeSqlite3.Database(
493
+ toNodeFilesystemPath(path),
494
+ flags,
495
+ (error) => {
496
+ if (error) reject(error);
497
+ else resolve4(database);
498
+ }
499
+ );
465
500
  });
466
501
  }
467
502
  async function openNodeZip(file, options = {}) {
@@ -469,7 +504,7 @@ async function openNodeZip(file, options = {}) {
469
504
  if (path === void 0) {
470
505
  throw new TypeError("The Node ZIP adapter requires a NodeFile");
471
506
  }
472
- const handle = await fsPromises.open(path, "r");
507
+ const handle = await fsPromises.open(toNodeFilesystemPath(path), "r");
473
508
  let size;
474
509
  try {
475
510
  size = (await handle.stat()).size;
@@ -784,6 +819,11 @@ async function writeNodeZip(file, entries) {
784
819
  }
785
820
  }
786
821
  async function addNodeZipEntries(zipFile, iterator, state) {
822
+ const stableZipOptions = {
823
+ compress: false,
824
+ forceDosTimestamp: true,
825
+ mtime: new Date(1980, 0, 2)
826
+ };
787
827
  while (!state.cancelled) {
788
828
  const result = await iterator.next();
789
829
  if (state.cancelled) return;
@@ -795,17 +835,17 @@ async function addNodeZipEntries(zipFile, iterator, state) {
795
835
  zipFile.addReadStream(
796
836
  createNodeFileReadStream(result.value.file),
797
837
  result.value.name,
798
- { compress: false }
838
+ stableZipOptions
799
839
  );
800
840
  } else if ("data" in result.value) {
801
841
  zipFile.addBuffer(Buffer.from(result.value.data), result.value.name, {
802
- compress: false
842
+ ...stableZipOptions
803
843
  });
804
844
  } else {
805
845
  zipFile.addReadStream(
806
846
  createNodeRangeReadStream(result.value),
807
847
  result.value.name,
808
- { compress: false, size: result.value.size }
848
+ { ...stableZipOptions, size: result.value.size }
809
849
  );
810
850
  }
811
851
  }
@@ -2424,6 +2464,18 @@ var WikiGraphArchiveManager = class {
2424
2464
  }, options.signal);
2425
2465
  return new WikiGraphArchiveHandle(this.#runtime, location);
2426
2466
  }
2467
+ async inspectSchema(target, options = {}) {
2468
+ return await this.#runtime.run(
2469
+ async () => ({
2470
+ schemaVersion: await readWikiGraphArchiveSchemaVersion(
2471
+ await resolveWikiGraphArchiveLocation(target).then(
2472
+ (location) => location.archiveFile
2473
+ )
2474
+ )
2475
+ }),
2476
+ options.signal
2477
+ );
2478
+ }
2427
2479
  };
2428
2480
  var WikiGraphArchiveHandle = class {
2429
2481
  #runtime;
@@ -2450,6 +2502,19 @@ var WikiGraphArchiveHandle = class {
2450
2502
  get target() {
2451
2503
  return this.#location.target;
2452
2504
  }
2505
+ /** Export this archive through the SDK without exposing core file adapters. */
2506
+ async export(path) {
2507
+ return await this.#runtime.run(async () => {
2508
+ const outputPath = await assertStandaloneWikiGraphArchivePath(path);
2509
+ const output = new NodeFile(outputPath);
2510
+ if (this.#location.archiveFile.kind === "directory") {
2511
+ await writeWikgArchive(this.#location.archiveFile, output);
2512
+ } else {
2513
+ await copyFileContent(this.#location.archiveFile, output);
2514
+ }
2515
+ return { path: outputPath };
2516
+ });
2517
+ }
2453
2518
  async #persistCursor(cursor) {
2454
2519
  return await this.#runtime.run(
2455
2520
  async () => await createContinuationCursor(cursor)
@@ -2982,6 +3047,38 @@ var WikiGraphArchiveHandle = class {
2982
3047
  options
2983
3048
  );
2984
3049
  }
3050
+ /** Read archive-level data without exposing the underlying Core reader. */
3051
+ async readOverview(options = {}) {
3052
+ return await this.#readDocument(async (document) => {
3053
+ const [metadata, cover, toc] = await Promise.all([
3054
+ document.readBookMeta(),
3055
+ document.readCover(),
3056
+ document.readToc()
3057
+ ]);
3058
+ const serials = toc === void 0 ? [] : await collectArchiveSerials(document, toc.items);
3059
+ return {
3060
+ ...metadata === void 0 ? {} : { metadata },
3061
+ ...cover === void 0 ? {} : { cover },
3062
+ ...toc === void 0 ? {} : { toc },
3063
+ serials
3064
+ };
3065
+ }, options);
3066
+ }
3067
+ /** Read a chapter and expose its graph as the stable WikgObject stream. */
3068
+ async readChapterData(serialId, options = {}) {
3069
+ const result = await this.#readDocument(async (document) => {
3070
+ const [chapter, summary] = await Promise.all([
3071
+ getChapterDetails(document, serialId),
3072
+ document.readSummary(serialId)
3073
+ ]);
3074
+ return { chapter, summary };
3075
+ }, options);
3076
+ return {
3077
+ chapter: result.chapter,
3078
+ ...result.summary === void 0 ? {} : { summary: result.summary },
3079
+ objects: this.#readChapterObjects(serialId, options)
3080
+ };
3081
+ }
2985
3082
  async replaceBookMeta(meta, options = {}) {
2986
3083
  return await this.#writeDocument(async (document) => {
2987
3084
  await document.replaceBookMeta(meta);
@@ -3069,6 +3166,33 @@ var WikiGraphArchiveHandle = class {
3069
3166
  (error) => rethrowArchiveSchemaError(error, this.#location.target)
3070
3167
  );
3071
3168
  }
3169
+ async *#readChapterObjects(serialId, options) {
3170
+ const queue = createAsyncValueQueue();
3171
+ const producer = this.#readDocument(async (document) => {
3172
+ try {
3173
+ for await (const object of createChapterReadingGraphObjectStream({
3174
+ chapterId: serialId,
3175
+ document
3176
+ })) {
3177
+ if (!await queue.push(object)) break;
3178
+ }
3179
+ queue.end();
3180
+ } catch (error) {
3181
+ queue.fail(error);
3182
+ throw error;
3183
+ }
3184
+ }, options).catch((error) => {
3185
+ queue.fail(error);
3186
+ throw error;
3187
+ });
3188
+ try {
3189
+ for await (const object of queue) yield object;
3190
+ await producer;
3191
+ } finally {
3192
+ queue.cancel();
3193
+ await producer.catch(() => void 0);
3194
+ }
3195
+ }
3072
3196
  async #writeDocument(operation, options = {}) {
3073
3197
  return await this.#runtime.run(async () => {
3074
3198
  return await writeWikiGraphArchiveLocation(this.#location, operation, {
@@ -3263,6 +3387,94 @@ function requireChapter(chapters, chapterId) {
3263
3387
  function asTextStream(text) {
3264
3388
  return Readable2.from([text]);
3265
3389
  }
3390
+ async function collectArchiveSerials(document, items, ancestorTitles = []) {
3391
+ const entries = [];
3392
+ for (const item of items) {
3393
+ const title = item.title?.trim() || `Chapter ${item.serialId ?? "group"}`;
3394
+ const tocPath = [...ancestorTitles, title];
3395
+ if (item.serialId !== void 0) {
3396
+ entries.push({
3397
+ fragmentCount: (await document.getSerialFragments(item.serialId).listFragmentIds()).length,
3398
+ serialId: item.serialId,
3399
+ title,
3400
+ tocPath
3401
+ });
3402
+ }
3403
+ entries.push(
3404
+ ...await collectArchiveSerials(document, item.children, tocPath)
3405
+ );
3406
+ }
3407
+ return entries;
3408
+ }
3409
+ function createAsyncValueQueue() {
3410
+ const values = [];
3411
+ const readers = [];
3412
+ const writers = [];
3413
+ let cancelled = false;
3414
+ let ended = false;
3415
+ let failure;
3416
+ const settleReaders = () => {
3417
+ while (readers.length > 0) {
3418
+ const reader = readers.shift();
3419
+ if (failure !== void 0) reader.reject(failure);
3420
+ else if (values.length > 0) {
3421
+ reader.resolve({ done: false, value: values.shift() });
3422
+ writers.shift()?.();
3423
+ } else if (ended) reader.resolve({ done: true, value: void 0 });
3424
+ else {
3425
+ readers.unshift(reader);
3426
+ return;
3427
+ }
3428
+ }
3429
+ };
3430
+ return {
3431
+ [Symbol.asyncIterator]: () => ({
3432
+ next: async () => {
3433
+ if (failure !== void 0) throw failure;
3434
+ if (values.length > 0) {
3435
+ const value = values.shift();
3436
+ writers.shift()?.();
3437
+ return { done: false, value };
3438
+ }
3439
+ if (ended) return { done: true, value: void 0 };
3440
+ return await new Promise((resolve4, reject) => {
3441
+ readers.push({ reject, resolve: resolve4 });
3442
+ });
3443
+ }
3444
+ }),
3445
+ cancel: () => {
3446
+ cancelled = true;
3447
+ ended = true;
3448
+ values.length = 0;
3449
+ while (writers.length > 0) writers.shift()();
3450
+ settleReaders();
3451
+ },
3452
+ end: () => {
3453
+ ended = true;
3454
+ settleReaders();
3455
+ },
3456
+ fail: (error) => {
3457
+ failure = error instanceof Error ? error : new Error(String(error));
3458
+ ended = true;
3459
+ values.length = 0;
3460
+ while (writers.length > 0) writers.shift()();
3461
+ settleReaders();
3462
+ },
3463
+ push: async (value) => {
3464
+ if (cancelled || ended || failure !== void 0) return false;
3465
+ if (readers.length > 0) {
3466
+ readers.shift().resolve({ done: false, value });
3467
+ return true;
3468
+ }
3469
+ if (values.length > 0) {
3470
+ await new Promise((resolve4) => writers.push(resolve4));
3471
+ if (cancelled || ended || failure !== void 0) return false;
3472
+ }
3473
+ values.push(value);
3474
+ return true;
3475
+ }
3476
+ };
3477
+ }
3266
3478
  async function assertChapterResetAllowed(archive, chapterId, stage) {
3267
3479
  if (stage === "planned") {
3268
3480
  await assertNoActiveBuildJobs({