File size: 901 Bytes
f918b86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Chase Hendrick
// Runs the Ink Bench alignment and scoring off the main thread, so the page stays responsive.
import * as C from './bench-core.js';
self.onmessage = async ({ data }) => {
  const { id, op } = data;
  try {
    if (op === 'align') {
      const al = await C.align(data.tgt, data.P, { start: data.start || null, onProgress: (f) => self.postMessage({ id, progress: f }) });
      self.postMessage({ id, result: al });
    } else if (op === 'score') {
      const { val, m } = C.applyAlignment(data.ref, data.P, data.al);
      const alignNcc = C.rnd(C.ncc(data.tgt || data.ref, val, m, 1), 6);
      const blurBest = C.blurEstimate(data.ref, val, m);
      self.postMessage({ id, result: { val, m, alignNcc, blurBest } }, [val.buffer, m.buffer]);
    }
  } catch (e) { self.postMessage({ id, error: String(e.message || e) }); }
};