@sealpixel/core 1.0.0-rc.12 → 1.0.0-rc.15

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 (83) hide show
  1. package/dist/assets.d.ts +0 -1
  2. package/dist/assets.js.map +1 -1
  3. package/dist/canonical-json.d.ts +0 -1
  4. package/dist/canonical-json.js.map +1 -1
  5. package/dist/compile.d.ts +0 -1
  6. package/dist/compile.js.map +1 -1
  7. package/dist/embedded.d.ts +0 -1
  8. package/dist/embedded.js.map +1 -1
  9. package/dist/errors.d.ts +1 -2
  10. package/dist/errors.js.map +1 -1
  11. package/dist/external-kernel.d.ts +0 -1
  12. package/dist/external-kernel.js.map +1 -1
  13. package/dist/generated/geometry.d.ts +1 -2
  14. package/dist/generated/geometry.js.map +1 -1
  15. package/dist/generated/output.d.ts +0 -1
  16. package/dist/generated/output.js.map +1 -1
  17. package/dist/generated/plan.d.ts +3 -4
  18. package/dist/generated/plan.js.map +1 -1
  19. package/dist/history.d.ts +0 -1
  20. package/dist/history.js.map +1 -1
  21. package/dist/image-size.d.ts +0 -1
  22. package/dist/image-size.js.map +1 -1
  23. package/dist/index.d.ts +1 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/inline-renderer.d.ts +2 -3
  26. package/dist/inline-renderer.js +4 -4
  27. package/dist/inline-renderer.js.map +1 -1
  28. package/dist/options.d.ts +0 -1
  29. package/dist/options.js.map +1 -1
  30. package/dist/plan.d.ts +0 -1
  31. package/dist/plan.js +1 -1
  32. package/dist/plan.js.map +1 -1
  33. package/dist/plugin.d.ts +0 -1
  34. package/dist/plugin.js.map +1 -1
  35. package/dist/registry.d.ts +0 -1
  36. package/dist/registry.js.map +1 -1
  37. package/dist/render.d.ts +0 -1
  38. package/dist/render.js +1 -1
  39. package/dist/render.js.map +1 -1
  40. package/dist/renderer-core.d.ts +15 -15
  41. package/dist/renderer-core.js +27 -19
  42. package/dist/renderer-core.js.map +1 -1
  43. package/dist/renderer.d.ts +3 -4
  44. package/dist/renderer.js.map +1 -1
  45. package/dist/session.d.ts +20 -71
  46. package/dist/session.js +16 -198
  47. package/dist/session.js.map +1 -1
  48. package/dist/types.d.ts +3 -3
  49. package/dist/types.js.map +1 -1
  50. package/dist/worker-protocol.d.ts +6 -7
  51. package/dist/worker-protocol.js.map +1 -1
  52. package/dist/worker-renderer.d.ts +2 -3
  53. package/dist/worker-renderer.js +8 -4
  54. package/dist/worker-renderer.js.map +1 -1
  55. package/dist/worker.d.ts +0 -1
  56. package/dist/worker.js +5 -5
  57. package/dist/worker.js.map +1 -1
  58. package/package.json +2 -2
  59. package/dist/assets.d.ts.map +0 -1
  60. package/dist/canonical-json.d.ts.map +0 -1
  61. package/dist/compile.d.ts.map +0 -1
  62. package/dist/embedded.d.ts.map +0 -1
  63. package/dist/errors.d.ts.map +0 -1
  64. package/dist/external-kernel.d.ts.map +0 -1
  65. package/dist/generated/geometry.d.ts.map +0 -1
  66. package/dist/generated/output.d.ts.map +0 -1
  67. package/dist/generated/plan.d.ts.map +0 -1
  68. package/dist/history.d.ts.map +0 -1
  69. package/dist/image-size.d.ts.map +0 -1
  70. package/dist/index.d.ts.map +0 -1
  71. package/dist/inline-renderer.d.ts.map +0 -1
  72. package/dist/options.d.ts.map +0 -1
  73. package/dist/plan.d.ts.map +0 -1
  74. package/dist/plugin.d.ts.map +0 -1
  75. package/dist/registry.d.ts.map +0 -1
  76. package/dist/render.d.ts.map +0 -1
  77. package/dist/renderer-core.d.ts.map +0 -1
  78. package/dist/renderer.d.ts.map +0 -1
  79. package/dist/session.d.ts.map +0 -1
  80. package/dist/types.d.ts.map +0 -1
  81. package/dist/worker-protocol.d.ts.map +0 -1
  82. package/dist/worker-renderer.d.ts.map +0 -1
  83. package/dist/worker.d.ts.map +0 -1
package/dist/session.js CHANGED
@@ -2,7 +2,6 @@ import { webCryptoSha256, withAssets } from './assets.js';
2
2
  import { compile } from './compile.js';
3
3
  import { SealpixelError } from './errors.js';
4
4
  import * as hist from './history.js';
5
- import { readImageSize } from './image-size.js';
6
5
  import { InlineRenderer } from './inline-renderer.js';
7
6
  import { createRegistry } from './registry.js';
8
7
  const hashMismatch = () => new SealpixelError('SOURCE_MISMATCH', 'the saved edit log belongs to a different image (hash differs)');
@@ -15,16 +14,15 @@ const EXT = {
15
14
  export function createEditorSession(options) {
16
15
  const registry = createRegistry(options.plugins);
17
16
  const maxClientMegapixels = options.limits?.maxClientMegapixels ?? 16;
18
- const maxClientBytes = options.limits?.maxClientBytes ?? 20e6;
17
+ const maxClientBytes = options.limits?.maxClientBytes ?? 50e6;
19
18
  const renderer = options.renderer ??
20
19
  new InlineRenderer({
21
20
  plugins: options.plugins,
22
21
  maxClientMegapixels,
23
- proxyMaxSide: options.proxy?.maxSide ?? 2048,
22
+ workingCopyMaxSide: options.workingCopy?.maxSide ?? 2048,
24
23
  });
25
24
  // A renderer handed in by the host outlives this session: hosts reuse it across sessions.
26
25
  const ownsRenderer = options.renderer === undefined;
27
- const proxyStrategy = options.proxy?.strategy ?? 'auto';
28
26
  const debounceMs = options.preview?.debounceMs ?? 80;
29
27
  const previewEnabled = options.preview?.enabled ?? true;
30
28
  const listeners = new Set();
@@ -47,9 +45,9 @@ export function createEditorSession(options) {
47
45
  };
48
46
  let previewTransform = null;
49
47
  /**
50
- * The image that `state.source` describes and the renderer holds: its
51
- * original bytes for server renders, and its upload, so a proxy and a render
52
- * share one copy. Changes only together with `state.source`.
48
+ * The image that `state.source` describes and the renderer holds, with its
49
+ * original bytes to restore the renderer after a failed load. Changes only
50
+ * together with `state.source`.
53
51
  */
54
52
  let committed = null;
55
53
  /** Increments on every `load`. A load that sees a newer one gives up. */
@@ -119,12 +117,12 @@ export function createEditorSession(options) {
119
117
  const log = previewTransform ? previewTransform(base) : base;
120
118
  try {
121
119
  const [image, geometry, viewGeometry] = await Promise.all([
122
- withAssets(() => renderer.render({ log, target: 'proxy', signal: controller.signal }), resolver, (id, bytes) => renderer.putAsset(id, bytes)),
120
+ withAssets(() => renderer.render({ log, target: 'workingCopy', signal: controller.signal }), resolver, (id, bytes) => renderer.putAsset(id, bytes)),
123
121
  // Geometry always describes the real output, even when a preview
124
122
  // transform shows something else on the stage.
125
- renderer.geometry({ log: base, target: 'proxy' }),
123
+ renderer.geometry({ log: base, target: 'workingCopy' }),
126
124
  // The stage needs the geometry of what it shows to keep the view steady.
127
- previewTransform ? renderer.geometry({ log, target: 'proxy' }) : null,
125
+ previewTransform ? renderer.geometry({ log, target: 'workingCopy' }) : null,
128
126
  ]);
129
127
  if (disposed || controller.signal.aborted || version !== state.version) {
130
128
  // With previews disabled no later render clears `inflight`, so a stale
@@ -160,7 +158,7 @@ export function createEditorSession(options) {
160
158
  const log = transform(hist.current(state.history));
161
159
  return withAssets(() => renderer.render({
162
160
  log,
163
- target: 'proxy',
161
+ target: 'workingCopy',
164
162
  ...(options?.signal ? { signal: options.signal } : {}),
165
163
  }), resolver, (id, bytes) => renderer.putAsset(id, bytes));
166
164
  }
@@ -182,117 +180,12 @@ export function createEditorSession(options) {
182
180
  return { bytes: new Uint8Array(await source.arrayBuffer()), name };
183
181
  }
184
182
  /**
185
- * Decodes client-side when the image is within the limits or the strategy
186
- * says so; otherwise asks the server for a deterministic proxy.
183
+ * Decodes the original in WebAssembly. The renderer keeps the full image
184
+ * only within `maxClientMegapixels`; the preview always uses the working copy.
187
185
  */
188
- async function loadInto(bytes, id, upload) {
189
- const megapixels = estimateMegapixels(bytes);
190
- const useServer = proxyStrategy === 'server' ||
191
- (proxyStrategy === 'auto' &&
192
- megapixels !== null &&
193
- megapixels > maxClientMegapixels &&
194
- options.server !== undefined);
195
- if (useServer && options.server) {
196
- const source = await sourceFor(bytes, options.server.endpoint, upload);
197
- const res = await serverFetch({
198
- source,
199
- mode: 'proxy',
200
- proxyMaxSide: options.proxy?.maxSide ?? 2048,
201
- sourceId: id,
202
- // A named source has to be claimed by its hash; the bytes are right
203
- // here, so this costs nothing and an inline source ignores it.
204
- ...(source.kind === 's3' ? { sourceHash: await webCryptoSha256(bytes) } : {}),
205
- });
206
- const descriptor = JSON.parse(res.headers.get('x-sealpixel-descriptor') ?? '{}');
207
- const proxyPng = new Uint8Array(await res.arrayBuffer());
208
- return renderer.loadProxyEncoded(proxyPng, { ...descriptor, id });
209
- }
186
+ function loadInto(bytes, id) {
210
187
  return renderer.load(bytes, id, { maxClientMegapixels });
211
188
  }
212
- /**
213
- * Where the upload route lives, given the render endpoint. A trailing
214
- * `/render` becomes `/upload`, because a host that names one route usually
215
- * names the other beside it; anything else gets `/upload` appended, which is
216
- * what a bare function url needs.
217
- */
218
- function uploadEndpointFor(endpoint) {
219
- if (options.server?.uploadEndpoint)
220
- return options.server.uploadEndpoint;
221
- return endpoint.endsWith('/render')
222
- ? `${endpoint.slice(0, -'/render'.length)}/upload`
223
- : `${endpoint.replace(/\/$/, '')}/upload`;
224
- }
225
- /**
226
- * Puts the original in the endpoint's store and remembers the reference, so a
227
- * proxy request and the render that follows it upload once between them.
228
- *
229
- * Returns null when the endpoint has no upload route, which leaves the caller
230
- * to send the original inline as before. Any other failure throws: sending
231
- * megabytes inline after an upload failed only trades one error for a more
232
- * confusing one.
233
- */
234
- async function ensureUploaded(bytes, endpoint, upload) {
235
- if (upload.source)
236
- return upload.source;
237
- const doFetch = options.server?.fetch ?? fetch;
238
- let contentType = 'application/octet-stream';
239
- try {
240
- contentType = readImageSize(bytes).mimeType ?? contentType;
241
- }
242
- catch {
243
- // Unrecognised header: let the route decide whether it takes this.
244
- }
245
- const ticketRes = await doFetch(uploadEndpointFor(endpoint), {
246
- method: 'POST',
247
- headers: { 'content-type': 'application/json', ...(options.server?.headers ?? {}) },
248
- body: JSON.stringify({ contentType, bytes: bytes.byteLength }),
249
- });
250
- // No route here, or a store that cannot sign one.
251
- if (ticketRes.status === 404 || ticketRes.status === 501)
252
- return null;
253
- if (!ticketRes.ok) {
254
- const detail = (await ticketRes.json().catch(() => ({})));
255
- throw new SealpixelError(detail.error ?? 'SERVER_ERROR', String(detail.message ?? `upload ticket refused with HTTP ${ticketRes.status}`));
256
- }
257
- const ticket = (await ticketRes.json());
258
- const form = new FormData();
259
- // The file goes last. A presigned POST policy ignores anything after it.
260
- for (const [name, value] of Object.entries(ticket.fields))
261
- form.append(name, value);
262
- form.append('file', new Blob([bytes], { type: contentType }));
263
- const put = await doFetch(ticket.url, { method: 'POST', body: form });
264
- if (!put.ok)
265
- throw new SealpixelError('SERVER_ERROR', `the store refused the upload with HTTP ${put.status}`);
266
- upload.source = { kind: 's3', bucket: ticket.bucket, key: ticket.key };
267
- return upload.source;
268
- }
269
- /** The source for a server call: the uploaded reference when it is worth one, else inline. */
270
- async function sourceFor(bytes, endpoint, upload) {
271
- const over = options.server?.uploadOver ?? 4_000_000;
272
- if (bytes.byteLength > over) {
273
- const uploaded = await ensureUploaded(bytes, endpoint, upload);
274
- if (uploaded)
275
- return uploaded;
276
- }
277
- return { kind: 'inline', base64: toBase64(bytes) };
278
- }
279
- async function serverFetch(body, endpoint = options.server?.endpoint) {
280
- if (!endpoint)
281
- throw new SealpixelError('NOT_CONFIGURED', 'no server endpoint configured');
282
- const doFetch = options.server?.fetch ?? fetch;
283
- const res = await doFetch(endpoint, {
284
- method: 'POST',
285
- headers: { 'content-type': 'application/json', ...(options.server?.headers ?? {}) },
286
- body: JSON.stringify(body),
287
- });
288
- if (!res.ok) {
289
- const detail = (await res
290
- .json()
291
- .catch(() => ({ error: 'SERVER_ERROR', message: `HTTP ${res.status}` })));
292
- throw new SealpixelError(detail.error ?? 'SERVER_ERROR', String(detail.message ?? `HTTP ${res.status}`), detail.details);
293
- }
294
- return res;
295
- }
296
189
  function resolveSavedState(saved) {
297
190
  const wrapped = saved;
298
191
  const raw = wrapped && typeof wrapped === 'object' && 'log' in wrapped ? wrapped.log : saved;
@@ -316,7 +209,7 @@ export function createEditorSession(options) {
316
209
  if (!committed)
317
210
  return;
318
211
  try {
319
- await loadInto(committed.bytes, committed.id, committed.upload);
212
+ await loadInto(committed.bytes, committed.id);
320
213
  }
321
214
  catch {
322
215
  committed = null;
@@ -378,8 +271,7 @@ export function createEditorSession(options) {
378
271
  return await exclusive(async () => {
379
272
  if (superseded())
380
273
  throw supersededError();
381
- const upload = { source: null };
382
- const loaded = await loadInto(bytes, id, upload);
274
+ const loaded = await loadInto(bytes, id);
383
275
  // The renderer holds the new image now. Until the state commits to
384
276
  // it, any failure puts the renderer back on the committed image.
385
277
  try {
@@ -395,7 +287,7 @@ export function createEditorSession(options) {
395
287
  ops: [],
396
288
  });
397
289
  const document = compile(hist.current(history), registry);
398
- committed = { bytes, id, upload };
290
+ committed = { bytes, id };
399
291
  set({
400
292
  status: 'ready',
401
293
  source: descriptor,
@@ -512,7 +404,7 @@ export function createEditorSession(options) {
512
404
  async export(exportOptions) {
513
405
  ensureReady();
514
406
  if (!state.resident) {
515
- throw new SealpixelError('NOT_RESIDENT', 'full-resolution pixels are not client-side; use requestServerRender');
407
+ throw new SealpixelError('NOT_RESIDENT', `the image is larger than maxClientMegapixels (${maxClientMegapixels}), so its full resolution is not in the browser; render the original outside the browser with the log from getEditLog()`);
516
408
  }
517
409
  const log = state.history.log;
518
410
  const upTo = exportOptions.upTo ?? state.history.index;
@@ -532,8 +424,6 @@ export function createEditorSession(options) {
532
424
  async download(downloadOptions = {}) {
533
425
  ensureReady();
534
426
  const output = downloadOptions.output ?? { format: 'image/png' };
535
- const via = downloadOptions.via ?? 'auto';
536
- const useServer = via === 'server' || (via === 'auto' && !state.resident);
537
427
  const exportOptions = {
538
428
  output,
539
429
  ...(downloadOptions.embedEditLog === undefined
@@ -542,67 +432,12 @@ export function createEditorSession(options) {
542
432
  ...(downloadOptions.upTo === undefined ? {} : { upTo: downloadOptions.upTo }),
543
433
  };
544
434
  const save = options.saveFile ?? browserSaveFile;
545
- if (useServer) {
546
- const result = await session.requestServerRender({
547
- ...exportOptions,
548
- destination: 'response',
549
- });
550
- const filename = downloadOptions.filename ??
551
- `${state.source?.id ?? 'image'}-${result.hash.slice(0, 8)}.${EXT[output.format]}`;
552
- await save(result.bytes, filename, result.mimeType);
553
- return { filename, result };
554
- }
555
435
  const result = await session.export(exportOptions);
556
436
  const filename = downloadOptions.filename ??
557
437
  `${state.source?.id ?? 'image'}-${result.hash.slice(0, 8)}.${EXT[output.format]}`;
558
438
  await save(result.bytes, filename, result.mimeType);
559
439
  return { filename, result };
560
440
  },
561
- async requestServerRender(renderOptions) {
562
- ensureReady();
563
- const endpoint = renderOptions.endpoint ?? options.server?.endpoint;
564
- if (!endpoint)
565
- throw new SealpixelError('NOT_CONFIGURED', 'no server endpoint configured');
566
- const source = renderOptions.source ??
567
- (committed ? await sourceFor(committed.bytes, endpoint, committed.upload) : null);
568
- if (!source)
569
- throw new SealpixelError('NO_SOURCE', 'original bytes are not available; pass a source reference');
570
- const destination = renderOptions.destination ?? 'response';
571
- const body = {
572
- source,
573
- editLog: state.history.log,
574
- output: renderOptions.output,
575
- upTo: renderOptions.upTo ?? state.history.index,
576
- ...(renderOptions.embedEditLog ? { embedEditLog: true } : {}),
577
- destination: { kind: destination },
578
- };
579
- const res = await serverFetch(body, endpoint);
580
- if (destination === 's3') {
581
- const job = (await res.json());
582
- return {
583
- url: job.url,
584
- objectKey: job.objectKey,
585
- bucket: job.bucket,
586
- hash: job.hash,
587
- width: job.width,
588
- height: job.height,
589
- mimeType: job.mimeType,
590
- cached: job.cached,
591
- jobKey: job.key,
592
- };
593
- }
594
- const bytes = new Uint8Array(await res.arrayBuffer());
595
- return {
596
- bytes,
597
- hash: res.headers.get('x-sealpixel-hash') ?? '',
598
- width: state.preview?.geometry.logicalOut.width ?? 0,
599
- height: state.preview?.geometry.logicalOut.height ?? 0,
600
- mimeType: res.headers.get('content-type') ??
601
- renderOptions.output.format,
602
- cached: res.headers.get('x-sealpixel-cached') === 'true',
603
- jobKey: res.headers.get('x-sealpixel-job') ?? '',
604
- };
605
- },
606
441
  dispose() {
607
442
  disposed = true;
608
443
  if (timer)
@@ -648,21 +483,4 @@ export async function browserSaveFile(bytes, filename, mimeType) {
648
483
  setTimeout(() => URL.revokeObjectURL(url), 10_000);
649
484
  }
650
485
  }
651
- function estimateMegapixels(bytes) {
652
- try {
653
- const { width, height } = readImageSize(bytes);
654
- return (width * height) / 1e6;
655
- }
656
- catch {
657
- return null;
658
- }
659
- }
660
- function toBase64(bytes) {
661
- if (typeof Buffer !== 'undefined')
662
- return Buffer.from(bytes).toString('base64');
663
- let bin = '';
664
- for (let i = 0; i < bytes.length; i += 0x8000)
665
- bin += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
666
- return btoa(bin);
667
- }
668
486
  //# sourceMappingURL=session.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAA2B,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAiB,MAAM,eAAe,CAAC;AAuM9D,MAAM,YAAY,GAAG,GAAG,EAAE,CACxB,IAAI,cAAc,CAChB,iBAAiB,EACjB,gEAAgE,CACjE,CAAC;AAEJ,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC;AAEhG,MAAM,GAAG,GAA4C;IACnD,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,MAAM;CACrB,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACzD,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,mBA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QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACnF,OAAO;IACT,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;QACb,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACtB,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC;QACnB,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,KAAK,EAAE,CAAC;QACV,CAAC,CAAC,MAAM,EAAE,CAAC;IACb,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Headless editor session. Owns the edit log (as `History`), the derived\n * document, and a renderer. Every state change schedules a debounced preview\n * render on the working copy; stale results are discarded by version.\n */\nimport type { RgbaBuffer } from '@sealpixel/wasm';\nimport { type AssetResolver, webCryptoSha256, withAssets } from './assets.js';\nimport { compile } from './compile.js';\nimport { SealpixelError } from './errors.js';\nimport * as hist from './history.js';\nimport { InlineRenderer } from './inline-renderer.js';\nimport type { Geometry } from './plan.js';\nimport type { AnyPlugin, AssetDeclaration, Document } from './plugin.js';\nimport { createRegistry, type Registry } from './registry.js';\nimport type { Renderer } from './renderer.js';\nimport type { ExportResult } from './renderer-core.js';\nimport type { EditLog, History, Operation, OutputOptions, SourceDescriptor } from './types.js';\n\nexport type LoadSource = Uint8Array | ArrayBuffer | Blob | string;\n\nexport interface LoadOptions {\n /** Saved state to resume from (an `EditLog` or `{ log, index }`), validated through the registry. */\n editLog?: unknown;\n /** History position to resume at. Defaults to the end of the log. */\n index?: number;\n /** Source id. Defaults to the File name without extension, or `image`. */\n id?: string;\n}\n\nexport interface SessionOptions {\n plugins: readonly AnyPlugin[];\n /** Defaults to an `InlineRenderer` built from `plugins`. Pass a `WorkerRenderer` in browsers. */\n renderer?: Renderer;\n /**\n * How much of the original stays in the browser. Default 16 megapixels and\n * 50e6 bytes, enough for a camera JPEG of 60 megapixels. An image above\n * `maxClientMegapixels` is not resident: the preview works on a working\n * copy, and `export` fails with `NOT_RESIDENT`: the host renders the\n * original elsewhere. An image above\n * `maxClientBytes` does not load at all (`TOO_LARGE`). The megapixel limit\n * reaches the renderer with every load, so a shared worker follows the\n * session that loads into it.\n */\n limits?: { maxClientMegapixels?: number; maxClientBytes?: number };\n preview?: { debounceMs?: number; enabled?: boolean };\n /**\n * The preview image. The session always decodes the original in WebAssembly\n * and downscales it itself. `maxSide` is the longest side for the default\n * renderer. Default 2048. A `renderer` passed in uses its own setting.\n */\n workingCopy?: { maxSide?: number };\n /** Fonts and images referenced by the log. Defaults to the plugins' declarations with relative urls. */\n assets?: AssetResolver;\n /**\n * How `download` hands bytes to the user. Defaults to an `<a download>`\n * click in browsers; required elsewhere.\n */\n saveFile?: (bytes: Uint8Array, filename: string, mimeType: string) => void | Promise<void>;\n}\n\nexport interface PreviewState {\n image: RgbaBuffer;\n /** Geometry of the real output, whatever the stage shows. */\n geometry: Geometry;\n /**\n * Geometry of the log the preview image was rendered from. Equals\n * `geometry` without a preview transform; with one (a tool showing the\n * uncropped image) it describes the pixels on the stage, so the UI can map\n * preview pixels back to the source and keep the view steady.\n */\n viewGeometry: Geometry;\n /** Version of the history the preview reflects. */\n version: number;\n}\n\nexport interface SessionState {\n status: 'empty' | 'loading' | 'ready' | 'error';\n source: SourceDescriptor | null;\n /** Whether full-resolution pixels are held client-side (local export possible). */\n resident: boolean;\n history: History;\n document: Document;\n /** Increments on every history change. */\n version: number;\n preview: PreviewState | null;\n previewPending: boolean;\n error: SealpixelError | null;\n}\n\nexport interface ExportOptions {\n output: OutputOptions;\n embedEditLog?: boolean;\n upTo?: number;\n}\n\nexport interface DownloadOptions extends Partial<ExportOptions> {\n filename?: string;\n}\n\nexport interface EditorSession {\n readonly registry: Registry;\n /**\n * Loads an image, optionally resuming a saved state. On failure the session\n * stays on the previous image: the state and the renderer keep describing\n * it. When a newer `load` starts before this one finishes, this one rejects\n * with `ABORTED` and the newer one wins.\n */\n load(source: LoadSource, options?: LoadOptions): Promise<SourceDescriptor>;\n dispatch(op: Operation): void;\n undo(): void;\n redo(): void;\n /** Moves to `index`, clamped to the log. A non-finite index, such as `NaN`, changes nothing. */\n timeTravel(index: number): void;\n canUndo(): boolean;\n canRedo(): boolean;\n getState(): SessionState;\n getEditLog(): { log: EditLog; index: number };\n getDocument(): Document;\n subscribe(listener: (state: SessionState) => void): () => void;\n /** Forces a preview render now and resolves when it is applied. */\n renderPreview(): Promise<PreviewState>;\n /** Resolves when no preview render is pending. */\n whenIdle(): Promise<void>;\n /**\n * Replaces the history with a saved state for the loaded image (controlled\n * mode). Validates through the registry and checks the source.\n */\n setEditLog(saved: unknown, index?: number): void;\n /**\n * Transforms the log before preview rendering only. Tools use it to show,\n * for example, the un-cropped image while the crop gizmo is active.\n */\n setPreviewTransform(transform: ((log: EditLog) => EditLog) | null): void;\n /**\n * Renders a working-copy-sized image from the current log, transformed, and returns\n * it without touching the stage, the state or the history. Tools use it to\n * show what an edit the user has not made yet would look like: the filter\n * tool renders its thumbnails from the log with the filter removed, so a\n * chosen preset does not end up baked into the alternatives beside it.\n */\n renderDetached(\n transform: (log: EditLog) => EditLog,\n options?: { signal?: AbortSignal },\n ): Promise<RgbaBuffer>;\n /**\n * Registers an asset the user supplied (for example an uploaded sticker):\n * stores the bytes in the renderer and records the declaration in the log\n * so the log stays self-describing. Returns the declaration with its hash.\n */\n addAsset(bytes: Uint8Array, options?: { id?: string; url?: string }): Promise<AssetDeclaration>;\n /**\n * Renders the full resolution in the browser. Throws `NOT_RESIDENT` when the\n * image is above `maxClientMegapixels`: the host then renders the original\n * elsewhere, from the log that `getEditLog()` returns.\n */\n export(options: ExportOptions): Promise<ExportResult>;\n /** Exports like `export` and hands the file to `saveFile`. */\n download(options?: DownloadOptions): Promise<{ filename: string; result: ExportResult }>;\n dispose(): void;\n}\n\nconst hashMismatch = () =>\n new SealpixelError(\n 'SOURCE_MISMATCH',\n 'the saved edit log belongs to a different image (hash differs)',\n );\n\nconst supersededError = () => new SealpixelError('ABORTED', 'a newer load() replaced this one');\n\nconst EXT: Record<OutputOptions['format'], string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpg',\n 'image/webp': 'webp',\n};\n\nexport function createEditorSession(options: SessionOptions): EditorSession {\n const registry = createRegistry(options.plugins);\n const maxClientMegapixels = options.limits?.maxClientMegapixels ?? 16;\n const maxClientBytes = options.limits?.maxClientBytes ?? 50e6;\n const renderer =\n options.renderer ??\n new InlineRenderer({\n plugins: options.plugins,\n maxClientMegapixels,\n workingCopyMaxSide: options.workingCopy?.maxSide ?? 2048,\n });\n // A renderer handed in by the host outlives this session: hosts reuse it across sessions.\n const ownsRenderer = options.renderer === undefined;\n const debounceMs = options.preview?.debounceMs ?? 80;\n const previewEnabled = options.preview?.enabled ?? true;\n\n const listeners = new Set<(state: SessionState) => void>();\n const emptyHistory = () =>\n hist.createHistory({\n version: 1,\n source: { id: '', width: 1, height: 1 },\n plugins: registry.pluginVersions(),\n ops: [],\n });\n let state: SessionState = {\n status: 'empty',\n source: null,\n resident: false,\n history: emptyHistory(),\n document: registry.initialDocument(),\n version: 0,\n preview: null,\n previewPending: false,\n error: null,\n };\n\n let previewTransform: ((log: EditLog) => EditLog) | null = null;\n /**\n * The image that `state.source` describes and the renderer holds, with its\n * original bytes to restore the renderer after a failed load. Changes only\n * together with `state.source`.\n */\n let committed: { bytes: Uint8Array; id: string } | null = null;\n /** Increments on every `load`. A load that sees a newer one gives up. */\n let loadGeneration = 0;\n /** Serializes the part of `load` that switches the renderer. */\n let loadQueue: Promise<unknown> = Promise.resolve();\n /** Bytes of assets added through `addAsset`, re-put after a renderer reload. */\n const localAssets = new Map<string, Uint8Array>();\n const resolver: AssetResolver | undefined = options.assets\n ? {\n declarations: () => options.assets?.declarations() ?? [],\n resolve: async (id) =>\n localAssets.get(id) ?? (await (options.assets as AssetResolver).resolve(id)),\n }\n : undefined;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let inflight: { version: number; controller: AbortController } | null = null;\n let idleResolvers: (() => void)[] = [];\n let disposed = false;\n\n const emit = () => {\n for (const l of listeners) l(state);\n };\n const set = (patch: Partial<SessionState>) => {\n state = { ...state, ...patch };\n emit();\n };\n const settleIdle = () => {\n if (!state.previewPending && !timer && !inflight) {\n const resolvers = idleResolvers;\n idleResolvers = [];\n for (const r of resolvers) r();\n }\n };\n\n const setHistory = (history: History) => {\n if (history === state.history) return;\n set({\n history,\n document: compile(hist.current(history), registry),\n version: state.version + 1,\n });\n schedulePreview();\n };\n\n function schedulePreview(): void {\n if (!previewEnabled || state.status !== 'ready') return;\n if (timer) clearTimeout(timer);\n set({ previewPending: true });\n timer = setTimeout(() => {\n timer = null;\n void runPreview();\n }, debounceMs);\n }\n\n async function runPreview(): Promise<PreviewState | null> {\n if (state.status !== 'ready') {\n set({ previewPending: false });\n settleIdle();\n return null;\n }\n inflight?.controller.abort();\n const version = state.version;\n const controller = new AbortController();\n inflight = { version, controller };\n const base = hist.current(state.history);\n const log = previewTransform ? previewTransform(base) : base;\n try {\n const [image, geometry, viewGeometry] = await Promise.all([\n withAssets(\n () => renderer.render({ log, target: 'workingCopy', signal: controller.signal }),\n resolver,\n (id, bytes) => renderer.putAsset(id, bytes),\n ),\n // Geometry always describes the real output, even when a preview\n // transform shows something else on the stage.\n renderer.geometry({ log: base, target: 'workingCopy' }),\n // The stage needs the geometry of what it shows to keep the view steady.\n previewTransform ? renderer.geometry({ log, target: 'workingCopy' }) : null,\n ]);\n if (disposed || controller.signal.aborted || version !== state.version) {\n // With previews disabled no later render clears `inflight`, so a stale\n // result has to, or `whenIdle` never resolves.\n if (inflight?.controller === controller) inflight = null;\n settleIdle();\n return null;\n }\n const preview = { image, geometry, viewGeometry: viewGeometry ?? geometry, version };\n inflight = null;\n set({ preview, previewPending: false, error: null });\n settleIdle();\n return preview;\n } catch (error) {\n if (inflight?.controller === controller) inflight = null;\n const e = SealpixelError.from(error);\n if (e.name === 'ABORTED' || version !== state.version) {\n settleIdle();\n return null;\n }\n set({ previewPending: false, error: e });\n settleIdle();\n return null;\n }\n }\n\n async function renderDetached(\n transform: (log: EditLog) => EditLog,\n options?: { signal?: AbortSignal },\n ): Promise<RgbaBuffer> {\n if (state.status !== 'ready') {\n throw new SealpixelError('NO_SOURCE', 'renderDetached needs a loaded image');\n }\n const log = transform(hist.current(state.history));\n return withAssets(\n () =>\n renderer.render({\n log,\n target: 'workingCopy',\n ...(options?.signal ? { signal: options.signal } : {}),\n }),\n resolver,\n (id, bytes) => renderer.putAsset(id, bytes),\n );\n }\n\n async function readBytes(\n source: LoadSource,\n ): Promise<{ bytes: Uint8Array; name: string | null }> {\n if (source instanceof Uint8Array) return { bytes: source, name: null };\n if (source instanceof ArrayBuffer) return { bytes: new Uint8Array(source), name: null };\n if (typeof source === 'string') {\n const res = await fetch(source);\n if (!res.ok) throw new SealpixelError('DECODE_FAILED', `${source}: HTTP ${res.status}`);\n return {\n bytes: new Uint8Array(await res.arrayBuffer()),\n name: source.split('/').pop() ?? null,\n };\n }\n const name =\n 'name' in source && typeof (source as File).name === 'string' ? (source as File).name : null;\n return { bytes: new Uint8Array(await source.arrayBuffer()), name };\n }\n\n /**\n * Decodes the original in WebAssembly. The renderer keeps the full image\n * only within `maxClientMegapixels`; the preview always uses the working copy.\n */\n function loadInto(bytes: Uint8Array, id: string) {\n return renderer.load(bytes, id, { maxClientMegapixels });\n }\n\n function resolveSavedState(saved: unknown): { log: EditLog; index: number | undefined } {\n const wrapped = saved as { log?: unknown; index?: unknown };\n const raw = wrapped && typeof wrapped === 'object' && 'log' in wrapped ? wrapped.log : saved;\n const log = registry.parseEditLog(raw);\n const index = typeof wrapped?.index === 'number' ? wrapped.index : undefined;\n return { log, index };\n }\n\n /** Runs `task` after every renderer switch that started before it. */\n function exclusive<T>(task: () => Promise<T>): Promise<T> {\n const run = loadQueue.then(task);\n loadQueue = run.catch(() => {});\n return run;\n }\n\n /**\n * Puts the committed image back into the renderer after a load switched it\n * and then failed. If that fails too, the session drops to `empty`: a state\n * that names an image the renderer does not hold renders wrong pixels.\n */\n async function restoreCommitted(): Promise<void> {\n // Nothing committed: the state is `empty` and nothing renders.\n if (!committed) return;\n try {\n await loadInto(committed.bytes, committed.id);\n } catch {\n committed = null;\n set({\n status: 'empty',\n source: null,\n resident: false,\n history: emptyHistory(),\n document: registry.initialDocument(),\n version: state.version + 1,\n preview: null,\n });\n }\n }\n\n /** History for a saved state resumed on a freshly loaded image. Throws `SOURCE_MISMATCH`. */\n function savedHistory(\n saved: { log: EditLog; index: number | undefined },\n descriptor: SourceDescriptor,\n index: number | undefined,\n ): History {\n const { log } = saved;\n if (log.source.hash !== undefined && log.source.hash !== descriptor.hash) {\n throw hashMismatch();\n }\n if (log.source.width !== descriptor.width || log.source.height !== descriptor.height) {\n throw new SealpixelError(\n 'SOURCE_MISMATCH',\n `the saved edit log expects ${log.source.width}x${log.source.height}, image is ${descriptor.width}x${descriptor.height}`,\n );\n }\n return hist.createHistory(\n {\n ...log,\n source: {\n ...log.source,\n hash: descriptor.hash ?? log.source.hash,\n } as SourceDescriptor,\n },\n index ?? saved.index ?? log.ops.length,\n );\n }\n\n const session: EditorSession = {\n registry,\n\n async load(source, loadOptions = {}) {\n const generation = ++loadGeneration;\n const superseded = () => generation !== loadGeneration;\n if (timer) clearTimeout(timer);\n timer = null;\n inflight?.controller.abort();\n inflight = null;\n set({ status: 'loading', error: null, preview: null, previewPending: false });\n try {\n const { bytes, name } = await readBytes(source);\n if (superseded()) throw supersededError();\n if (bytes.byteLength > maxClientBytes) {\n throw new SealpixelError(\n 'TOO_LARGE',\n `${bytes.byteLength} bytes exceed the client limit of ${maxClientBytes}`,\n );\n }\n const id = loadOptions.id ?? (name ? name.replace(/\\.[^.]+$/, '') : 'image');\n // Validate what can be validated before the renderer switches.\n const saved =\n loadOptions.editLog === undefined ? null : resolveSavedState(loadOptions.editLog);\n if (saved?.log.source.hash !== undefined) {\n if (saved.log.source.hash !== (await webCryptoSha256(bytes))) throw hashMismatch();\n if (superseded()) throw supersededError();\n }\n return await exclusive(async () => {\n if (superseded()) throw supersededError();\n const loaded = await loadInto(bytes, id);\n // The renderer holds the new image now. Until the state commits to\n // it, any failure puts the renderer back on the committed image.\n try {\n if (superseded()) throw supersededError();\n const descriptor = loaded.descriptor;\n const history = saved\n ? savedHistory(saved, descriptor, loadOptions.index)\n : hist.createHistory({\n version: 1,\n source: descriptor,\n plugins: registry.pluginVersions(),\n ops: [],\n });\n const document = compile(hist.current(history), registry);\n committed = { bytes, id };\n set({\n status: 'ready',\n source: descriptor,\n resident: loaded.resident,\n history,\n document,\n version: state.version + 1,\n preview: null,\n error: null,\n });\n schedulePreview();\n return descriptor;\n } catch (error) {\n await restoreCommitted();\n throw error;\n }\n });\n } catch (error) {\n const e = SealpixelError.from(error);\n // Only the newest load reports into the state. It waits for the\n // renderer switches ahead of it, so the state never says `ready` while\n // an older load still holds the renderer on another image.\n await exclusive(async () => {\n if (!superseded()) set({ status: state.source ? 'ready' : 'empty', error: e });\n });\n throw e;\n }\n },\n\n dispatch(op) {\n ensureReady();\n const violation = state.source\n ? registry.validateOperation(op, state.document, state.source)\n : null;\n if (violation) throw new SealpixelError('OPTION_VIOLATION', `${op.type}: ${violation}`);\n setHistory(hist.dispatch(state.history, op));\n },\n undo() {\n setHistory(hist.undo(state.history));\n },\n redo() {\n setHistory(hist.redo(state.history));\n },\n timeTravel(index) {\n setHistory(hist.timeTravel(state.history, index));\n },\n canUndo: () => hist.canUndo(state.history),\n canRedo: () => hist.canRedo(state.history),\n getState: () => state,\n getEditLog: () => ({ log: state.history.log, index: state.history.index }),\n getDocument: () => state.document,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n\n async renderPreview() {\n ensureReady();\n if (timer) clearTimeout(timer);\n timer = null;\n const result = await runPreview();\n if (result) return result;\n if (state.preview && state.preview.version === state.version) return state.preview;\n throw state.error ?? new SealpixelError('ABORTED', 'preview superseded');\n },\n\n whenIdle() {\n if (!state.previewPending && !timer && !inflight) return Promise.resolve();\n return new Promise((resolve) => idleResolvers.push(resolve));\n },\n\n setEditLog(saved, index) {\n ensureReady();\n const descriptor = state.source as SourceDescriptor;\n const resolved = resolveSavedState(saved);\n const log = resolved.log;\n if (\n log.source.hash !== undefined &&\n descriptor.hash !== undefined &&\n log.source.hash !== descriptor.hash\n ) {\n throw new SealpixelError(\n 'SOURCE_MISMATCH',\n 'the edit log belongs to a different image (hash differs)',\n );\n }\n if (log.source.width !== descriptor.width || log.source.height !== descriptor.height) {\n throw new SealpixelError('SOURCE_MISMATCH', 'the edit log has different source dimensions');\n }\n setHistory(\n hist.createHistory(\n { ...log, source: descriptor },\n index ?? resolved.index ?? log.ops.length,\n ),\n );\n },\n\n renderDetached,\n setPreviewTransform(transform) {\n previewTransform = transform;\n set({ version: state.version + 1 });\n schedulePreview();\n },\n\n async addAsset(bytes, assetOptions = {}) {\n ensureReady();\n const hash = await webCryptoSha256(bytes);\n const declaration: AssetDeclaration = {\n id: assetOptions.id ?? `asset.${hash.slice(0, 16)}`,\n hash,\n ...(assetOptions.url === undefined ? {} : { url: assetOptions.url }),\n };\n await renderer.putAsset(declaration.id, bytes);\n localAssets.set(declaration.id, bytes);\n const existing = state.history.log.assets ?? [];\n if (!existing.some((a) => a.id === declaration.id)) {\n const log: EditLog = { ...state.history.log, assets: [...existing, declaration] };\n set({ history: { ...state.history, log } });\n }\n return declaration;\n },\n\n async export(exportOptions) {\n ensureReady();\n if (!state.resident) {\n throw new SealpixelError(\n 'NOT_RESIDENT',\n `the image is larger than maxClientMegapixels (${maxClientMegapixels}), so its full resolution is not in the browser; render the original outside the browser with the log from getEditLog()`,\n );\n }\n const log = state.history.log;\n const upTo = exportOptions.upTo ?? state.history.index;\n const violations = registry.validateDocument(\n upTo === state.history.index ? state.document : compile(log, registry, upTo),\n log.source,\n );\n if (violations.length > 0) {\n throw new SealpixelError(\n 'OPTION_VIOLATION',\n violations.map((v) => `${v.plugin}: ${v.message}`).join('; '),\n violations,\n );\n }\n return renderer.export({\n log,\n output: exportOptions.output,\n upTo,\n ...(exportOptions.embedEditLog === undefined\n ? {}\n : { embedEditLog: exportOptions.embedEditLog }),\n });\n },\n\n async download(downloadOptions = {}) {\n ensureReady();\n const output = downloadOptions.output ?? { format: 'image/png' };\n const exportOptions: ExportOptions = {\n output,\n ...(downloadOptions.embedEditLog === undefined\n ? {}\n : { embedEditLog: downloadOptions.embedEditLog }),\n ...(downloadOptions.upTo === undefined ? {} : { upTo: downloadOptions.upTo }),\n };\n const save = options.saveFile ?? browserSaveFile;\n const result = await session.export(exportOptions);\n const filename =\n downloadOptions.filename ??\n `${state.source?.id ?? 'image'}-${result.hash.slice(0, 8)}.${EXT[output.format]}`;\n await save(result.bytes, filename, result.mimeType);\n return { filename, result };\n },\n\n dispose() {\n disposed = true;\n if (timer) clearTimeout(timer);\n inflight?.controller.abort();\n listeners.clear();\n if (ownsRenderer) renderer.dispose();\n },\n };\n\n function ensureReady(): void {\n if (state.status !== 'ready') throw new SealpixelError('NO_SOURCE', 'load an image first');\n }\n\n return session;\n}\n\n/** Default `saveFile`: an `<a download>` click, with the share sheet as a fallback on iOS Safari. */\nexport async function browserSaveFile(\n bytes: Uint8Array,\n filename: string,\n mimeType: string,\n): Promise<void> {\n if (typeof document === 'undefined' || typeof URL.createObjectURL !== 'function') {\n throw new SealpixelError(\n 'DOWNLOAD_UNSUPPORTED',\n 'no DOM available; pass saveFile to createEditorSession',\n );\n }\n const blob = new Blob([bytes as BlobPart], { type: mimeType });\n const nav = navigator as Navigator & { canShare?: (d: ShareData) => boolean };\n const isIOS = /iP(hone|ad|od)/.test(navigator.userAgent);\n if (\n isIOS &&\n typeof File !== 'undefined' &&\n nav.canShare?.({ files: [new File([blob], filename, { type: mimeType })] })\n ) {\n await navigator.share({ files: [new File([blob], filename, { type: mimeType })] });\n return;\n }\n const url = URL.createObjectURL(blob);\n try {\n const a = document.createElement('a');\n a.href = url;\n a.download = filename;\n a.rel = 'noopener';\n a.style.display = 'none';\n document.body.appendChild(a);\n a.click();\n a.remove();\n } finally {\n setTimeout(() => URL.revokeObjectURL(url), 10_000);\n }\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -80,7 +80,7 @@ export interface RenderOptions {
80
80
  output: OutputOptions;
81
81
  /**
82
82
  * `truth` (default) requires the buffer to have the logical source
83
- * dimensions. `preview` accepts a proxy and scales lengths accordingly.
83
+ * dimensions. `preview` accepts a working copy and scales lengths accordingly.
84
84
  */
85
85
  mode?: 'truth' | 'preview';
86
86
  /** Render only `ops[0..upTo)`. Defaults to all ops. */
@@ -100,7 +100,8 @@ export interface RenderOptions {
100
100
  embedEditLog?: boolean;
101
101
  }
102
102
  export interface RenderResult {
103
- bytes: Uint8Array;
103
+ /** Backed by a plain `ArrayBuffer`, so it is a `BlobPart`. */
104
+ bytes: Uint8Array<ArrayBuffer>;
104
105
  mimeType: OutputFormat;
105
106
  width: number;
106
107
  height: number;
@@ -111,4 +112,3 @@ export interface RenderResult {
111
112
  timings: Record<string, number>;
112
113
  }
113
114
  export type RenderSource = Uint8Array | RgbaBuffer;
114
- //# sourceMappingURL=types.d.ts.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RgbaBuffer } from '@sealpixel/wasm';\n\nexport type { DecodedImage, RgbaBuffer, SealpixelWasm } from '@sealpixel/wasm';\n\n/** Normalised coordinate in 0..1. */\nexport type Unit = number;\n/** Length in pixels of the logical, full-resolution stage. */\nexport type SourcePx = number;\nexport type Radians = number;\n\nexport interface Point {\n x: Unit;\n y: Unit;\n}\nexport interface Rect {\n x: Unit;\n y: Unit;\n width: Unit;\n height: Unit;\n}\n/** sRGB colour with straight alpha, each channel 0..1. */\nexport type Color = [r: number, g: number, b: number, a: number];\n\n/** Identity and logical dimensions of the original image after EXIF orientation. */\nexport interface SourceDescriptor {\n id: string;\n width: number;\n height: number;\n /** sha256 of the original bytes. The server verifies it before rendering. */\n hash?: string;\n mimeType?: string;\n}\n\n/** Augmented by plugins via `declare module '@sealpixel/core'`. */\n// biome-ignore lint/suspicious/noEmptyInterface: augmentation target\nexport interface OperationRegistry {}\nexport type OperationType = keyof OperationRegistry & string;\n/**\n * Union of every registered operation. Falls back to the bare base shape when\n * no plugin has augmented the registry (for example inside `@sealpixel/core`'s\n * own tests), so generic code can still read `type` and `id`.\n */\nexport type Operation = [OperationType] extends [never]\n ? OperationBase<string>\n : OperationRegistry[OperationType];\n\nexport interface OperationBase<T extends string> {\n type: T;\n /** Unique per log entry. Ignored by the renderer. */\n id: string;\n /** Wall-clock timestamp. Ignored by the renderer. */\n at?: number | undefined;\n}\n\n/** The only state of an editing session. Serialisable as JSON. */\nexport interface EditLog {\n version: 1;\n source: SourceDescriptor;\n /** Plugin id to plugin version, for migrations. */\n plugins: Record<string, number>;\n /**\n * Assets the ops reference that are not declared by a plugin (for example\n * an uploaded sticker). Hosts must make `url` reachable for other devices\n * and the server.\n */\n assets?: import('./plugin.js').AssetDeclaration[];\n ops: Operation[];\n}\n\n/** Undo/redo position over an edit log: `ops[0..index)` is the current state. */\nexport interface History {\n log: EditLog;\n index: number;\n}\n\nexport type OutputFormat = 'image/png' | 'image/jpeg' | 'image/webp';\n\nexport interface OutputOptions {\n format: OutputFormat;\n /** 0..1, lossy formats only. Default 0.9. */\n quality?: number;\n /** JPEG only. Default false. */\n progressive?: boolean;\n /** JPEG only. Default '4:2:0'. */\n chromaSubsampling?: '4:2:0' | '4:4:4';\n /** WebP only. V1 always encodes lossless. */\n lossless?: boolean;\n /** Opaque colour that alpha is flattened onto for JPEG, 0..255 each. Default white. */\n background?: [r: number, g: number, b: number];\n}\n\nexport interface RenderOptions {\n output: OutputOptions;\n /**\n * `truth` (default) requires the buffer to have the logical source\n * dimensions. `preview` accepts a working copy and scales lengths accordingly.\n */\n mode?: 'truth' | 'preview';\n /** Render only `ops[0..upTo)`. Defaults to all ops. */\n upTo?: number;\n signal?: AbortSignal;\n /** Pre-loaded core. Servers pass this to reuse one instance across requests. */\n wasm?: import('@sealpixel/wasm').SealpixelWasm;\n /** Plugins that interpret the log's ops. Required when the log has ops. */\n registry?: import('./registry.js').Registry;\n /** Supplies fonts and images referenced by the log. */\n assets?: import('./assets.js').AssetResolver;\n /**\n * Store `canonicalJson({ log, index })` in the file's metadata so it can be\n * reopened with `readEmbeddedState`. Off by default: the log may contain\n * text the user does not want to ship.\n */\n embedEditLog?: boolean;\n}\n\nexport interface RenderResult {\n /** Backed by a plain `ArrayBuffer`, so it is a `BlobPart`. */\n bytes: Uint8Array<ArrayBuffer>;\n mimeType: OutputFormat;\n width: number;\n height: number;\n /** sha256 of `bytes`, computed inside the core. */\n hash: string;\n /** Version of the core that produced the bytes. */\n coreVersion: string;\n timings: Record<string, number>;\n}\n\nexport type RenderSource = Uint8Array | RgbaBuffer;\n"]}
@@ -17,12 +17,12 @@ export type WorkerRequest = {
17
17
  options?: RendererLoadOptions;
18
18
  } | {
19
19
  id: number;
20
- type: 'loadProxy';
21
- proxy: RgbaBuffer;
20
+ type: 'loadWorkingCopy';
21
+ workingCopy: RgbaBuffer;
22
22
  descriptor: SourceDescriptor;
23
23
  } | {
24
24
  id: number;
25
- type: 'loadProxyEncoded';
25
+ type: 'loadWorkingCopyEncoded';
26
26
  bytes: Uint8Array;
27
27
  descriptor: SourceDescriptor;
28
28
  } | {
@@ -37,7 +37,7 @@ export type WorkerRequest = {
37
37
  id: number;
38
38
  type: 'geometry';
39
39
  log: RenderRequest['log'];
40
- target: 'proxy' | 'full';
40
+ target: 'workingCopy' | 'full';
41
41
  upTo?: number;
42
42
  } | {
43
43
  id: number;
@@ -71,8 +71,8 @@ export type ResultOf = {
71
71
  plugins: Record<string, number>;
72
72
  };
73
73
  load: LoadedSource;
74
- loadProxy: LoadedSource;
75
- loadProxyEncoded: LoadedSource;
74
+ loadWorkingCopy: LoadedSource;
75
+ loadWorkingCopyEncoded: LoadedSource;
76
76
  render: RgbaBuffer;
77
77
  export: ExportResult;
78
78
  geometry: Geometry;
@@ -98,4 +98,3 @@ export declare function webTransport(target: {
98
98
  }): Transport;
99
99
  /** Buffers inside a message that can be transferred instead of copied. */
100
100
  export declare function transferablesOf(value: unknown): ArrayBuffer[];
101
- //# sourceMappingURL=worker-protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-protocol.js","sourceRoot":"","sources":["../src/worker-protocol.ts"],"names":[],"mappings":"AA4DA,8DAA8D;AAC9D,MAAM,UAAU,YAAY,CAAC,MAK5B;IACC,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,QAAQ,IAAI,EAAE,CAAC;QACnE,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAClF,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;YACrB,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,CAA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AC9B,MAAM,KAAK,GAAG,CAAC,CAAU,EAAE,EAAE;QAC3B,IACE,CAAC,YAAY,UAAU;YACvB,CAAC,CAAC,MAAM,YAAY,WAAW;YAC/B,CAAC,CAAC,UAAU,KAAK,CAAC;YAClB,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,EACpC,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACrB,CAAC;aAAM,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,YAAY,UAAU,CAAC,EAAE,CAAC;YACpE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,CAA4B,CAAC;gBAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAChF,CAAC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,CAAC;IACb,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Messages between `WorkerRenderer` (main thread) and `startSealpixelWorker`.\n * Buffers travel as transferables; everything else is structured-cloned.\n */\nimport type { RgbaBuffer } from '@sealpixel/wasm';\nimport type { Geometry } from './plan.js';\nimport type {\n ExportRequest,\n ExportResult,\n LoadedSource,\n RendererLoadOptions,\n RenderRequest,\n} from './renderer-core.js';\nimport type { SourceDescriptor } from './types.js';\n\nexport type WorkerRequest =\n | { id: number; type: 'init' }\n | { id: number; type: 'load'; bytes: Uint8Array; sourceId: string; options?: RendererLoadOptions }\n | { id: number; type: 'loadWorkingCopy'; workingCopy: RgbaBuffer; descriptor: SourceDescriptor }\n | { id: number; type: 'loadWorkingCopyEncoded'; bytes: Uint8Array; descriptor: SourceDescriptor }\n | { id: number; type: 'render'; req: Omit<RenderRequest, 'signal'> }\n | { id: number; type: 'export'; req: ExportRequest }\n | {\n id: number;\n type: 'geometry';\n log: RenderRequest['log'];\n target: 'workingCopy' | 'full';\n upTo?: number;\n }\n | { id: number; type: 'unload' }\n | { id: number; type: 'asset'; assetId: string; bytes: Uint8Array }\n | { id: number; type: 'abort'; target: number };\n\nexport type WorkerResponse =\n | { id: number; ok: true; result: unknown }\n | { id: number; ok: false; error: { name: string; message: string; details?: unknown } };\n\nexport type ResultOf = {\n init: { coreVersion: string; plugins: Record<string, number> };\n load: LoadedSource;\n loadWorkingCopy: LoadedSource;\n loadWorkingCopyEncoded: LoadedSource;\n render: RgbaBuffer;\n export: ExportResult;\n geometry: Geometry;\n unload: undefined;\n asset: undefined;\n abort: undefined;\n};\n\n/**\n * Minimal transport both sides need. Web Workers (`self`, `Worker`) and\n * Node's `MessagePort` satisfy it directly or through a small adapter.\n */\nexport interface Transport {\n postMessage(message: unknown, transfer?: ArrayBuffer[]): void;\n onMessage(handler: (message: unknown) => void): void;\n close?(): void;\n}\n\n/** Adapter for a `Worker` or `DedicatedWorkerGlobalScope`. */\nexport function webTransport(target: {\n postMessage(message: unknown, transfer?: Transferable[]): void;\n addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;\n terminate?(): void;\n close?(): void;\n}): Transport {\n return {\n postMessage: (m, transfer) => target.postMessage(m, transfer ?? []),\n onMessage: (handler) => target.addEventListener('message', (e) => handler(e.data)),\n close: () => {\n target.terminate?.();\n target.close?.();\n },\n };\n}\n\n/** Buffers inside a message that can be transferred instead of copied. */\nexport function transferablesOf(value: unknown): ArrayBuffer[] {\n const out: ArrayBuffer[] = [];\n const visit = (v: unknown) => {\n if (\n v instanceof Uint8Array &&\n v.buffer instanceof ArrayBuffer &&\n v.byteOffset === 0 &&\n v.byteLength === v.buffer.byteLength\n ) {\n out.push(v.buffer);\n } else if (v && typeof v === 'object' && !(v instanceof Uint8Array)) {\n for (const inner of Object.values(v as Record<string, unknown>)) visit(inner);\n }\n };\n visit(value);\n return out;\n}\n"]}
@@ -15,8 +15,8 @@ export declare class WorkerRenderer implements Renderer {
15
15
  plugins: Record<string, number>;
16
16
  }>;
17
17
  load(bytes: Uint8Array, id: string, options?: RendererLoadOptions): Promise<import("./renderer-core.js").LoadedSource>;
18
- loadProxy(proxy: RgbaBuffer, descriptor: SourceDescriptor): Promise<import("./renderer-core.js").LoadedSource>;
19
- loadProxyEncoded(bytes: Uint8Array, descriptor: SourceDescriptor): Promise<import("./renderer-core.js").LoadedSource>;
18
+ loadWorkingCopy(workingCopy: RgbaBuffer, descriptor: SourceDescriptor): Promise<import("./renderer-core.js").LoadedSource>;
19
+ loadWorkingCopyEncoded(bytes: Uint8Array, descriptor: SourceDescriptor): Promise<import("./renderer-core.js").LoadedSource>;
20
20
  render(req: RenderRequest): Promise<RgbaBuffer>;
21
21
  export(req: Parameters<Renderer['export']>[0]): Promise<import("./renderer-core.js").ExportResult>;
22
22
  geometry(req: Parameters<Renderer['geometry']>[0]): Promise<import("./plan.js").Geometry>;
@@ -32,4 +32,3 @@ export declare class WorkerRenderer implements Renderer {
32
32
  private post;
33
33
  private receive;
34
34
  }
35
- //# sourceMappingURL=worker-renderer.d.ts.map
@@ -21,11 +21,15 @@ export class WorkerRenderer {
21
21
  ...(options ? { options } : {}),
22
22
  });
23
23
  }
24
- loadProxy(proxy, descriptor) {
25
- return this.call({ type: 'loadProxy', proxy, descriptor });
24
+ loadWorkingCopy(workingCopy, descriptor) {
25
+ return this.call({ type: 'loadWorkingCopy', workingCopy, descriptor });
26
26
  }
27
- loadProxyEncoded(bytes, descriptor) {
28
- return this.call({ type: 'loadProxyEncoded', bytes, descriptor });
27
+ loadWorkingCopyEncoded(bytes, descriptor) {
28
+ return this.call({
29
+ type: 'loadWorkingCopyEncoded',
30
+ bytes,
31
+ descriptor,
32
+ });
29
33
  }
30
34
  async render(req) {
31
35
  const { signal, ...rest } = req;