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.
- package/README.md +294 -229
- package/dist/animation.browser.mjs +2 -2
- package/dist/animation.mjs +2 -2
- package/dist/capture-complete.browser.mjs +2 -2
- package/dist/capture-complete.mjs +2 -2
- package/dist/capture-groups.mjs +2 -2
- package/dist/capture.browser.mjs +2 -2
- package/dist/capture.mjs +2 -2
- package/dist/cli-add.mjs +2 -2
- package/dist/cli-astro.mjs +2 -2
- package/dist/cli-cloudflare.mjs +2 -2
- package/dist/cli-emdash.mjs +2 -2
- package/dist/cli-places.mjs +2 -2
- package/dist/cli-selftest.mjs +2 -2
- package/dist/cli-workers.mjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/decode.browser.mjs +2 -2
- package/dist/decode.mjs +2 -2
- package/dist/decode.node.mjs +2 -2
- package/dist/format.browser.mjs +2 -2
- package/dist/format.mjs +2 -2
- package/dist/hdr.mjs +2 -2
- package/dist/helpers.mjs +2 -2
- package/dist/index.browser.mjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/jpeg.browser.mjs +2 -2
- package/dist/jpeg.mjs +2 -2
- package/dist/jpeg.node.mjs +2 -2
- package/dist/metadata.mjs +2 -2
- package/dist/polyfill.mjs +2 -2
- package/dist/resumable.mjs +2 -2
- package/dist/resumable.node.mjs +2 -2
- package/dist/serve.mjs +2 -2
- package/dist/serve.node.mjs +2 -2
- package/dist/upload.browser.mjs +2 -2
- package/dist/upload.mjs +2 -2
- package/dist/verify.mjs +2 -2
- package/dist/verify.node.mjs +2 -2
- package/dist/wasm-modules.mjs +2 -2
- package/examples/agents/jxl-tools.mjs +8 -8
- package/examples/android/prepare-assets.mjs +2 -2
- package/examples/capacitor/prepare-assets.mjs +2 -2
- package/examples/emdash/admin-work.mjs +1 -1
- package/examples/emdash/backfill.mjs +4 -4
- package/examples/emdash/background.mjs +5 -5
- package/examples/emdash/browser-candidate.mjs +1 -1
- package/examples/emdash/deliver.mjs +2 -2
- package/examples/emdash/host-policy.mjs +6 -6
- package/examples/emdash/index.mjs +3 -3
- package/examples/emdash/job-runner.mjs +31 -31
- package/examples/emdash/job-store.mjs +21 -21
- package/examples/emdash/jpeg-source.mjs +2 -2
- package/examples/emdash/library-jobs.mjs +21 -21
- package/examples/emdash/local-store.mjs +16 -16
- package/examples/emdash/media-admin.mjs +9 -9
- package/examples/emdash/media-plugin.mjs +62 -62
- package/examples/emdash/media-storage.mjs +55 -55
- package/examples/emdash/media-words.mjs +89 -89
- package/examples/emdash/media-worker.mjs +1 -1
- package/examples/emdash/original-envelope.mjs +2 -2
- package/examples/emdash/originals.mjs +77 -77
- package/examples/emdash/r2-store.mjs +3 -3
- package/examples/emdash/read-all.mjs +14 -14
- package/examples/emdash/server-only.mjs +1 -1
- package/examples/emdash/storage.mjs +1 -1
- package/examples/emdash/structural-delivery.mjs +42 -42
- package/examples/emdash/thread-driver.mjs +15 -15
- package/examples/emdash/thread-worker.mjs +3 -3
- package/examples/emdash/work-queue.mjs +11 -11
- package/examples/flutter/prepare-assets.mjs +3 -3
- package/examples/ios/prepare-assets.mjs +3 -3
- package/examples/page-rects.js +14 -14
- package/examples/react-native/src/JXLProvider.tsx +19 -9
- package/examples/snapdom/jxl.js +3 -2
- package/examples/svg-jxl.js +10 -10
- package/package.json +1 -1
- package/types/animation.d.mts +2 -2
- package/types/capture-complete.d.mts +5 -5
- package/types/capture.d.mts +1 -1
- package/types/format.d.mts +2 -2
- package/types/index.d.mts +6 -6
- package/types/jpeg.d.mts +1 -1
- package/types/result.d.mts +5 -4
- package/types/resumable.d.mts +7 -7
- package/types/serve.d.mts +1 -1
- package/types/types.d.mts +19 -18
- package/types/upload.d.mts +1 -1
- package/types/verify.d.mts +4 -4
package/dist/wasm-modules.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rapier-jxl 8.4.
|
|
2
|
-
function e(e){globalThis[c]=Object.freeze({...e,...globalThis[c]})}function t(e){if(!e||"object"!=typeof e||Array.isArray(e)||!Object.keys(e).length)throw u("
|
|
1
|
+
/*! rapier-jxl 8.4.1 | MIT */
|
|
2
|
+
function e(e){globalThis[c]=Object.freeze({...e,...globalThis[c]})}function t(e){if(!e||"object"!=typeof e||Array.isArray(e)||!Object.keys(e).length)throw u("modules: {name: WebAssembly.Module}");let t=Object.entries(e);for(let[e,s]of t){if(!Object.hasOwn(a,e))throw u(`unknown module: ${e}`);let t,r;try{t=WebAssembly.Module.imports(s),r=WebAssembly.Module.exports(s)}catch{throw u(`${e}: WebAssembly.Module`)}let n="kernels"===e||"general"===e;if(l(r)!==a[e]||(n?1!==t.length||"env"!==t[0].module||"memory"!==t[0].name||"memory"!==t[0].kind:0!==t.length))throw u(`${e}: interface mismatch`);if(o.has(e)&&o.get(e)!==s||i.has(e)&&i.get(e)!==s)throw u(`${e}: already configured`)}for(let[e,s]of t)o.set(e,s);m=!0}function s(){return b(),m?Object.freeze(Object.fromEntries(o)):void 0}async function r(e,t){return b(),!(!i.get(e)&&!o.has(e))||(g.has(e)||(i.has(e)||i.set(e,null),g.set(e,(async()=>{let s=await WebAssembly.compile(t());return await WebAssembly.instantiate(Uint8Array.of(0,97,115,109,1,0,0,0)),i.get(e)||i.set(e,s),d.delete(e),!0})().catch(t=>(g.delete(e),d.set(e,t),!1)))),g.get(e))}function n(e,t){if(b(),i.get(e))return i.get(e);i.set(e,null);let s,r=o.get(e);if(r)return i.set(e,r),r;try{s=new WebAssembly.Module(t())}catch(t){throw m?u(`${e}: missing`):t}return i.set(e,s),s}var a={kernels:"6gzyrq",jpeg:"1fjin7z",decode:"17x8vsf",rebuild:"fgbogf",general:"1sc0v86"},l=e=>{let t=2166136261;for(let s of e.map(e=>e.name+":"+e.kind).sort().join(" "))t=Math.imul(t^s.charCodeAt(0),16777619);return(t>>>0).toString(36)},o=new Map,i=new Map,m=!1,u=e=>Object.assign(new Error(e),{code:"JXL_WASM"}),c=Symbol.for("rapier-jxl/8.4.1 wasm "+Object.entries(a).map(([e,t])=>e+":"+t).join(";")),f=null,b=()=>{let e=globalThis[c];if(!e||e===f)return;f=e;let s=Object.entries(e).filter(([e])=>!o.has(e));s.length&&t(Object.fromEntries(s))},h=e=>(b(),o.has(e)),g=new Map,d=new Map,y=e=>void 0===e?d.values().next().value:d.get(e);export{r as compileWasm,t as configureModules,h as hasWasmModule,e as provideWasm,s as suppliedWasm,y as wasmFailure,n as wasmModule};
|
|
@@ -54,13 +54,13 @@ async function admitImageDimensions(bytes, key, maxPixels = MAX_PIXELS) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
async function read(env, key, what = 'key') {
|
|
57
|
-
if (!env?.JXL_BUCKET) throw refuse('JXL_SETUP', '
|
|
57
|
+
if (!env?.JXL_BUCKET) throw refuse('JXL_SETUP', 'JXL_BUCKET: bind R2; run npx jpegxl add agents');
|
|
58
58
|
admitKey(key, what);
|
|
59
59
|
const object = await env.JXL_BUCKET.get(key);
|
|
60
|
-
if (!object) throw refuse('JXL_INPUT',
|
|
60
|
+
if (!object) throw refuse('JXL_INPUT', `${what}: missing ${safeLabel(key)}`);
|
|
61
61
|
if (object.size > MAX_BYTES) {
|
|
62
62
|
object.body?.cancel();
|
|
63
|
-
throw refuse('JXL_LIMIT', `${safeLabel(key)}
|
|
63
|
+
throw refuse('JXL_LIMIT', `${safeLabel(key)}: over ${MAX_BYTES / 1e6} MB; run npx jpegxl add r2`);
|
|
64
64
|
}
|
|
65
65
|
return new Uint8Array(await object.arrayBuffer());
|
|
66
66
|
}
|
|
@@ -72,7 +72,7 @@ async function write(env, key, bytes, overwrite, meta, contentType = 'image/jxl'
|
|
|
72
72
|
httpMetadata: {contentType},
|
|
73
73
|
...!overwrite && {onlyIf: new Headers({'if-none-match': '*'})},
|
|
74
74
|
});
|
|
75
|
-
if (!put) throw refuse('JXL_OPTIONS', `${safeLabel(key)}
|
|
75
|
+
if (!put) throw refuse('JXL_OPTIONS', `${safeLabel(key)}: exists; set overwrite: true`);
|
|
76
76
|
}
|
|
77
77
|
const summary = (key, out, from, to, extra) => ({key: out, from: key, fromBytes: from, bytes: to, saved: Math.round((1 - to / from) * 1000) / 10 + '%', ...extra});
|
|
78
78
|
|
|
@@ -88,7 +88,7 @@ export function defineTools(z) {
|
|
|
88
88
|
input: z.object({key, out, overwrite, effort: recompressEffort}).strict(),
|
|
89
89
|
async run(env, {key, out, overwrite, effort = 3}) {
|
|
90
90
|
const bytes = await read(env, key);
|
|
91
|
-
if (!isJpeg(bytes)) throw refuse('JXL_INPUT', `${safeLabel(key)}
|
|
91
|
+
if (!isJpeg(bytes)) throw refuse('JXL_INPUT', `${safeLabel(key)}: not a JPEG; use jxl_convert`);
|
|
92
92
|
out = admitDistinctOut(key, out ?? besideKey(key, '.jxl'));
|
|
93
93
|
await admitImageDimensions(bytes, key);
|
|
94
94
|
const result = await recompress(bytes, {effort, maxPixels: MAX_PIXELS});
|
|
@@ -112,7 +112,7 @@ export function defineTools(z) {
|
|
|
112
112
|
input: z.object({key, out, overwrite}).strict(),
|
|
113
113
|
async run(env, {key, out, overwrite}) {
|
|
114
114
|
const bytes = await read(env, key);
|
|
115
|
-
if (!isJxl(bytes)) throw refuse('JXL_INPUT', `${safeLabel(key)}
|
|
115
|
+
if (!isJxl(bytes)) throw refuse('JXL_INPUT', `${safeLabel(key)}: JPEG XL required`);
|
|
116
116
|
out = admitDistinctOut(key, out ?? besideKey(key, '.restored.jpg'));
|
|
117
117
|
await admitImageDimensions(bytes, key, MAX_JPEG_PIXELS);
|
|
118
118
|
const result = await restore(bytes, {maxPixels: MAX_JPEG_PIXELS});
|
|
@@ -125,7 +125,7 @@ export function defineTools(z) {
|
|
|
125
125
|
ensureDecoders();
|
|
126
126
|
const source = await read(env, original, 'original'), file = await read(env, jxl, 'jxl');
|
|
127
127
|
if (!isJpeg(source) && !isPng(source)) throw refuse('JXL_INPUT', `${safeLabel(original)} is not a JPEG or PNG.`);
|
|
128
|
-
if (!isJxl(file)) throw refuse('JXL_INPUT', `${safeLabel(jxl)}
|
|
128
|
+
if (!isJxl(file)) throw refuse('JXL_INPUT', `${safeLabel(jxl)}: JPEG XL required`);
|
|
129
129
|
const sourceLimit = isJpeg(source) ? MAX_JPEG_PIXELS : MAX_PIXELS;
|
|
130
130
|
await admitImageDimensions(source, original, sourceLimit);
|
|
131
131
|
const h = header(file, {maxPixels: sourceLimit, maxBoxes: MAX_BOXES, maxInputBytes: MAX_BYTES});
|
|
@@ -167,6 +167,6 @@ export async function runTool(tool, env, args) {
|
|
|
167
167
|
return {isError: true, content: [{type: 'text', text: `JXL_OPTIONS: Invalid argument${issue?.path?.length ? ' ' + issue.path.join('.') : ''}; ${issue?.message ?? 'check tool arguments'}.`}]};
|
|
168
168
|
}
|
|
169
169
|
const code = String(error?.code).startsWith('JXL_') ? error.code : 'JXL_INTERNAL';
|
|
170
|
-
return {isError: true, content: [{type: 'text', text: `${code}: ${code === 'JXL_INTERNAL' ? '
|
|
170
|
+
return {isError: true, content: [{type: 'text', text: `${code}: ${code === 'JXL_INTERNAL' ? 'jxl-tools:dispatch' : error.message}`}]};
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -14,11 +14,11 @@ export async function prepareAssets({example = here, packageDir = process.env.JX
|
|
|
14
14
|
for (const name of ['upload', 'jpeg']) {
|
|
15
15
|
const path = `dist/${name}.mjs`;
|
|
16
16
|
if (manifest.exports?.[`./${name}`]?.import !== `./${path}`)
|
|
17
|
-
throw new Error(
|
|
17
|
+
throw Object.assign(new Error(`${pkg} is not a built package with ./${name}.`), {code: 'JXL_PACKAGE'});
|
|
18
18
|
await copyFile(join(pkg, path), join(generated, 'jpegxl', `${name}.mjs`));
|
|
19
19
|
}
|
|
20
20
|
if (manifest.exports?.['./animation']?.browser !== './dist/animation.browser.mjs' || manifest.exports['./animation'].import !== './dist/animation.mjs')
|
|
21
|
-
throw new Error(
|
|
21
|
+
throw Object.assign(new Error(`${pkg} is not a built package with ./animation.`), {code: 'JXL_PACKAGE'});
|
|
22
22
|
for (const name of ['animation', 'animation.browser']) await copyFile(join(pkg, `dist/${name}.mjs`), join(generated, 'jpegxl', `${name}.mjs`));
|
|
23
23
|
await copyFile(join(pkg, 'LICENSE'), join(generated, 'jpegxl/LICENSE'));
|
|
24
24
|
const page = await readFile(join(source, 'encoder.html'), 'utf8');
|
|
@@ -11,7 +11,7 @@ export const MODULES = ['upload.mjs', 'upload.browser.mjs', 'jpeg.mjs', 'jpeg.br
|
|
|
11
11
|
export async function copyModules({packageDir, to}) {
|
|
12
12
|
const manifest = JSON.parse(await readFile(join(packageDir, 'package.json'), 'utf8').catch(() => 'null') ?? 'null');
|
|
13
13
|
for (const name of ['upload', 'jpeg']) if (manifest?.exports?.[`./${name}`]?.browser !== `./dist/${name}.browser.mjs`)
|
|
14
|
-
throw new Error(
|
|
14
|
+
throw Object.assign(new Error(`${packageDir} is not a built package with ./${name}.`), {code: 'JXL_PACKAGE'});
|
|
15
15
|
await mkdir(to, {recursive: true});
|
|
16
16
|
for (const name of MODULES) await copyFile(join(packageDir, 'dist', name), join(to, name));
|
|
17
17
|
await copyFile(join(packageDir, 'LICENSE'), join(to, 'LICENSE'));
|
|
@@ -22,5 +22,5 @@ export async function prepareAssets({example = here, packageDir = process.env.JX
|
|
|
22
22
|
}
|
|
23
23
|
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
24
24
|
try { await prepareAssets(); }
|
|
25
|
-
catch (error) { console.error(`${error.message}\nSet JXL_PACKAGE to a built package, or run npm install --no-save jpegxl in this example.`); process.exitCode = 1; }
|
|
25
|
+
catch (error) { console.error(`${error.code || 'JXL_PACKAGE'}: ${error.message}\nSet JXL_PACKAGE to a built package, or run npm install --no-save jpegxl in this example.`); process.exitCode = 1; }
|
|
26
26
|
}
|
|
@@ -168,7 +168,7 @@ export function createSettings(initial, {read, write, change = () => {}}) {
|
|
|
168
168
|
// Unique media IDs are then read in bounded parallel batches while preserving exact import order.
|
|
169
169
|
export async function rewriteAndRead(result, {rewrite, read, signal, concurrency = 8}) {
|
|
170
170
|
if (!Number.isSafeInteger(concurrency) || concurrency < 1 || concurrency > 32)
|
|
171
|
-
throw new RangeError('concurrency
|
|
171
|
+
throw new RangeError('concurrency: integer 1-32');
|
|
172
172
|
check(signal);
|
|
173
173
|
try { await rewrite(result.urlMap, signal); }
|
|
174
174
|
catch (error) { check(signal); throw atPhase(error, 'rewrite'); }
|
|
@@ -11,7 +11,7 @@ const LIBRARY_BATCH = 8;
|
|
|
11
11
|
|
|
12
12
|
function boundedInt(name, value, min, max) {
|
|
13
13
|
if (!Number.isSafeInteger(value) || value < min || value > max)
|
|
14
|
-
throw new RangeError(`${name}
|
|
14
|
+
throw new RangeError(`${name}: integer ${min}-${max}`);
|
|
15
15
|
return value;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,12 +19,12 @@ export async function backfill({site, token, apply = false, fetch: send = fetch,
|
|
|
19
19
|
cursor: initialCursor, pageSize = LIBRARY_BATCH, concurrency = 1, effort, signal, maxPixels}) {
|
|
20
20
|
const base = new URL(site);
|
|
21
21
|
if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password || !token)
|
|
22
|
-
throw new TypeError('
|
|
22
|
+
throw new TypeError('site: URL and token');
|
|
23
23
|
boundedInt('pageSize', pageSize, 1, 100);
|
|
24
24
|
boundedInt('concurrency', concurrency, 1, 16);
|
|
25
25
|
if (effort !== undefined) boundedInt('effort', effort, 1, 9);
|
|
26
26
|
if (initialCursor !== undefined && (typeof initialCursor !== 'string' || !initialCursor.length))
|
|
27
|
-
throw new TypeError('
|
|
27
|
+
throw new TypeError('cursor: nonempty string');
|
|
28
28
|
const call = async (path, init = {}) => {
|
|
29
29
|
const response = await send(new URL(path, base), {...init, signal, redirect: 'error', headers: {Authorization: `Bearer ${token}`,
|
|
30
30
|
'X-EmDash-Request': '1', Accept: 'application/json', ...init.headers}});
|
|
@@ -131,7 +131,7 @@ export async function backfill({site, token, apply = false, fetch: send = fetch,
|
|
|
131
131
|
signal?.throwIfAborted();
|
|
132
132
|
onPage({cursor: cursor ?? null, nextCursor: page.nextCursor ?? null, items: page.items.length});
|
|
133
133
|
if (!page.nextCursor) break;
|
|
134
|
-
if (page.nextCursor === cursor) throw new Error('
|
|
134
|
+
if (page.nextCursor === cursor) throw new Error('media cursor: repeated');
|
|
135
135
|
cursor = page.nextCursor;
|
|
136
136
|
}
|
|
137
137
|
return totals;
|
|
@@ -10,7 +10,7 @@ export async function runBackground({event, platform, scope, work, runner, libra
|
|
|
10
10
|
if (event?.name !== 'jxl-work' || event?.data?.kind !== 'images' || !['node', 'cloudflare'].includes(platform) ||
|
|
11
11
|
!Number.isFinite(wakeMs) || wakeMs <= 0 || !Number.isFinite(stepMs) || stepMs <= 0 || stepMs > 60000 ||
|
|
12
12
|
cpuLimitMs !== null && (!Number.isFinite(cpuLimitMs) || cpuLimitMs <= 0))
|
|
13
|
-
throw fail('JXL_OPTIONS', "
|
|
13
|
+
throw fail('JXL_OPTIONS', "request: site work and allowance");
|
|
14
14
|
// Every wake ends at its allowance, Node's too: EmDash takes back a task 'running' for 10 minutes, so an unbounded Node
|
|
15
15
|
// wake was claimed twice, and one cut by a restart left the task locked with nothing advancing.
|
|
16
16
|
const started = now(), allowance = cpuLimitMs === null ? wakeMs : Math.min(wakeMs, cpuLimitMs * 0.8);
|
|
@@ -30,7 +30,7 @@ export async function runBackground({event, platform, scope, work, runner, libra
|
|
|
30
30
|
const page = await work.list(cursor);
|
|
31
31
|
for (const {data} of page.items) {
|
|
32
32
|
if (data.scope !== scope || !['image', 'library', 'originals'].includes(data.kind))
|
|
33
|
-
throw fail('JXL_INPUT', "
|
|
33
|
+
throw fail('JXL_INPUT', "work: wrong site; reload record");
|
|
34
34
|
let previous;
|
|
35
35
|
for (;;) {
|
|
36
36
|
if (exhausted()) return result;
|
|
@@ -46,7 +46,7 @@ export async function runBackground({event, platform, scope, work, runner, libra
|
|
|
46
46
|
if (job.cleanupPending || job.phase === 'blocked') break;
|
|
47
47
|
revision = job.revision;
|
|
48
48
|
} else if (data.kind === 'originals') {
|
|
49
|
-
if (typeof originals !== 'function') throw fail('JXL_OPTIONS', "
|
|
49
|
+
if (typeof originals !== 'function') throw fail('JXL_OPTIONS', "originals: policy runner");
|
|
50
50
|
const policy = await (await originals({ms: sliceMs})).resume(data.id, {signal});
|
|
51
51
|
result.advances++;
|
|
52
52
|
if (policy?.blocked) break;
|
|
@@ -54,7 +54,7 @@ export async function runBackground({event, platform, scope, work, runner, libra
|
|
|
54
54
|
await work.remove('originals', data.id); result.completed++; break;
|
|
55
55
|
}
|
|
56
56
|
if (!['archiving', 'restoring'].includes(policy.phase))
|
|
57
|
-
throw fail('JXL_INPUT', "
|
|
57
|
+
throw fail('JXL_INPUT', "originals: reload progress");
|
|
58
58
|
revision = policy.revision;
|
|
59
59
|
} else {
|
|
60
60
|
const run = await (await library({ms: sliceMs})).resume(data.id);
|
|
@@ -83,7 +83,7 @@ export async function runBackground({event, platform, scope, work, runner, libra
|
|
|
83
83
|
if (typeof sweep === 'function' && !exhausted()) await sweep({signal});
|
|
84
84
|
return result;
|
|
85
85
|
}
|
|
86
|
-
if (!page.cursor || seen.has(page.cursor)) throw fail('JXL_IO', "
|
|
86
|
+
if (!page.cursor || seen.has(page.cursor)) throw fail('JXL_IO', "work page: repeated cursor");
|
|
87
87
|
seen.add(page.cursor); cursor = page.cursor;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -10,7 +10,7 @@ export async function stageCandidate(store, result, {signal} = {}) {
|
|
|
10
10
|
signal?.throwIfAborted();
|
|
11
11
|
if (!store || typeof store.write !== 'function' || !(result?.bytes instanceof Uint8Array) ||
|
|
12
12
|
result.bytes.byteLength < 2 || result.bytes.byteLength > MAX_BYTES || result.meetsTarget !== true || result.format !== 'jxl')
|
|
13
|
-
throw fail('JXL_INPUT', "
|
|
13
|
+
throw fail('JXL_INPUT', "candidate: fitting JXL <=8MiB; storage write()");
|
|
14
14
|
const {bytes, verification: ignoredReceipt, ...metadata} = result;
|
|
15
15
|
const record = JSON.parse(JSON.stringify(metadata));
|
|
16
16
|
const parts = [];
|
|
@@ -5,7 +5,7 @@ export const QUALITY = 85;
|
|
|
5
5
|
export function deliveryWidths(width, widths, available = []) {
|
|
6
6
|
if (!Number.isSafeInteger(width) || width < 1 || !Array.isArray(widths) || !Array.isArray(available) ||
|
|
7
7
|
widths.some(w => !Number.isSafeInteger(w) || w < 1) || available.some(w => !Number.isSafeInteger(w) || w < 1))
|
|
8
|
-
throw new TypeError('
|
|
8
|
+
throw new TypeError('picture: dimensions and positive widths');
|
|
9
9
|
const kept = new Set(available);
|
|
10
10
|
return [...new Set(widths)].filter(w => w < width && !kept.has(w)).sort((a, b) => a - b);
|
|
11
11
|
}
|
|
@@ -14,7 +14,7 @@ export async function deliveryCopies(source, {width, height}, widths, {variants}
|
|
|
14
14
|
{fidelity = {quality: QUALITY}, maxBytes, signal, onProgress} = {}) {
|
|
15
15
|
signal?.throwIfAborted();
|
|
16
16
|
if (!Number.isSafeInteger(height) || height < 1)
|
|
17
|
-
throw new TypeError('
|
|
17
|
+
throw new TypeError('picture: dimensions and positive widths');
|
|
18
18
|
const sizes = deliveryWidths(width, widths);
|
|
19
19
|
if (!sizes.length) {
|
|
20
20
|
onProgress?.(1);
|
|
@@ -8,15 +8,15 @@ import {nodeEstimate} from './node-admission.mjs';
|
|
|
8
8
|
const WORKER_MEMORY_BYTES = 128 * 1024 * 1024;
|
|
9
9
|
const fail = message => Object.assign(new Error(message), {code: 'JXL_OPTIONS'});
|
|
10
10
|
const positive = (value, name) => {
|
|
11
|
-
if (!Number.isFinite(value) || value <= 0) throw fail(
|
|
11
|
+
if (!Number.isFinite(value) || value <= 0) throw fail(`${name}: positive number`);
|
|
12
12
|
return value;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// These are the deployed host's configured allowances. No account-plan guess or sandbox quota belongs here.
|
|
16
16
|
export function hostOptions(value = {}) {
|
|
17
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) throw fail("
|
|
17
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw fail("limits: object");
|
|
18
18
|
if (Object.keys(value).some(key => !['cpuLimitMs', 'memoryLimitBytes'].includes(key)))
|
|
19
|
-
throw fail("
|
|
19
|
+
throw fail("limits: cpuLimitMs, memoryLimitBytes");
|
|
20
20
|
return Object.fromEntries(Object.entries(value).map(([key, number]) => [key, positive(number, key)]));
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -24,12 +24,12 @@ export function hostOptions(value = {}) {
|
|
|
24
24
|
// is admitted against: that allowance, else on Node the host's real limit (cgroup v2 memory.max where set, else the
|
|
25
25
|
// machine's), never a tighter one of our own (principle 10). `realMemory` is for tests.
|
|
26
26
|
export function hostLimits(platform, options = {}, realMemory = nodeMemoryBytes) {
|
|
27
|
-
if (!['node', 'cloudflare'].includes(platform)) throw fail("
|
|
27
|
+
if (!['node', 'cloudflare'].includes(platform)) throw fail("platform: node or cloudflare");
|
|
28
28
|
const cpuLimitMs = options.cpuLimitMs === undefined ? null : positive(options.cpuLimitMs, 'cpuLimitMs');
|
|
29
29
|
const requested = options.memoryLimitBytes === undefined ? null : positive(options.memoryLimitBytes, 'memoryLimitBytes');
|
|
30
|
-
if (requested !== null && !Number.isSafeInteger(requested)) throw fail("
|
|
30
|
+
if (requested !== null && !Number.isSafeInteger(requested)) throw fail("memoryLimitBytes: safe integer");
|
|
31
31
|
if (platform === 'cloudflare' && requested > WORKER_MEMORY_BYTES)
|
|
32
|
-
throw fail('memoryLimitBytes
|
|
32
|
+
throw fail('memoryLimitBytes: <=128MiB');
|
|
33
33
|
const memoryLimitBytes = requested ?? (platform === 'cloudflare' ? WORKER_MEMORY_BYTES : null);
|
|
34
34
|
return Object.freeze({platform, cpuLimitMs, memoryLimitBytes,
|
|
35
35
|
memoryBytes: memoryLimitBytes ?? (platform === 'node' ? realMemory() : null)});
|
|
@@ -17,9 +17,9 @@ function rapierMediaPlugin() {
|
|
|
17
17
|
|
|
18
18
|
export function jxl(emdash, config = {}, limits = {}) {
|
|
19
19
|
const refuse = (code, message) => Object.assign(new TypeError(message), {code});
|
|
20
|
-
if (config !== null && typeof config === 'object' && config.plugins != null && !Array.isArray(config.plugins)) throw refuse('JXL_OPTIONS', "
|
|
21
|
-
if (typeof emdash !== 'function') throw refuse('JXL_INPUT', "
|
|
22
|
-
if (config === null || typeof config !== 'object' || !config.storage) throw refuse('JXL_OPTIONS', "
|
|
20
|
+
if (config !== null && typeof config === 'object' && config.plugins != null && !Array.isArray(config.plugins)) throw refuse('JXL_OPTIONS', "plugins: array");
|
|
21
|
+
if (typeof emdash !== 'function') throw refuse('JXL_INPUT', "integration: jxl(emdash, {database, storage})");
|
|
22
|
+
if (config === null || typeof config !== 'object' || !config.storage) throw refuse('JXL_OPTIONS', "storage: jxl(emdash, {storage: r2({binding}) or local({directory})})");
|
|
23
23
|
return [emdash({...config, storage: rapierStorage(config.storage, hostOptions(limits)), plugins: [...(config.plugins ?? []), rapierMediaPlugin()]}),
|
|
24
24
|
{name: 'rapier-jxl', hooks: {'astro:config:setup': ({addMiddleware}) => addMiddleware({entrypoint: file('./middleware.mjs'), order: 'pre'})}}];
|
|
25
25
|
}
|
|
@@ -38,10 +38,10 @@ async function sourceBytes(media, command, signal, call) {
|
|
|
38
38
|
for (let offset = 0; offset < bytes.length; offset += PART_BYTES) {
|
|
39
39
|
signal?.throwIfAborted();
|
|
40
40
|
const part = await media.readSource(command.key, offset, Math.min(PART_BYTES, bytes.length - offset), {generation: input.generation, signal, call});
|
|
41
|
-
if (!(part instanceof Uint8Array) || part.length !== Math.min(PART_BYTES, bytes.length - offset)) throw fail('JXL_IO', "
|
|
41
|
+
if (!(part instanceof Uint8Array) || part.length !== Math.min(PART_BYTES, bytes.length - offset)) throw fail('JXL_IO', "picture read: storage failure");
|
|
42
42
|
bytes.set(part, offset);
|
|
43
43
|
}
|
|
44
|
-
if (await digest(bytes) !== input.sha256) throw fail('JXL_INPUT', "
|
|
44
|
+
if (await digest(bytes) !== input.sha256) throw fail('JXL_INPUT', "picture: changed; reload record");
|
|
45
45
|
return bytes;
|
|
46
46
|
}
|
|
47
47
|
async function jpegPixels(media, command, signal, call) {
|
|
@@ -111,29 +111,29 @@ export function verificationAdmission(host, result, maxPixels) {
|
|
|
111
111
|
}
|
|
112
112
|
return {code: 'JXL_UNSUPPORTED', operation: 'verify', reason: 'verification_resource_bound_missing',
|
|
113
113
|
missing: [host?.cpuLimitMs !== null && 'unitCpu', (host?.memoryLimitBytes !== null || host?.memoryBytes !== undefined) && 'memory'].filter(Boolean),
|
|
114
|
-
message: "
|
|
114
|
+
message: "host allowance: retain original or change host"};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
async function candidateResult(candidate, receipt, input, store, signal) {
|
|
118
118
|
// The public driver has already verified preservation. Reassembly authenticates publication bytes only.
|
|
119
|
-
if (!candidateOf(candidate)) throw fail('JXL_INPUT', "
|
|
119
|
+
if (!candidateOf(candidate)) throw fail('JXL_INPUT', "candidate parts: regenerate");
|
|
120
120
|
if (receipt?.verified !== true || receipt.source?.kind !== 'bytes' || receipt.source.digest !== 'sha256:' + input.sha256 ||
|
|
121
121
|
!/^sha256:[a-f0-9]{64}$/.test(receipt.outputDigest ?? '') ||
|
|
122
122
|
['width', 'height', 'format', 'kept'].some(key => receipt[key] !== candidate.result[key]) ||
|
|
123
123
|
JSON.stringify(receipt.fidelity) !== JSON.stringify(candidate.result.fidelity))
|
|
124
|
-
throw fail('JXL_INPUT', "
|
|
124
|
+
throw fail('JXL_INPUT', "candidate: reverify against original");
|
|
125
125
|
const bytes = new Uint8Array(candidate.byteLength);
|
|
126
126
|
let offset = 0;
|
|
127
127
|
for (const ref of candidate.parts) {
|
|
128
128
|
signal?.throwIfAborted();
|
|
129
129
|
const part = await store.read(ref);
|
|
130
130
|
if (!(part instanceof Uint8Array) || part.length !== ref.length)
|
|
131
|
-
throw fail('JXL_IO', "
|
|
131
|
+
throw fail('JXL_IO', "candidate part: restore missing/truncated");
|
|
132
132
|
bytes.set(part, offset); offset += part.length;
|
|
133
133
|
}
|
|
134
134
|
signal?.throwIfAborted();
|
|
135
135
|
if ('sha256:' + await digest(bytes) !== receipt.outputDigest)
|
|
136
|
-
throw fail('JXL_INPUT', "
|
|
136
|
+
throw fail('JXL_INPUT', "candidate: changed; reverify original");
|
|
137
137
|
signal?.throwIfAborted();
|
|
138
138
|
return {...candidate.result, bytes, verification: receipt};
|
|
139
139
|
}
|
|
@@ -143,7 +143,7 @@ async function candidateResult(candidate, receipt, input, store, signal) {
|
|
|
143
143
|
// the whole request's CPU and memory are measured separately on the actual host.
|
|
144
144
|
export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms = 5000, driver = resumable, now = () => Date.now(), pixelSource = jpegPixels} = {}) {
|
|
145
145
|
if (!Number.isFinite(ms) || ms <= 0 || ms > 60000 || typeof scope !== 'string' || !ctx?.cron || !ctx?.kv)
|
|
146
|
-
throw fail('JXL_OPTIONS', "
|
|
146
|
+
throw fail('JXL_OPTIONS', "job config: scheduler, versioned KV, budget 1-60000ms");
|
|
147
147
|
// Each invocation keeps the Worker allowance it began with, including when it resumes an older checkpoint.
|
|
148
148
|
// Node admission already measures its whole threaded job; it does not use the Worker-only core table.
|
|
149
149
|
const worker = media.host?.platform === 'cloudflare', memory = worker
|
|
@@ -151,16 +151,16 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
151
151
|
const calls = createEmDashCallCounter();
|
|
152
152
|
const work = createWorkQueue(ctx, {scope, call: action => calls.call(action)});
|
|
153
153
|
const read = async id => {
|
|
154
|
-
if (typeof id !== 'string' || !ID.test(id)) throw fail('JXL_INPUT', "
|
|
154
|
+
if (typeof id !== 'string' || !ID.test(id)) throw fail('JXL_INPUT', "job ID: saved ID");
|
|
155
155
|
const current = await calls.call(() => ctx.kv.getVersioned(keyOf(id))) ?? {value: null, revision: null};
|
|
156
|
-
if (current.value && current.value.command.scope !== scope) throw fail('JXL_INPUT', "
|
|
156
|
+
if (current.value && current.value.command.scope !== scope) throw fail('JXL_INPUT', "job scope: reload record");
|
|
157
157
|
return current;
|
|
158
158
|
};
|
|
159
159
|
async function save(id, current, value) {
|
|
160
160
|
const saved = await calls.call(() => ctx.kv.compareAndSet(keyOf(id), current.revision, value));
|
|
161
161
|
if (saved?.applied === true) return {value, revision: saved.revision};
|
|
162
162
|
if (saved?.applied === false) return read(id);
|
|
163
|
-
throw fail('JXL_IO', "
|
|
163
|
+
throw fail('JXL_IO', "checkpoint write: unconfirmed; check state");
|
|
164
164
|
}
|
|
165
165
|
const browserExecution = async (reason, selected, signal) => ({location: 'browser', reason, settings: selected,
|
|
166
166
|
archiveOriginals: canRetireJpeg(media.host) && (await media.originals.policy({signal, call: action => calls.call(action)})).admitting});
|
|
@@ -177,7 +177,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
177
177
|
value.maxBytes !== undefined && (!Number.isSafeInteger(value.maxBytes) || value.maxBytes < 1) ||
|
|
178
178
|
value.archive !== undefined && (!record(value.archive) || value.archive.id !== value.id ||
|
|
179
179
|
value.archive.key !== value.key || value.archive.generation !== value.input.generation))
|
|
180
|
-
throw fail('JXL_OPTIONS', "
|
|
180
|
+
throw fail('JXL_OPTIONS', "job request: ID, original key, operation");
|
|
181
181
|
const command = {id: value.id, key: value.key, scope, operation: value.operation, input: value.input, options: value.options ?? {},
|
|
182
182
|
...(value.settings !== undefined && {settings: value.settings}),
|
|
183
183
|
...(value.archiveOnly === true && {archiveOnly: true}),
|
|
@@ -188,15 +188,15 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
188
188
|
let json;
|
|
189
189
|
try { json = JSON.stringify(command, (_, item) => {
|
|
190
190
|
if (['undefined', 'function', 'symbol', 'bigint'].includes(typeof item) || typeof item === 'number' && !Number.isFinite(item))
|
|
191
|
-
throw fail('JXL_OPTIONS', "
|
|
191
|
+
throw fail('JXL_OPTIONS', "request: JSON values");
|
|
192
192
|
return record(item) ? Object.fromEntries(Object.keys(item).sort().map(key => [key, item[key]])) : item;
|
|
193
|
-
}); } catch { throw fail('JXL_OPTIONS', "
|
|
194
|
-
if (text.encode(json).length > 4096) throw fail('JXL_LIMIT', "
|
|
193
|
+
}); } catch { throw fail('JXL_OPTIONS', "request: acyclic JSON"); }
|
|
194
|
+
if (text.encode(json).length > 4096) throw fail('JXL_LIMIT', "request: scheduler limit; use references");
|
|
195
195
|
return JSON.parse(json);
|
|
196
196
|
}
|
|
197
197
|
async function ensure(command, current) {
|
|
198
198
|
if (current.value) {
|
|
199
|
-
if (JSON.stringify(current.value.command) !== JSON.stringify(command)) throw fail('JXL_INPUT', "
|
|
199
|
+
if (JSON.stringify(current.value.command) !== JSON.stringify(command)) throw fail('JXL_INPUT', "job ID: reload matching request");
|
|
200
200
|
return current;
|
|
201
201
|
}
|
|
202
202
|
const refused = command.candidate && verificationAdmission(media.host, command.candidate?.result,
|
|
@@ -206,7 +206,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
206
206
|
stage: command.candidate ? 'candidate' : command.operation === 'recompress' ? 'original' : 'delivery', originalPublication: null,
|
|
207
207
|
candidateState: command.candidate ? {phase: refused ? 'blocked' : 'verifying', error: refused || null} : null,
|
|
208
208
|
execution: null, result: null, publication: null, error: null, canceled: false});
|
|
209
|
-
if (JSON.stringify(saved.value?.command) !== JSON.stringify(command)) throw fail('JXL_INPUT', "
|
|
209
|
+
if (JSON.stringify(saved.value?.command) !== JSON.stringify(command)) throw fail('JXL_INPUT', "job ID: reload matching request");
|
|
210
210
|
return saved;
|
|
211
211
|
}
|
|
212
212
|
const view = current => current?.value ? {id: current.value.command.id, revision: current.revision,
|
|
@@ -233,19 +233,19 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
233
233
|
// A job that has ended (done, failed, canceled, or handed to the browser) keeps none of its parts. Its work row stays
|
|
234
234
|
// until that is acknowledged: a failed delete is shown as cleanupPending and the next wake repeats it.
|
|
235
235
|
async function stepById(id, signal, prepare = null) {
|
|
236
|
-
if (typeof id !== 'string' || !ID.test(id)) throw fail('JXL_INPUT', "
|
|
236
|
+
if (typeof id !== 'string' || !ID.test(id)) throw fail('JXL_INPUT', "request: saved job ID");
|
|
237
237
|
signal?.throwIfAborted();
|
|
238
238
|
const release = await acquireEmDashAdvance(ctx, {owner: id, scope, ms, now, calls});
|
|
239
239
|
if (!release) {
|
|
240
240
|
let current = await read(id);
|
|
241
241
|
if (prepare) current = await prepare(current);
|
|
242
|
-
if (!current?.value) throw fail('JXL_INPUT', "
|
|
242
|
+
if (!current?.value) throw fail('JXL_INPUT', "image job: restore missing");
|
|
243
243
|
return {...view(current), busy: true};
|
|
244
244
|
}
|
|
245
245
|
try {
|
|
246
246
|
let current = await read(id);
|
|
247
247
|
if (prepare) current = await prepare(current);
|
|
248
|
-
if (!current?.value) throw fail('JXL_INPUT', "
|
|
248
|
+
if (!current?.value) throw fail('JXL_INPUT', "image job: restore missing");
|
|
249
249
|
return await advanceClaimed(current, signal);
|
|
250
250
|
} finally {
|
|
251
251
|
// A lost release expires. A durably saved result remains successful if this advisory write fails.
|
|
@@ -253,7 +253,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
async function step(current, signal) {
|
|
256
|
-
if (!current?.value) throw fail('JXL_INPUT', "
|
|
256
|
+
if (!current?.value) throw fail('JXL_INPUT', "image job: restore missing");
|
|
257
257
|
return stepById(current.value.command.id, signal);
|
|
258
258
|
}
|
|
259
259
|
async function advanceClaimed(current, signal) {
|
|
@@ -277,11 +277,11 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
277
277
|
const clearParts = async command => {
|
|
278
278
|
await driver.discard?.(command.id);
|
|
279
279
|
return createEmDashJobStore(ctx, {calls, owner: command.id, now,
|
|
280
|
-
readSource: () => { throw fail('JXL_IO', "
|
|
280
|
+
readSource: () => { throw fail('JXL_IO', "source: saved job input"); }}).clear();
|
|
281
281
|
};
|
|
282
282
|
async function advanceOnce(current, signal) {
|
|
283
283
|
let job = current?.value;
|
|
284
|
-
if (!job) throw fail('JXL_INPUT', "
|
|
284
|
+
if (!job) throw fail('JXL_INPUT', "image job: restore missing");
|
|
285
285
|
signal?.throwIfAborted();
|
|
286
286
|
const {command} = job;
|
|
287
287
|
// A refused publication's retired payload is removed in its own call (media-storage.mjs collect).
|
|
@@ -376,7 +376,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
376
376
|
const finished = await driver.finish(job.checkpoint, {...(driver.discard && {owner: command.id}), operation, input, store, ...memory, signal});
|
|
377
377
|
result = candidate ? await candidateResult(candidate, finished, command.input, store, signal) : finished;
|
|
378
378
|
if (candidate && await betterFits(media, command, candidate, result, signal, action => calls.call(action)))
|
|
379
|
-
throw fail('JXL_TARGET', "
|
|
379
|
+
throw fail('JXL_TARGET', "quality: higher fits");
|
|
380
380
|
}
|
|
381
381
|
} catch (thrown) {
|
|
382
382
|
signal?.throwIfAborted();
|
|
@@ -443,9 +443,9 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
443
443
|
// Completion is its own call; a retry reuses the same publication identity.
|
|
444
444
|
signal?.throwIfAborted();
|
|
445
445
|
if (result.meetsTarget === true && result.verification?.verified !== true)
|
|
446
|
-
throw fail('JXL_INPUT', "
|
|
446
|
+
throw fail('JXL_INPUT', "image job: reverify original/candidate");
|
|
447
447
|
if (command.archiveOnly && (result.meetsTarget !== true || result.kept !== 'jpeg-bytes' || result.fidelity !== 'exact')) {
|
|
448
|
-
if (result.meetsTarget === true) throw fail('JXL_INPUT', "
|
|
448
|
+
if (result.meetsTarget === true) throw fail('JXL_INPUT', "JPEG bytes: use exact");
|
|
449
449
|
return view(await save(command.id, current, {...job, result: summary(result),
|
|
450
450
|
publication: {key: command.key, stored: null, reason: result.reason?.code ?? 'JXL_TARGET'}}));
|
|
451
451
|
}
|
|
@@ -477,7 +477,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
477
477
|
return view(await save(command.id, current, {...job, result: summary(result),
|
|
478
478
|
publication: {key: command.key, stored: null, reason: 'key_changed'}}));
|
|
479
479
|
const receipt = result.verification;
|
|
480
|
-
if (receipt?.verified !== true) throw fail('JXL_INPUT', "JPEG job
|
|
480
|
+
if (receipt?.verified !== true) throw fail('JXL_INPUT', "JPEG job: reverify original/candidate");
|
|
481
481
|
const deliveryEligible = !command.archiveOnly && !over && result.bytes.byteLength < before.size;
|
|
482
482
|
const archive = await media.originals.beginArchive(command.key, result, {receipt, source: command.input.sha256,
|
|
483
483
|
expectedGeneration: command.input.generation, expectedDeliveryRevision: command.input.deliveryRevision,
|
|
@@ -500,7 +500,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
500
500
|
calls, work,
|
|
501
501
|
async queue(value) {
|
|
502
502
|
const command = commandOf({...value, scope});
|
|
503
|
-
if (command.archiveOnly) throw fail('JXL_OPTIONS', "
|
|
503
|
+
if (command.archiveOnly) throw fail('JXL_OPTIONS', "archive: use originals policy");
|
|
504
504
|
const current = await read(command.id);
|
|
505
505
|
if (current.value) return view(await ensure(command, current));
|
|
506
506
|
// The recurring intent recovers an interruption before the first checkpoint is saved.
|
|
@@ -515,7 +515,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
515
515
|
// An armed archive mutation first drains to its acknowledged state. The page never races its removal proof.
|
|
516
516
|
if (!job || job.archive || job.candidateState || job.publication?.collect || job.canceled) return view(current);
|
|
517
517
|
if (execution?.location !== 'browser' || !['cpu', 'memory', 'format'].includes(execution.reason) || !record(execution.settings))
|
|
518
|
-
throw fail('JXL_OPTIONS', "
|
|
518
|
+
throw fail('JXL_OPTIONS', "execution: request new server job");
|
|
519
519
|
if (!job.result && !job.error) current = await save(id, current, {...job, execution});
|
|
520
520
|
return view(current);
|
|
521
521
|
},
|
|
@@ -524,7 +524,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
524
524
|
let attempt = 0;
|
|
525
525
|
while (current.value && current.value.result === null && !current.value.error && current.value.execution?.location !== 'browser' &&
|
|
526
526
|
current.value.checkpoint?.status !== 'done' && !current.value.canceled) {
|
|
527
|
-
if (attempt++ === 8) throw fail('JXL_BUSY', "
|
|
527
|
+
if (attempt++ === 8) throw fail('JXL_BUSY', "job cancellation: retry");
|
|
528
528
|
current = await save(id, current, {...current.value, canceled: true});
|
|
529
529
|
}
|
|
530
530
|
return view(current);
|
|
@@ -532,7 +532,7 @@ export function createEmDashJobRunner(ctx, {operations, media, scope = '', ms =
|
|
|
532
532
|
async resume(value, {signal, cancel = false} = {}) {
|
|
533
533
|
const command = commandOf(value), id = command.id;
|
|
534
534
|
if (typeof cancel !== 'boolean' || cancel && !command.archiveOnly)
|
|
535
|
-
throw fail('JXL_OPTIONS', "
|
|
535
|
+
throw fail('JXL_OPTIONS', "archive cancellation: originals controller");
|
|
536
536
|
if (!cancel) return stepById(id, signal, current => ensure(command, current));
|
|
537
537
|
let current = await read(id);
|
|
538
538
|
// The durable queue recovers an interruption before the initial checkpoint was acknowledged.
|