jpegxl 8.4.0 → 8.4.1

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 (88) hide show
  1. package/README.md +294 -229
  2. package/dist/animation.browser.mjs +2 -2
  3. package/dist/animation.mjs +2 -2
  4. package/dist/capture-complete.browser.mjs +2 -2
  5. package/dist/capture-complete.mjs +2 -2
  6. package/dist/capture-groups.mjs +2 -2
  7. package/dist/capture.browser.mjs +2 -2
  8. package/dist/capture.mjs +2 -2
  9. package/dist/cli-add.mjs +2 -2
  10. package/dist/cli-astro.mjs +2 -2
  11. package/dist/cli-cloudflare.mjs +2 -2
  12. package/dist/cli-emdash.mjs +2 -2
  13. package/dist/cli-places.mjs +2 -2
  14. package/dist/cli-selftest.mjs +2 -2
  15. package/dist/cli-workers.mjs +2 -2
  16. package/dist/cli.mjs +2 -2
  17. package/dist/decode.browser.mjs +2 -2
  18. package/dist/decode.mjs +2 -2
  19. package/dist/decode.node.mjs +2 -2
  20. package/dist/format.browser.mjs +2 -2
  21. package/dist/format.mjs +2 -2
  22. package/dist/hdr.mjs +2 -2
  23. package/dist/helpers.mjs +2 -2
  24. package/dist/index.browser.mjs +2 -2
  25. package/dist/index.mjs +2 -2
  26. package/dist/jpeg.browser.mjs +2 -2
  27. package/dist/jpeg.mjs +2 -2
  28. package/dist/jpeg.node.mjs +2 -2
  29. package/dist/metadata.mjs +2 -2
  30. package/dist/polyfill.mjs +2 -2
  31. package/dist/resumable.mjs +2 -2
  32. package/dist/resumable.node.mjs +2 -2
  33. package/dist/serve.mjs +2 -2
  34. package/dist/serve.node.mjs +2 -2
  35. package/dist/upload.browser.mjs +2 -2
  36. package/dist/upload.mjs +2 -2
  37. package/dist/verify.mjs +2 -2
  38. package/dist/verify.node.mjs +2 -2
  39. package/dist/wasm-modules.mjs +2 -2
  40. package/examples/agents/jxl-tools.mjs +8 -8
  41. package/examples/android/prepare-assets.mjs +2 -2
  42. package/examples/capacitor/prepare-assets.mjs +2 -2
  43. package/examples/emdash/admin-work.mjs +1 -1
  44. package/examples/emdash/backfill.mjs +4 -4
  45. package/examples/emdash/background.mjs +5 -5
  46. package/examples/emdash/browser-candidate.mjs +1 -1
  47. package/examples/emdash/deliver.mjs +2 -2
  48. package/examples/emdash/host-policy.mjs +6 -6
  49. package/examples/emdash/index.mjs +3 -3
  50. package/examples/emdash/job-runner.mjs +31 -31
  51. package/examples/emdash/job-store.mjs +21 -21
  52. package/examples/emdash/jpeg-source.mjs +2 -2
  53. package/examples/emdash/library-jobs.mjs +21 -21
  54. package/examples/emdash/local-store.mjs +16 -16
  55. package/examples/emdash/media-admin.mjs +9 -9
  56. package/examples/emdash/media-plugin.mjs +62 -62
  57. package/examples/emdash/media-storage.mjs +55 -55
  58. package/examples/emdash/media-words.mjs +89 -89
  59. package/examples/emdash/media-worker.mjs +1 -1
  60. package/examples/emdash/original-envelope.mjs +2 -2
  61. package/examples/emdash/originals.mjs +77 -77
  62. package/examples/emdash/r2-store.mjs +3 -3
  63. package/examples/emdash/read-all.mjs +14 -14
  64. package/examples/emdash/server-only.mjs +1 -1
  65. package/examples/emdash/storage.mjs +1 -1
  66. package/examples/emdash/structural-delivery.mjs +42 -42
  67. package/examples/emdash/thread-driver.mjs +15 -15
  68. package/examples/emdash/thread-worker.mjs +3 -3
  69. package/examples/emdash/work-queue.mjs +11 -11
  70. package/examples/flutter/prepare-assets.mjs +3 -3
  71. package/examples/ios/prepare-assets.mjs +3 -3
  72. package/examples/page-rects.js +14 -14
  73. package/examples/react-native/src/JXLProvider.tsx +19 -9
  74. package/examples/snapdom/jxl.js +3 -2
  75. package/examples/svg-jxl.js +10 -10
  76. package/package.json +1 -1
  77. package/types/animation.d.mts +2 -2
  78. package/types/capture-complete.d.mts +5 -5
  79. package/types/capture.d.mts +1 -1
  80. package/types/format.d.mts +2 -2
  81. package/types/index.d.mts +6 -6
  82. package/types/jpeg.d.mts +1 -1
  83. package/types/result.d.mts +5 -4
  84. package/types/resumable.d.mts +7 -7
  85. package/types/serve.d.mts +1 -1
  86. package/types/types.d.mts +19 -18
  87. package/types/upload.d.mts +1 -1
  88. package/types/verify.d.mts +4 -4
@@ -28,18 +28,18 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
28
28
  allowRetirement = platform === 'node', driver = resumable, restoreOperation = restore} = {}) {
29
29
  if (!['node', 'cloudflare'].includes(platform) || typeof scope !== 'string' || !scope ||
30
30
  [create, compareAndSet, head, replace, delivery].some(value => typeof value !== 'function'))
31
- throw fail('JXL_OPTIONS', "Archive cannot write conditionally; configure conditional writes.");
31
+ throw fail('JXL_OPTIONS', "archive: conditional writes");
32
32
  if (typeof restoreOperation !== 'function' || ['start', 'advance', 'finish'].some(name => typeof driver?.[name] !== 'function'))
33
- throw fail('JXL_OPTIONS', "Reconstruction is unconfigured; supply its resumable driver and restore operation.");
34
- if (typeof allowRetirement !== 'boolean') throw fail('JXL_OPTIONS', "Originals policy is unset; set allowRetirement from the native host policy.");
33
+ throw fail('JXL_OPTIONS', "reconstruction: driver and restore operation");
34
+ if (typeof allowRetirement !== 'boolean') throw fail('JXL_OPTIONS', "allowRetirement: host policy");
35
35
  // A create-only write answers true, false, or {created: true, version} (the stored object's own version, used by copy
36
36
  // attach). Every original and archive write here reads only whether it created the object.
37
37
  const createWithVersion = create;
38
38
  create = async (...args) => { const answer = await createWithVersion(...args); return answer?.created === true ? true : answer; };
39
39
  if (preserveDelivery !== undefined && typeof preserveDelivery !== 'function')
40
- throw fail('JXL_OPTIONS', "Missing archive preservation; supply its storage callback.");
40
+ throw fail('JXL_OPTIONS', "archive preservation: callback");
41
41
  if (!Number.isSafeInteger(maxDeliveryBytes) || maxDeliveryBytes < 1 || maxDeliveryBytes > MAX_ARCHIVE_BYTES + ENVELOPE_BYTES)
42
- throw fail('JXL_OPTIONS', "Missing archive allowance; supply the native byte allowance.");
42
+ throw fail('JXL_OPTIONS', "archive allowance: native byte limit");
43
43
 
44
44
  async function dispatch(action, {signal, call = direct} = {}) {
45
45
  signal?.throwIfAborted();
@@ -52,7 +52,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
52
52
  try { file = await dispatch(() => inner.download(key, {signal: options.signal}), options); }
53
53
  catch (error) { if (error?.code === 'NOT_FOUND') return null; throw error; }
54
54
  const bytes = await readAll(file.body, {maxBytes, signal: options.signal});
55
- if (file.size !== bytes.length) throw fail('JXL_INPUT', "Archive data has the wrong length; restore the complete saved archive.");
55
+ if (file.size !== bytes.length) throw fail('JXL_INPUT', "archive: complete byte length");
56
56
  return {...file, bytes};
57
57
  }
58
58
  async function json(key, options) {
@@ -60,12 +60,12 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
60
60
  if (!file) return null;
61
61
  let value;
62
62
  try { value = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(file.bytes)); }
63
- catch { throw fail('JXL_INPUT', "Archive record is invalid JSON; restore its saved record."); }
63
+ catch { throw fail('JXL_INPUT', "archive record: invalid JSON; restore record"); }
64
64
  return {value, etag: file.etag, size: file.size};
65
65
  }
66
66
  async function cas(key, previous, value, options = {}) {
67
67
  const bytes = utf8(JSON.stringify(value));
68
- if (bytes.length > MAX_JSON) throw fail('JXL_LIMIT', "Archive record is too large; store less data.");
68
+ if (bytes.length > MAX_JSON) throw fail('JXL_LIMIT', "archive record: too large");
69
69
  return dispatch(() => compareAndSet(key, bytes, {etag: previous?.etag ?? null,
70
70
  contentType: 'application/json', signal: options.signal}), options);
71
71
  }
@@ -110,8 +110,8 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
110
110
  saved = await json(CONTROL, options);
111
111
  if (!saved && uncertain) throw uncertain;
112
112
  }
113
- if (saved && !validControl(saved.value)) throw fail('JXL_INPUT', "Invalid archive control record; restore it before removing the integration.");
114
- if (!saved && initialize) throw fail('JXL_INTERNAL', "Invalid image result; report the input and options.");
113
+ if (saved && !validControl(saved.value)) throw fail('JXL_INPUT', "archive control: restore record");
114
+ if (!saved && initialize) throw fail('JXL_INTERNAL', "originals:control");
115
115
  return saved;
116
116
  }
117
117
  async function updateControl(saved, mutate, options = {}) {
@@ -143,7 +143,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
143
143
  const saved = await json(await recordKey(key, id), options);
144
144
  if (saved && (!validRecord(saved.value) || saved.value.source !== key || saved.value.id !== id ||
145
145
  saved.value.candidate !== await candidateKey(key, id)))
146
- throw fail('JXL_INPUT', "Archive ownership is invalid; restore its matching saved record.");
146
+ throw fail('JXL_INPUT', "archive owner: restore record");
147
147
  return saved;
148
148
  }
149
149
  async function updateRecord(saved, mutate, options = {}) {
@@ -163,20 +163,20 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
163
163
  const bytes = await readAll(prefix.body, {maxBytes: ENVELOPE_PREFIX_BYTES, signal: options.signal});
164
164
  if (prefix.version !== file.version) {
165
165
  if (retry) return physical(key, options, false);
166
- throw fail('JXL_INPUT', "Original changed during its read; reload its record and retry.");
166
+ throw fail('JXL_INPUT', "original: changed; reload record");
167
167
  }
168
168
  // A short or misplaced prefix cannot show the archive marker: it must not make an archive look like a JPEG.
169
169
  if (prefix.range && (prefix.range.offset !== 0 || prefix.range.length !== length) || bytes.length !== length)
170
- throw fail('JXL_INPUT', "Original prefix has the wrong range or length; check storage range reads.");
170
+ throw fail('JXL_INPUT', "original prefix: range or length");
171
171
  const marker = envelopeIdentity(bytes);
172
172
  if (!marker) return {file, record: null, archived: false};
173
173
  id = marker.id; archived = true;
174
174
  }
175
175
  const saved = await owned(key, id, options), record = saved?.value;
176
176
  if (!record || archived && file.size !== record.jxlBytes + ENVELOPE_BYTES || !archived && file.size !== record.originalBytes)
177
- throw fail('JXL_INPUT', "JPEG lacks matching ownership; restore its matching record before continuing.");
177
+ throw fail('JXL_INPUT', "JPEG: restore owner record");
178
178
  if (archived && record.state === 'refused')
179
- throw fail('JXL_INPUT', "Archive ownership is inconsistent; reconcile its saved record before continuing.");
179
+ throw fail('JXL_INPUT', "archive ownership: reconcile record");
180
180
  return {file, record, archived};
181
181
  }
182
182
  function logical(found) {
@@ -189,7 +189,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
189
189
  }
190
190
  async function archivePayload(found, options = {}) {
191
191
  const file = await read(found.record.source, found.record.jxlBytes + ENVELOPE_BYTES, options);
192
- if (!file || file.version !== found.file.version) throw fail('JXL_INPUT', "Archive changed during its read; reload its record and retry.");
192
+ if (!file || file.version !== found.file.version) throw fail('JXL_INPUT', "archive: changed; reload record");
193
193
  return unwrapOriginal(file.bytes, found.record.id, found.record.jxlBytes);
194
194
  }
195
195
  const restoreKey = record => RESTORES + record.id + '.json';
@@ -206,7 +206,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
206
206
  !ID.test(value.revision ?? '') || !['running', 'cached', 'blocked'].includes(value.phase) ||
207
207
  typeof value.done !== 'boolean' || typeof value.version !== 'string' || !value.version ||
208
208
  value.checkpoint !== null && (typeof value.checkpoint !== 'object' || Array.isArray(value.checkpoint))))
209
- throw fail('JXL_INPUT', "Invalid reconstruction checkpoint; resume from an intact checkpoint.");
209
+ throw fail('JXL_INPUT', "reconstruction checkpoint: invalid; resume an intact checkpoint");
210
210
  return saved;
211
211
  }
212
212
  async function saveRestore(record, saved, value, options) {
@@ -227,7 +227,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
227
227
  const page = await dispatch(() => inner.list({prefix, limit: 32, signal: options.signal}), options);
228
228
  for (const file of page.files) {
229
229
  if (!file.key.startsWith(prefix) || !file.key.endsWith('.part'))
230
- throw fail('JXL_INPUT', "Reconstruction cleanup found unknown data; reconcile the saved job before deleting anything.");
230
+ throw fail('JXL_INPUT', "reconstruction cleanup: reconcile saved job");
231
231
  await dispatch(() => inner.delete(file.key, {signal: options.signal}), options);
232
232
  }
233
233
  if (!page.nextCursor) return true;
@@ -254,11 +254,11 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
254
254
  const file = await dispatch(() => inner.download(record.source, {range: {offset, length}, signal: options.signal}), options);
255
255
  try {
256
256
  if (file.version !== original.version || file.size !== original.size)
257
- throw fail('JXL_INPUT', "Archive changed during reconstruction; reload its record and retry.");
257
+ throw fail('JXL_INPUT', "archive: changed; reload record");
258
258
  if (file.range?.offset !== offset || file.range.length !== length)
259
- throw fail('JXL_UNSUPPORTED', "Storage cannot read source ranges; enable range reads before reconstruction.");
259
+ throw fail('JXL_UNSUPPORTED', "storage: enable range reads");
260
260
  const bytes = await readAll(file.body, {maxBytes: length, signal: options.signal});
261
- if (bytes.length !== length) throw fail('JXL_INPUT', "Archive range is truncated; restore it before resuming.");
261
+ if (bytes.length !== length) throw fail('JXL_INPUT', "archive range: truncated; restore");
262
262
  return bytes;
263
263
  } catch (error) { cancel(file.body); throw error; }
264
264
  }
@@ -267,30 +267,30 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
267
267
  let marker;
268
268
  const identity = async () => marker ??= (async () => {
269
269
  const value = envelopeIdentity(await range(0, Math.min(original.size, ENVELOPE_PREFIX_BYTES)));
270
- if (!value || value.id !== record.id) throw fail('JXL_INPUT', "Reconstruction identity changed; reload its record and retry.");
270
+ if (!value || value.id !== record.id) throw fail('JXL_INPUT', "reconstruction identity: reload record");
271
271
  return value;
272
272
  })();
273
273
  const partKey = ref => {
274
274
  if (!HASH.test(ref?.hash ?? '') || !Number.isSafeInteger(ref.length) || ref.length < 0 || ref.length > MAX_PART)
275
- throw fail('JXL_INPUT', "A reconstruction part is mutable or oversized; write immutable parts up to 1 MiB.");
275
+ throw fail('JXL_INPUT', "reconstruction part: immutable <=1MiB");
276
276
  return restoreParts(record, run) + ref.hash + '.part';
277
277
  };
278
278
  const readPart = async ref => {
279
279
  const file = await read(partKey(ref), MAX_PART, options);
280
- if (!file || file.bytes.length !== ref.length) throw fail('JXL_IO', "Missing reconstruction part; restore it before resuming.");
280
+ if (!file || file.bytes.length !== ref.length) throw fail('JXL_IO', "reconstruction part: restore missing");
281
281
  return file.bytes;
282
282
  };
283
283
  const writePart = async (ref, bytes) => {
284
284
  const key = partKey(ref);
285
285
  if (!(bytes instanceof Uint8Array) || bytes.length !== ref.length)
286
- throw fail('JXL_INPUT', "Reconstruction part has the wrong length; restore the complete part.");
286
+ throw fail('JXL_INPUT', "reconstruction part: complete length");
287
287
  const created = await dispatch(() => create(key, bytes, {contentType: 'application/octet-stream', signal: options.signal}), options);
288
- if (created !== true && created !== false) throw fail('JXL_IO', "Reconstruction part write is unconfirmed; check its state before retrying.");
288
+ if (created !== true && created !== false) throw fail('JXL_IO', "reconstruction write: unconfirmed; check state");
289
289
  };
290
290
  return {
291
291
  async readSource(offset, length) {
292
292
  if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(length) || length < 1 ||
293
- offset > record.jxlBytes - length) throw fail('JXL_INPUT', "Invalid reconstruction range; request bytes within the saved source.");
293
+ offset > record.jxlBytes - length) throw fail('JXL_INPUT', "reconstruction range: within source");
294
294
  const {offset: insertion} = await identity(), left = Math.max(0, Math.min(length, insertion - offset));
295
295
  const bytes = new Uint8Array(length);
296
296
  if (left) bytes.set(await range(offset, left));
@@ -304,7 +304,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
304
304
  };
305
305
  }
306
306
  async function restoreAdvance(found, {ms = 5000, ...options} = {}) {
307
- if (!Number.isFinite(ms) || ms <= 0 || ms > 60000) throw fail('JXL_OPTIONS', "Invalid reconstruction budget; use 1 to 60000 ms.");
307
+ if (!Number.isFinite(ms) || ms <= 0 || ms > 60000) throw fail('JXL_OPTIONS', "budget: 1-60000ms");
308
308
  const {record} = found, cached = await cachedOriginal(record, options);
309
309
  if (cached) return {done: true, bytes: cached, cached: true};
310
310
  let saved = await restoreState(record, options);
@@ -323,7 +323,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
323
323
  }
324
324
  const job = saved.value;
325
325
  if (job.version !== found.file.version) throw fail('JXL_INPUT', "Archive generation changed during reconstruction; reload its record and retry.");
326
- if (job.phase === 'blocked') throw fail(job.error?.code ?? 'JXL_INPUT', job.error?.message ?? "Reconstruction is blocked; check the archive and saved job.");
326
+ if (job.phase === 'blocked') throw fail(job.error?.code ?? 'JXL_INPUT', job.error?.message ?? "reconstruction: blocked; inspect archive/job");
327
327
  const input = {generation: record.id, sha256: record.outputSha256, byteLength: record.jxlBytes, kind: 'file'};
328
328
  const store = restoreStore(found, job.run, options), common = {operation: restoreOperation, input, store, verify, signal: options.signal};
329
329
  let checkpoint, done = false;
@@ -338,7 +338,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
338
338
  receipt.source?.kind !== 'bytes' || receipt.source.digest !== 'sha256:' + record.outputSha256 ||
339
339
  receipt.outputDigest !== 'sha256:' + record.sourceSha256 || receipt.restoredDigest !== 'sha256:' + record.sourceSha256 ||
340
340
  receipt.referenceDigest !== 'sha256:' + record.sourceSha256 || receipt.width !== record.result.width || receipt.height !== record.result.height)
341
- throw fail('JXL_INPUT', "Archive did not restore exact JPEG bytes; keep the integration installed and restore a verified archive.");
341
+ throw fail('JXL_INPUT', "JPEG restoration: mismatch; keep integration");
342
342
  return {done: true, bytes: result.bytes, run: job.run};
343
343
  }
344
344
  } catch (error) {
@@ -377,14 +377,14 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
377
377
  async function download(key, options = {}, retry = true) {
378
378
  if (!jpeg(key)) return inner.download(key, options);
379
379
  const found = await physical(key, options);
380
- if (!found) throw fail('NOT_FOUND', 'Media file not found.');
380
+ if (!found) throw fail('NOT_FOUND', 'media file: missing');
381
381
  const meta = logical(found);
382
382
  if (!found.archived) {
383
383
  const file = await inner.download(key, options);
384
384
  if (file.version !== found.file.version) {
385
385
  cancel(file.body);
386
386
  if (retry) return download(key, options, false);
387
- throw fail('JXL_INPUT', "Original changed during its read; reload its record and retry.");
387
+ throw fail('JXL_INPUT', "original: changed; reload record");
388
388
  }
389
389
  return {...file, ...meta, body: file.body, ...(file.range ? {range: file.range} : {})};
390
390
  }
@@ -438,9 +438,9 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
438
438
  // A Free or unknown Worker cannot promise a cold original GET within its CPU allowance.
439
439
  // It keeps the uploaded JPEG; a reversible JXL remains eligible as a delivery copy.
440
440
  if (!allowRetirement) return refuse('host_cpu_limit');
441
- if (typeof storageOnly !== 'boolean') throw fail('JXL_OPTIONS', "Invalid originals policy; set storageOnly to true or false.");
441
+ if (typeof storageOnly !== 'boolean') throw fail('JXL_OPTIONS', "storageOnly: boolean");
442
442
  if (!HASH.test(source ?? '') || !HASH.test(expectedGeneration ?? '') || !ID.test(expectedDeliveryRevision ?? '') || !ID.test(jobIdentity ?? ''))
443
- throw fail('JXL_OPTIONS', "Incomplete archive identity; pass its source, delivery revision, and server job ID.");
443
+ throw fail('JXL_OPTIONS', "archive identity: source, delivery revision, job ID");
444
444
  if (!(result?.bytes instanceof Uint8Array) || result.bytes.length < 2 || result.bytes.length > maxInputBytes ||
445
445
  result.format !== 'jxl' || result.kept !== 'jpeg-bytes' || result.fidelity !== 'exact') return refuse('not_reversible_jpeg');
446
446
  if (result.bytes.length > MAX_ARCHIVE_BYTES) return refuse('archive_byte_limit');
@@ -448,13 +448,13 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
448
448
  receipt.format !== 'jxl' || receipt.source?.kind !== 'bytes' || receipt.source.digest !== 'sha256:' + source ||
449
449
  receipt.referenceDigest !== 'sha256:' + source || receipt.restoredDigest !== 'sha256:' + source ||
450
450
  !SHA.test(receipt.outputDigest ?? '') || receipt.width !== result.width || receipt.height !== result.height)
451
- throw fail('JXL_INPUT', "Missing archive receipt; independently reverify the original and candidate.");
451
+ throw fail('JXL_INPUT', "archive receipt: reverify original and candidate");
452
452
  const checkpoint = {id: jobIdentity, key, generation: expectedGeneration};
453
453
  const prior = await owned(key, jobIdentity, options);
454
454
  if (prior) {
455
455
  if (prior.value.generation !== expectedGeneration || prior.value.sourceSha256 !== source ||
456
456
  prior.value.outputSha256 !== receipt.outputDigest.slice(7) || prior.value.jxlBytes !== result.bytes.length)
457
- throw fail('JXL_INPUT', "Archive ID reused; use a new ID.");
457
+ throw fail('JXL_INPUT', "archive ID: unique");
458
458
  if (prior.value.state !== 'prepared' || prior.value.staged === true) return checkpoint;
459
459
  }
460
460
  const gate = await control(options);
@@ -475,11 +475,11 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
475
475
  deliveryRevision: expectedDeliveryRevision, deliveryEligible: !storageOnly && deliveryEligible === true, storageOnly,
476
476
  deliveryReason, result: stripBytes(result), receipt: structuredClone(receipt), candidate,
477
477
  state: 'prepared', staging: 'prepared', staged: false, cleaned: false, reason: null};
478
- if (!validRecord(record)) throw fail('JXL_INPUT', "Archive metadata is invalid; restore its matching saved record.");
478
+ if (!validRecord(record)) throw fail('JXL_INPUT', "archive metadata: restore record");
479
479
  if (!prior) {
480
480
  const metadataKey = await recordKey(key, jobIdentity);
481
481
  const recordBytes = utf8(JSON.stringify(record));
482
- if (recordBytes.length > MAX_JSON) throw fail('JXL_LIMIT', "Archive record is too large; store less data.");
482
+ if (recordBytes.length > MAX_JSON) throw fail('JXL_LIMIT', "archive record: too large");
483
483
  const created = await dispatch(() => create(metadataKey, recordBytes,
484
484
  {contentType: 'application/json', signal: options.signal}), options);
485
485
  if (created !== true) return beginArchive(key, result, {source, expectedGeneration, expectedDeliveryRevision, jobIdentity,
@@ -554,9 +554,9 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
554
554
  async function advanceArchive(checkpoint, options = {}) {
555
555
  const {key, id, generation: expectedGeneration} = checkpoint ?? {};
556
556
  if (!jpeg(key) || !ID.test(id ?? '') || !HASH.test(expectedGeneration ?? ''))
557
- throw fail('JXL_OPTIONS', "Invalid request; pass its saved archive checkpoint.");
557
+ throw fail('JXL_OPTIONS', "request: saved archive checkpoint");
558
558
  let saved = await owned(key, id, options);
559
- if (!saved || saved.value.generation !== expectedGeneration) throw fail('JXL_INPUT', "Archive checkpoint is missing or changed; reload its record and retry.");
559
+ if (!saved || saved.value.generation !== expectedGeneration) throw fail('JXL_INPUT', "archive checkpoint: reload record");
560
560
  if (saved.value.state === 'refused') return finishRefusal(saved, saved.value.reason, options);
561
561
  if (saved.value.state === 'restored') return {done: true, phase: 'complete', progressed: false,
562
562
  publication: refusal(key, 'retirement_disabled', saved.value.result)};
@@ -609,7 +609,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
609
609
  return finishRefusal(saved, 'delivery_changed', options);
610
610
  const candidate = await read(record.candidate, record.jxlBytes + ENVELOPE_BYTES, options);
611
611
  if (!candidate || candidate.bytes.length !== record.jxlBytes + ENVELOPE_BYTES || envelopeIdentity(candidate.bytes)?.id !== id)
612
- throw fail('JXL_INPUT', "Prepared archive is missing or changed; reload its record and retry.");
612
+ throw fail('JXL_INPUT', "prepared archive: reload record");
613
613
  // The only archive write dispatch in the implementation. A retry that sees writing cannot enter here.
614
614
  const armed = await updateControl(gate, value => { value.writer.phase = 'writing'; }, options);
615
615
  if (!armed) return {done: false, phase: 'prepared', progressed: false, error: null};
@@ -639,15 +639,15 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
639
639
  function requireRemoval(saved, input) {
640
640
  const status = removalValue(saved);
641
641
  if (!status || input?.id !== status.id || input.siteId !== status.siteId || input.scope !== scope)
642
- throw fail('JXL_INPUT', "Restoration or storage identity changed; reload its record and retry.");
642
+ throw fail('JXL_INPUT', "restoration identity: reload record");
643
643
  return status;
644
644
  }
645
645
  async function beginRemoval({id, ...options} = {}) {
646
- if (!ID.test(id ?? '')) throw fail('JXL_OPTIONS', "Invalid removal ID; pass its 32-character ID.");
646
+ if (!ID.test(id ?? '')) throw fail('JXL_OPTIONS', "removal ID: 32 lowercase hex characters");
647
647
  const saved = await control(options);
648
648
  if (saved.value.removal) {
649
649
  if (saved.value.removal.purpose === 'uninstall') {
650
- if (saved.value.removal.id !== id) throw fail('JXL_INPUT', "Restoration is active; finish it first.");
650
+ if (saved.value.removal.id !== id) throw fail('JXL_INPUT', "restoration: finish active run");
651
651
  return removalValue(saved);
652
652
  }
653
653
  // Only the explicit uninstall request acquires the terminal removal gate. A switch's
@@ -666,7 +666,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
666
666
  }
667
667
  const latest = await control(options);
668
668
  if (latest.value.removal?.id !== id || latest.value.removal?.purpose !== 'uninstall')
669
- throw fail('JXL_INPUT', "A different restoration started; reload its progress.");
669
+ throw fail('JXL_INPUT', "restoration: changed; reload progress");
670
670
  return removalValue(latest);
671
671
  }
672
672
  async function removalStatus(options = {}) {
@@ -684,7 +684,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
684
684
  }
685
685
  async function drainRestoreWriter(saved, options) {
686
686
  const writer = saved.value.writer, item = await owned(writer.key, writer.archive, options);
687
- if (!item) throw fail('JXL_INPUT', "Missing restoration owner; restore its matching record.");
687
+ if (!item) throw fail('JXL_INPUT', "restoration owner: restore record");
688
688
  if (writer.phase === 'cleaning' && writer.outcome === 'restore-refused') {
689
689
  await releaseWriter(writer.id, options);
690
690
  return;
@@ -709,7 +709,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
709
709
  }
710
710
  async function advanceRemoval(input = {}) {
711
711
  const {signal, call = direct, ms = 5000} = input, options = {signal, call};
712
- if (!Number.isFinite(ms) || ms <= 0 || ms > 60000) throw fail('JXL_OPTIONS', "Invalid reconstruction budget; use 1 to 60000 ms.");
712
+ if (!Number.isFinite(ms) || ms <= 0 || ms > 60000) throw fail('JXL_OPTIONS', "budget: 1-60000ms");
713
713
  let saved = await control(options); requireRemoval(saved, input);
714
714
  if (saved.value.removal.phase === 'complete') return removalValue(saved);
715
715
  if (saved.value.writer) {
@@ -725,7 +725,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
725
725
  await releaseWriter(saved.value.writer.id, options);
726
726
  saved = await control(options);
727
727
  } else {
728
- const error = fail('JXL_ARCHIVE_UNRESOLVED', "A source change is unconfirmed; keep the integration installed.");
728
+ const error = fail('JXL_ARCHIVE_UNRESOLVED', "source change: unconfirmed; keep integration");
729
729
  await blockWriter(saved, error, options); return removalValue(await control(options));
730
730
  }
731
731
  if (saved.value.writer) return removalValue(saved);
@@ -741,7 +741,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
741
741
  const item = await json(file.key, options);
742
742
  if (!item || !validRecord(item.value) || await recordKey(item.value.source, item.value.id) !== file.key ||
743
743
  item.value.candidate !== await candidateKey(item.value.source, item.value.id))
744
- throw fail('JXL_INPUT', "Invalid restoration owner; restore its saved record.");
744
+ throw fail('JXL_INPUT', "restoration owner: saved record");
745
745
  const record = item.value, found = await physical(record.source, options);
746
746
  if (found?.archived && found.record.id === record.id) {
747
747
  if (saved.value.removal.phase === 'verifying') { remaining++; continue; }
@@ -749,15 +749,15 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
749
749
  try {
750
750
  const selected = await delivery(record.source, record.generation, options);
751
751
  if (selected.mode === 'copies' && selected.revision === record.deliveryRevision) {
752
- if (!preserveDelivery) throw fail('JXL_UNSUPPORTED', "Cannot preserve archive delivery; keep its setting.");
752
+ if (!preserveDelivery) throw fail('JXL_UNSUPPORTED', "archive delivery: retain setting");
753
753
  if (record.jxlBytes > maxDeliveryBytes)
754
- throw fail('JXL_LIMIT', "Archive delivery exceeds the copy limit; keep its setting until it can be preserved.");
754
+ throw fail('JXL_LIMIT', "archive delivery: exceeds copy limit");
755
755
  const bytes = await archivePayload(found, options);
756
756
  const kept = await preserveDelivery(record.source, {...structuredClone(record.result), bytes}, {
757
757
  source: record.sourceSha256, expectedGeneration: record.generation, expectedDeliveryRevision: record.deliveryRevision,
758
758
  jobIdentity: record.id, receipt: structuredClone(record.receipt),
759
759
  preservationId: saved.value.removal.id, ...options});
760
- if (kept?.preserved !== true) throw fail('JXL_IO', "Archive delivery preservation is unconfirmed; check its state before retrying.");
760
+ if (kept?.preserved !== true) throw fail('JXL_IO', "archive delivery: unconfirmed; check state");
761
761
  }
762
762
  await updateRecord(item, value => { value.deliveryPreserved = saved.value.removal.id; }, options);
763
763
  } catch (error) {
@@ -792,7 +792,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
792
792
  return removalValue(await control(settled));
793
793
  }
794
794
  const latest = await control(settled);
795
- if (latest.value.writer?.id !== id) throw fail('JXL_INPUT', "Restoration writer changed before confirmation; check its state before retrying.");
795
+ if (latest.value.writer?.id !== id) throw fail('JXL_INPUT', "restoration writer: changed; check state");
796
796
  if (acknowledged === null || acknowledged === false) {
797
797
  await updateControl(latest, value => {
798
798
  value.writer.phase = 'cleaning'; value.writer.outcome = 'restore-refused';
@@ -857,7 +857,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
857
857
  function policyValue(saved) {
858
858
  const {policy, removal, writer, mode, revision} = saved.value;
859
859
  const error = removal?.error ?? policy.error ?? (!allowRetirement && policy.enabled
860
- ? {code: 'JXL_UNSUPPORTED', message: "Archive allowance unavailable; use a host with the saved allowance."} : null);
860
+ ? {code: 'JXL_UNSUPPORTED', message: "archive allowance: use capable host"} : null);
861
861
  return {available: allowRetirement && removal?.purpose !== 'uninstall', enabled: policy.enabled, desired: policy.desired,
862
862
  phase: policy.phase, id: policy.id, revision,
863
863
  admitting: allowRetirement && mode === 'enabled' && policy.enabled && policy.desired,
@@ -868,15 +868,15 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
868
868
  async function policy(options = {}) { return policyValue(await control(options)); }
869
869
  async function setPolicy({enabled, id, expectedId, ...options} = {}) {
870
870
  if (typeof enabled !== 'boolean' || !ID.test(id ?? '') || !ID.test(expectedId ?? ''))
871
- throw fail('JXL_OPTIONS', "Stale originals policy; pass its current identity.");
871
+ throw fail('JXL_OPTIONS', "originals policy: current identity");
872
872
  const saved = await control(options), previous = saved.value.policy;
873
- if (previous.id !== expectedId) throw fail('JXL_POLICY_CHANGED', "Originals setting changed; read its current progress.");
874
- if (enabled && !allowRetirement) throw fail('JXL_UNSUPPORTED', "This host cannot archive JPEG originals; keep the JPEG files.");
873
+ if (previous.id !== expectedId) throw fail('JXL_POLICY_CHANGED', "originals policy: refresh progress");
874
+ if (enabled && !allowRetirement) throw fail('JXL_UNSUPPORTED', "host: retain original JPEGs");
875
875
  if (saved.value.removal?.purpose === 'uninstall')
876
- throw fail('JXL_BUSY', "Integration removal blocks archival; finish removal first.");
876
+ throw fail('JXL_BUSY', "archival: finish integration removal");
877
877
  if (previous.desired === enabled) return policyValue(saved);
878
878
  if (previous.phase === 'restoring')
879
- throw fail('JXL_BUSY', "Originals are being restored; finish restoration before changing this setting.");
879
+ throw fail('JXL_BUSY', "originals policy: finish restoration");
880
880
  await updateControl(saved, value => {
881
881
  if (enabled) {
882
882
  value.mode = 'enabled'; value.removal = null; value.policy = newPolicy(true, id);
@@ -898,7 +898,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
898
898
  }
899
899
  async function advancePolicy({id, ms = 5000, signal, call = direct, list, prepare, run} = {}) {
900
900
  if (!ID.test(id ?? '') || !Number.isFinite(ms) || ms <= 0 || ms > 60000)
901
- throw fail('JXL_OPTIONS', "Invalid request; pass the saved originals operation and a budget of 1 to 60000 ms.");
901
+ throw fail('JXL_OPTIONS', "request: saved operation; budget 1-60000ms");
902
902
  const options = {signal, call};
903
903
  let saved = await control(options), selected = saved.value.policy;
904
904
  if (selected.id !== id) return null;
@@ -911,7 +911,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
911
911
  };
912
912
  if (selected.phase === 'restoring') {
913
913
  if (selected.current?.command) {
914
- if (typeof run !== 'function') throw fail('JXL_OPTIONS', "Archive cancellation is unconfigured; supply its saved server runner.");
914
+ if (typeof run !== 'function') throw fail('JXL_OPTIONS', "archive cancellation: server runner");
915
915
  try {
916
916
  const stopped = await run(selected.current.command, {ms, signal, cancel: true});
917
917
  // A stopped archive job whose part cleanup is still pending keeps its command: the next advance repeats it.
@@ -924,7 +924,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
924
924
  }
925
925
  const removal = removalValue(saved);
926
926
  if (!removal || saved.value.removal.purpose !== 'policy' || removal.id !== id)
927
- throw fail('JXL_INPUT', "Originals setting lost its restoration; reload the saved operation before continuing.");
927
+ throw fail('JXL_INPUT', "originals policy: reload restoration");
928
928
  await advanceRemoval({...removal, ms, ...options});
929
929
  saved = await control(options);
930
930
  if (saved.value.policy.id === id && saved.value.removal?.purpose === 'policy' &&
@@ -939,9 +939,9 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
939
939
  }
940
940
  return policyValue(await control(options));
941
941
  }
942
- if (!allowRetirement) return saveError(fail('JXL_UNSUPPORTED', "This host cannot archive JPEG originals; keep the JPEG files."));
942
+ if (!allowRetirement) return saveError(fail('JXL_UNSUPPORTED', "host: retain original JPEGs"));
943
943
  if ([list, prepare, run].some(value => typeof value !== 'function'))
944
- throw fail('JXL_OPTIONS', "Progressive archival is unconfigured; supply the native media list and verified server runner.");
944
+ throw fail('JXL_OPTIONS', "archival: media list and verified runner");
945
945
  const complete = async (outcome, reason = null) => {
946
946
  await updateControl(saved, value => {
947
947
  const item = value.policy.current;
@@ -958,13 +958,13 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
958
958
  if (!page || !Array.isArray(page.items) || page.items.length > 1 ||
959
959
  page.nextCursor !== undefined && (typeof page.nextCursor !== 'string' || !page.nextCursor) ||
960
960
  page.nextCursor !== undefined && page.nextCursor === selected.cursor)
961
- throw fail('JXL_IO', "JPEG list returned an invalid page; check storage and retry.");
961
+ throw fail('JXL_IO', "JPEG list: invalid page");
962
962
  const item = page.items[0];
963
963
  if (!item) {
964
- if (page.nextCursor !== undefined) throw fail('JXL_IO', "JPEG list returned an empty nonterminal page; check storage and retry.");
964
+ if (page.nextCursor !== undefined) throw fail('JXL_IO', "JPEG list: empty nonterminal page");
965
965
  await updateControl(saved, value => { value.policy.phase = 'idle'; value.policy.error = null; }, options);
966
966
  } else {
967
- if (typeof item.id !== 'string' || !jpeg(item.key)) throw fail('JXL_INPUT', "JPEG list has an invalid original; repair its media record before resuming.");
967
+ if (typeof item.id !== 'string' || !jpeg(item.key)) throw fail('JXL_INPUT', "JPEG list: repair original record");
968
968
  const jobId = (await digest(utf8(JSON.stringify(['originals', scope, id, item.id, item.key])))).slice(0, 32);
969
969
  await updateControl(saved, value => { value.policy.current = {item: structuredClone(item), jobId,
970
970
  nextCursor: page.nextCursor ?? null, stage: 'prepare', command: null}; value.policy.error = null; }, options);
@@ -976,14 +976,14 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
976
976
  const command = await prepare(current.item, {id: current.jobId, signal, call});
977
977
  if (command?.skip) return complete(command.skip === 'archived' ? 'archived' : 'kept', command.skip);
978
978
  if (!command || command.id !== current.jobId || command.key !== current.item.key || command.archiveOnly !== true)
979
- throw fail('JXL_INPUT', "Archive belongs to another command; reload its matching saved command.");
979
+ throw fail('JXL_INPUT', "archive: reload matching command");
980
980
  await updateControl(saved, value => {
981
981
  value.policy.current.command = structuredClone(command); value.policy.current.stage = 'run'; value.policy.error = null;
982
982
  }, options);
983
983
  return policyValue(await control(options));
984
984
  }
985
985
  const job = await run(current.command, {ms, signal, cancel: false});
986
- if (!job) throw fail('JXL_IO', "Missing saved archive job; restore it before resuming.");
986
+ if (!job) throw fail('JXL_IO', "archive job: restore missing");
987
987
  if (job.phase === 'blocked') return saveError(job.blocked ?? job.error ??
988
988
  fail('JXL_ARCHIVE_UNRESOLVED', "JPEG archive write is unconfirmed; check its state before retrying."));
989
989
  if ((job.done || job.canceled) && !job.cleanupPending) return complete(job.publication?.stored === 'original' ? 'archived' : job.error ? 'failed' : 'kept',
@@ -1024,11 +1024,11 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
1024
1024
  const saved = await settledMutation(await control(options), options);
1025
1025
  if (saved.value.mode === 'retiring' && saved.value.removal?.phase === 'complete') {
1026
1026
  if (saved.value.removal.purpose === 'uninstall') return action();
1027
- throw fail('JXL_BUSY', "Restored originals setting is being saved; retry this change.");
1027
+ throw fail('JXL_BUSY', "originals policy: save pending");
1028
1028
  }
1029
1029
  if (saved.value.writer) {
1030
1030
  if (saved.value.writer.phase === 'blocked' || attempt === 7)
1031
- throw fail('JXL_BUSY', "JPEG replacement is in progress; retry this change.");
1031
+ throw fail('JXL_BUSY', "JPEG replacement: in progress");
1032
1032
  continue;
1033
1033
  }
1034
1034
  acquired = await updateControl(saved, value => {
@@ -1036,7 +1036,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
1036
1036
  }, options);
1037
1037
  if (acquired) break;
1038
1038
  }
1039
- if (!acquired) throw fail('JXL_BUSY', "JPEG replacement started; retry this change.");
1039
+ if (!acquired) throw fail('JXL_BUSY', "JPEG replacement: started");
1040
1040
  let result;
1041
1041
  try { result = await action(); }
1042
1042
  catch (error) {
@@ -1054,7 +1054,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
1054
1054
  }, settledOptions);
1055
1055
  }
1056
1056
  if (!durable || !await releaseWriter(id, settledOptions))
1057
- throw fail('JXL_ARCHIVE_UNRESOLVED', "Source changed without writer confirmation; check its state before retrying.");
1057
+ throw fail('JXL_ARCHIVE_UNRESOLVED', "source: unconfirmed change; check state");
1058
1058
  return result;
1059
1059
  }
1060
1060
  const originals = {
@@ -1063,7 +1063,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
1063
1063
  beginArchive, advanceArchive, beginRemoval, advanceRemoval, removalStatus, policy, setPolicy, advancePolicy,
1064
1064
  async advanceRestore(key, options = {}) {
1065
1065
  const found = await physical(key, options);
1066
- if (!found) throw fail('NOT_FOUND', 'Media file not found.');
1066
+ if (!found) throw fail('NOT_FOUND', 'media file: missing');
1067
1067
  return found.archived ? restoreAdvance(found, options) : {done: true, archived: false, bytes: null};
1068
1068
  },
1069
1069
  async info(key, options) {
@@ -1105,12 +1105,12 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
1105
1105
  result.push({key: part.key, size: part.size});
1106
1106
  }
1107
1107
  if (!parts.nextCursor) break;
1108
- if (partCursor === parts.nextCursor) throw fail('JXL_INTERNAL', "Invalid image result; report the input and options.");
1108
+ if (partCursor === parts.nextCursor) throw fail('JXL_INTERNAL', "originals:part-cursor");
1109
1109
  partCursor = parts.nextCursor;
1110
1110
  }
1111
1111
  }
1112
1112
  if (!page.nextCursor) return result;
1113
- if (cursor === page.nextCursor) throw fail('JXL_INTERNAL', "Invalid image result; report the input and options.");
1113
+ if (cursor === page.nextCursor) throw fail('JXL_INTERNAL', "originals:page-cursor");
1114
1114
  cursor = page.nextCursor;
1115
1115
  }
1116
1116
  }
@@ -1121,7 +1121,7 @@ export function originalStorage(inner, {platform, scope, create, compareAndSet,
1121
1121
  if (property === 'upload') return async options => {
1122
1122
  if (!jpeg(options.key)) return target.upload(options);
1123
1123
  const body = await readAll(options.body, {maxBytes: maxInputBytes, signal: options.signal});
1124
- if (envelopeIdentity(body)) throw fail('JXL_INPUT', "Archive is private storage data; upload the restored JPEG.");
1124
+ if (envelopeIdentity(body)) throw fail('JXL_INPUT', "archive: upload restored JPEG");
1125
1125
  return mutation(options.key, () => target.upload({...options, body}), options);
1126
1126
  };
1127
1127
  if (property === 'delete') return (key, options) => mutation(key, () => target.delete(key, options), options);
@@ -8,7 +8,7 @@ export function r2Store(inner, bucket) {
8
8
  options?.signal?.throwIfAborted();
9
9
  const object = await bucket.get(key, options?.range ? {range: options.range} : undefined);
10
10
  if (!object?.body && key.startsWith('__rapier_jxl__/'))
11
- throw Object.assign(new Error('Private media object not found.'), {code: 'NOT_FOUND'});
11
+ throw Object.assign(new Error('private media object: missing'), {code: 'NOT_FOUND'});
12
12
  if (!object?.body) return target.download(key, options);
13
13
  return {body: object.body, ...(object.range ? {range: object.range} : {}), ...metadata(object)};
14
14
  };
@@ -24,7 +24,7 @@ export function r2Store(inner, bucket) {
24
24
  async function compareAndSet(key, body, {etag, contentType, signal} = {}) {
25
25
  if (!key.startsWith('__rapier_jxl__/') || !key.endsWith('.json') ||
26
26
  etag !== null && (typeof etag !== 'string' || !etag))
27
- throw Object.assign(new Error("Missing revision; pass the stored revision."), {code: 'JXL_INPUT'});
27
+ throw Object.assign(new Error("revision: stored revision"), {code: 'JXL_INPUT'});
28
28
  signal?.throwIfAborted();
29
29
  const onlyIf = etag === null ? new Headers({'If-None-Match': '*'}) : {etagMatches: etag};
30
30
  return await bucket.put(key, body, {onlyIf, httpMetadata: {contentType}}) !== null;
@@ -38,7 +38,7 @@ export function r2Store(inner, bucket) {
38
38
  if (key.startsWith('__rapier_jxl__/') || !/\.(?:jpe?g|jpe|jfif)$/i.test(key) ||
39
39
  typeof expectedVersion !== 'string' || !expectedVersion || typeof etag !== 'string' || !etag ||
40
40
  !/^[a-f0-9]{32}$/.test(originalId ?? '') || !['jxl', 'jpeg'].includes(representation))
41
- throw Object.assign(new Error("Missing replacement identities; pass source and archive identities."), {code: 'JXL_INPUT'});
41
+ throw Object.assign(new Error("replacement: source and archive identities"), {code: 'JXL_INPUT'});
42
42
  signal?.throwIfAborted();
43
43
  const before = await bucket.head(key);
44
44
  if (!before || before.version !== expectedVersion || before.etag !== etag) return null;