@fairfox/polly 0.72.0 → 0.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/src/elysia/index.js +464 -4
  2. package/dist/src/elysia/index.js.map +6 -4
  3. package/dist/src/peer.d.ts +2 -0
  4. package/dist/src/peer.js +468 -4
  5. package/dist/src/peer.js.map +8 -5
  6. package/dist/src/polly-ui/ActionInput.d.ts +2 -1
  7. package/dist/src/polly-ui/ActionSelect.d.ts +2 -1
  8. package/dist/src/polly-ui/Button.d.ts +4 -0
  9. package/dist/src/polly-ui/Cluster.d.ts +2 -1
  10. package/dist/src/polly-ui/Code.d.ts +2 -1
  11. package/dist/src/polly-ui/Dropdown.d.ts +6 -0
  12. package/dist/src/polly-ui/Surface.d.ts +12 -1
  13. package/dist/src/polly-ui/Text.d.ts +23 -11
  14. package/dist/src/polly-ui/index.css +44 -18
  15. package/dist/src/polly-ui/index.js +118 -12
  16. package/dist/src/polly-ui/index.js.map +12 -11
  17. package/dist/src/polly-ui/internal/passthrough.d.ts +25 -0
  18. package/dist/src/polly-ui/styles.css +59 -18
  19. package/dist/src/polly-ui/theme.css +1 -0
  20. package/dist/src/shared/lib/peer-repo-server.d.ts +18 -0
  21. package/dist/src/shared/lib/sweep-sealed.d.ts +111 -0
  22. package/dist/tools/test/src/browser/run.js +42 -33
  23. package/dist/tools/test/src/browser/run.js.map +6 -5
  24. package/dist/tools/test/src/browser/runner-core.d.ts +32 -0
  25. package/dist/tools/test/src/e2e-mesh/index.js +193 -171
  26. package/dist/tools/test/src/e2e-mesh/index.js.map +4 -4
  27. package/dist/tools/test/src/visual/index.js +248 -229
  28. package/dist/tools/test/src/visual/index.js.map +5 -5
  29. package/dist/tools/verify/specs/tla/MeshSeed.cfg +27 -0
  30. package/dist/tools/verify/specs/tla/MeshSeed.tla +179 -0
  31. package/dist/tools/verify/specs/tla/README.md +11 -1
  32. package/dist/tools/verify/src/cli.js +79 -2
  33. package/dist/tools/verify/src/cli.js.map +7 -6
  34. package/dist/tools/visualize/src/cli.js +179 -3
  35. package/dist/tools/visualize/src/cli.js.map +6 -6
  36. package/package.json +3 -2
@@ -13374,232 +13374,25 @@ var require_png = __commonJS((exports) => {
13374
13374
  };
13375
13375
  });
13376
13376
 
13377
- // tools/test/src/visual/compare.ts
13378
- var {readFileSync, writeFileSync} = (() => ({}));
13379
-
13380
- // node_modules/.bun/pixelmatch@7.2.0/node_modules/pixelmatch/index.js
13381
- function pixelmatch(img1, img2, output, width, height, options = {}) {
13382
- const {
13383
- threshold = 0.1,
13384
- alpha = 0.1,
13385
- aaColor = [255, 255, 0],
13386
- diffColor = [255, 0, 0],
13387
- checkerboard = true,
13388
- includeAA,
13389
- diffColorAlt,
13390
- diffMask
13391
- } = options;
13392
- if (!isPixelData(img1) || !isPixelData(img2) || output && !isPixelData(output))
13393
- throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");
13394
- if (img1.length !== img2.length || output && output.length !== img1.length)
13395
- throw new Error(`Image sizes do not match. Image 1 size: ${img1.length}, image 2 size: ${img2.length}`);
13396
- if (img1.length !== width * height * 4)
13397
- throw new Error(`Image data size does not match width/height. Expecting ${width * height * 4}. Got ${img1.length}`);
13398
- const len = width * height;
13399
- const a32 = new Uint32Array(img1.buffer, img1.byteOffset, len);
13400
- const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len);
13401
- let identical = true;
13402
- for (let i = 0;i < len; i++) {
13403
- if (a32[i] !== b32[i]) {
13404
- identical = false;
13405
- break;
13406
- }
13407
- }
13408
- if (identical) {
13409
- if (output && !diffMask) {
13410
- for (let i = 0, pos = 0;i < len; i++, pos += 4)
13411
- drawGrayPixel(img1, pos, alpha, output);
13412
- }
13413
- return 0;
13414
- }
13415
- const maxDelta = 35215 * threshold * threshold;
13416
- const [aaR, aaG, aaB] = aaColor;
13417
- const [diffR, diffG, diffB] = diffColor;
13418
- const [altR, altG, altB] = diffColorAlt || diffColor;
13419
- let diff = 0;
13420
- for (let i = 0, pos = 0;i < len; i++, pos += 4) {
13421
- const delta = a32[i] === b32[i] ? 0 : colorDelta(img1, img2, pos, pos, checkerboard);
13422
- if (Math.abs(delta) > maxDelta) {
13423
- const x = i % width;
13424
- const y = i / width | 0;
13425
- const isExcludedAA = !includeAA && (antialiased(img1, x, y, width, height, a32, b32, checkerboard) || antialiased(img2, x, y, width, height, b32, a32, checkerboard));
13426
- if (isExcludedAA) {
13427
- if (output && !diffMask)
13428
- drawPixel(output, pos, aaR, aaG, aaB);
13429
- } else {
13430
- if (output) {
13431
- if (delta < 0) {
13432
- drawPixel(output, pos, altR, altG, altB);
13433
- } else {
13434
- drawPixel(output, pos, diffR, diffG, diffB);
13435
- }
13436
- }
13437
- diff++;
13438
- }
13439
- } else if (output && !diffMask) {
13440
- drawGrayPixel(img1, pos, alpha, output);
13441
- }
13442
- }
13443
- return diff;
13444
- }
13445
- function isPixelData(arr) {
13446
- return ArrayBuffer.isView(arr) && arr.BYTES_PER_ELEMENT === 1;
13447
- }
13448
- function antialiased(img, x1, y1, width, height, a32, b32, checkerboard) {
13449
- const x0 = Math.max(x1 - 1, 0);
13450
- const y0 = Math.max(y1 - 1, 0);
13451
- const x2 = Math.min(x1 + 1, width - 1);
13452
- const y2 = Math.min(y1 + 1, height - 1);
13453
- const pos4 = (y1 * width + x1) * 4;
13454
- const cr = img[pos4];
13455
- const cg = img[pos4 + 1];
13456
- const cb = img[pos4 + 2];
13457
- const ca = img[pos4 + 3];
13458
- let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
13459
- let min = 0;
13460
- let max = 0;
13461
- let minX = 0;
13462
- let minY = 0;
13463
- let maxX = 0;
13464
- let maxY = 0;
13465
- for (let x = x0;x <= x2; x++) {
13466
- for (let y = y0;y <= y2; y++) {
13467
- if (x === x1 && y === y1)
13468
- continue;
13469
- const delta = brightnessDelta(img, pos4, (y * width + x) * 4, cr, cg, cb, ca, checkerboard);
13470
- if (delta === 0) {
13471
- zeroes++;
13472
- if (zeroes > 2)
13473
- return false;
13474
- } else if (delta < min) {
13475
- min = delta;
13476
- minX = x;
13477
- minY = y;
13478
- } else if (delta > max) {
13479
- max = delta;
13480
- maxX = x;
13481
- maxY = y;
13482
- }
13483
- }
13484
- }
13485
- if (min === 0 || max === 0)
13486
- return false;
13487
- return hasManySiblings(a32, minX, minY, width, height) && hasManySiblings(b32, minX, minY, width, height) || hasManySiblings(a32, maxX, maxY, width, height) && hasManySiblings(b32, maxX, maxY, width, height);
13488
- }
13489
- function hasManySiblings(img, x1, y1, width, height) {
13490
- const x0 = Math.max(x1 - 1, 0);
13491
- const y0 = Math.max(y1 - 1, 0);
13492
- const x2 = Math.min(x1 + 1, width - 1);
13493
- const y2 = Math.min(y1 + 1, height - 1);
13494
- const val = img[y1 * width + x1];
13495
- let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
13496
- for (let x = x0;x <= x2; x++) {
13497
- for (let y = y0;y <= y2; y++) {
13498
- if (x === x1 && y === y1)
13499
- continue;
13500
- zeroes += +(val === img[y * width + x]);
13501
- if (zeroes > 2)
13502
- return true;
13503
- }
13504
- }
13505
- return false;
13506
- }
13507
- function colorDelta(img1, img2, k, m, checkerboard) {
13508
- const r1 = img1[k];
13509
- const g1 = img1[k + 1];
13510
- const b1 = img1[k + 2];
13511
- const a1 = img1[k + 3];
13512
- const r2 = img2[m];
13513
- const g2 = img2[m + 1];
13514
- const b2 = img2[m + 2];
13515
- const a2 = img2[m + 3];
13516
- let dr = r1 - r2;
13517
- let dg = g1 - g2;
13518
- let db = b1 - b2;
13519
- const da = a1 - a2;
13520
- if (a1 < 255 || a2 < 255) {
13521
- let rb = 255, gb = 255, bb = 255;
13522
- if (checkerboard) {
13523
- rb = 48 + 159 * (k % 2);
13524
- gb = 48 + 159 * ((k / 1.618033988749895 | 0) % 2);
13525
- bb = 48 + 159 * ((k / 2.618033988749895 | 0) % 2);
13526
- }
13527
- dr = (r1 * a1 - r2 * a2 - rb * da) / 255;
13528
- dg = (g1 * a1 - g2 * a2 - gb * da) / 255;
13529
- db = (b1 * a1 - b2 * a2 - bb * da) / 255;
13530
- }
13531
- const y = dr * 0.29889531 + dg * 0.58662247 + db * 0.11448223;
13532
- const i = dr * 0.59597799 - dg * 0.2741761 - db * 0.32180189;
13533
- const q = dr * 0.21147017 - dg * 0.52261711 + db * 0.31114694;
13534
- const delta = 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q;
13535
- return y > 0 ? -delta : delta;
13536
- }
13537
- function brightnessDelta(img, k, m, r1, g1, b1, a1, checkerboard) {
13538
- const r2 = img[m];
13539
- const g2 = img[m + 1];
13540
- const b2 = img[m + 2];
13541
- const a2 = img[m + 3];
13542
- let dr = r1 - r2;
13543
- let dg = g1 - g2;
13544
- let db = b1 - b2;
13545
- const da = a1 - a2;
13546
- if (!dr && !dg && !db && !da)
13547
- return 0;
13548
- if (a1 < 255 || a2 < 255) {
13549
- let rb = 255, gb = 255, bb = 255;
13550
- if (checkerboard) {
13551
- rb = 48 + 159 * (k % 2);
13552
- gb = 48 + 159 * ((k / 1.618033988749895 | 0) % 2);
13553
- bb = 48 + 159 * ((k / 2.618033988749895 | 0) % 2);
13554
- }
13555
- dr = (r1 * a1 - r2 * a2 - rb * da) / 255;
13556
- dg = (g1 * a1 - g2 * a2 - gb * da) / 255;
13557
- db = (b1 * a1 - b2 * a2 - bb * da) / 255;
13558
- }
13559
- return dr * 0.29889531 + dg * 0.58662247 + db * 0.11448223;
13560
- }
13561
- function drawPixel(output, pos, r, g, b) {
13562
- output[pos] = r;
13563
- output[pos + 1] = g;
13564
- output[pos + 2] = b;
13565
- output[pos + 3] = 255;
13566
- }
13567
- function drawGrayPixel(img, i, alpha, output) {
13568
- const val = 255 + (img[i] * 0.29889531 + img[i + 1] * 0.58662247 + img[i + 2] * 0.11448223 - 255) * alpha * img[i + 3] / 255;
13569
- drawPixel(output, i, val, val, val);
13570
- }
13571
-
13572
- // tools/test/src/visual/compare.ts
13573
- var import_pngjs = __toESM(require_png(), 1);
13574
- function compareImages(baselinePath, actualPath, diffPath, options = {}) {
13575
- const threshold = options.threshold ?? 0.1;
13576
- const mismatchRatio = options.mismatchRatio ?? 0.001;
13577
- const includeAA = options.includeAA ?? false;
13578
- const baseline = import_pngjs.PNG.sync.read(readFileSync(baselinePath));
13579
- const actual = import_pngjs.PNG.sync.read(readFileSync(actualPath));
13580
- if (baseline.width !== actual.width || baseline.height !== actual.height) {
13581
- throw new Error(`Image dimensions differ: baseline ${baseline.width}x${baseline.height}, actual ${actual.width}x${actual.height}`);
13582
- }
13583
- const { width, height } = baseline;
13584
- const diff = new import_pngjs.PNG({ width, height });
13585
- const diffPixels = pixelmatch(baseline.data, actual.data, diff.data, width, height, {
13586
- threshold,
13587
- includeAA
13588
- });
13589
- const totalPixels = width * height;
13590
- const ratio = diffPixels / totalPixels;
13591
- const match2 = ratio <= mismatchRatio;
13592
- let diffPngPath;
13593
- if (!match2) {
13594
- writeFileSync(diffPath, import_pngjs.PNG.sync.write(diff));
13595
- diffPngPath = diffPath;
13596
- }
13597
- return { match: match2, diffPixels, totalPixels, ratio, diffPngPath };
13598
- }
13599
- // tools/test/src/visual/harness.ts
13600
- var {existsSync, mkdirSync, writeFileSync: writeFileSync2} = (() => ({}));
13601
-
13602
13377
  // node:path
13378
+ var exports_path = {};
13379
+ __export(exports_path, {
13380
+ sep: () => sep,
13381
+ resolve: () => resolve,
13382
+ relative: () => relative,
13383
+ posix: () => posix,
13384
+ parse: () => parse,
13385
+ normalize: () => normalize,
13386
+ join: () => join,
13387
+ isAbsolute: () => isAbsolute,
13388
+ format: () => format2,
13389
+ extname: () => extname,
13390
+ dirname: () => dirname,
13391
+ delimiter: () => delimiter,
13392
+ default: () => path_default,
13393
+ basename: () => basename,
13394
+ _makeLong: () => _makeLong
13395
+ });
13603
13396
  function assertPath(path) {
13604
13397
  if (typeof path !== "string")
13605
13398
  throw TypeError("Path must be a string. Received " + JSON.stringify(path));
@@ -13915,11 +13708,237 @@ function parse(path) {
13915
13708
  ret.dir = "/";
13916
13709
  return ret;
13917
13710
  }
13918
- var sep = "/";
13919
- var delimiter = ":";
13920
- var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format: format2, parse, sep, delimiter, win32: null, posix: null });
13711
+ var sep = "/", delimiter = ":", posix, path_default;
13712
+ var init_path = __esm(() => {
13713
+ posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format: format2, parse, sep, delimiter, win32: null, posix: null });
13714
+ path_default = posix;
13715
+ });
13716
+
13717
+ // tools/test/src/visual/compare.ts
13718
+ var {readFileSync, writeFileSync} = (() => ({}));
13921
13719
 
13720
+ // node_modules/.bun/pixelmatch@7.2.0/node_modules/pixelmatch/index.js
13721
+ function pixelmatch(img1, img2, output, width, height, options = {}) {
13722
+ const {
13723
+ threshold = 0.1,
13724
+ alpha = 0.1,
13725
+ aaColor = [255, 255, 0],
13726
+ diffColor = [255, 0, 0],
13727
+ checkerboard = true,
13728
+ includeAA,
13729
+ diffColorAlt,
13730
+ diffMask
13731
+ } = options;
13732
+ if (!isPixelData(img1) || !isPixelData(img2) || output && !isPixelData(output))
13733
+ throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");
13734
+ if (img1.length !== img2.length || output && output.length !== img1.length)
13735
+ throw new Error(`Image sizes do not match. Image 1 size: ${img1.length}, image 2 size: ${img2.length}`);
13736
+ if (img1.length !== width * height * 4)
13737
+ throw new Error(`Image data size does not match width/height. Expecting ${width * height * 4}. Got ${img1.length}`);
13738
+ const len = width * height;
13739
+ const a32 = new Uint32Array(img1.buffer, img1.byteOffset, len);
13740
+ const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len);
13741
+ let identical = true;
13742
+ for (let i = 0;i < len; i++) {
13743
+ if (a32[i] !== b32[i]) {
13744
+ identical = false;
13745
+ break;
13746
+ }
13747
+ }
13748
+ if (identical) {
13749
+ if (output && !diffMask) {
13750
+ for (let i = 0, pos = 0;i < len; i++, pos += 4)
13751
+ drawGrayPixel(img1, pos, alpha, output);
13752
+ }
13753
+ return 0;
13754
+ }
13755
+ const maxDelta = 35215 * threshold * threshold;
13756
+ const [aaR, aaG, aaB] = aaColor;
13757
+ const [diffR, diffG, diffB] = diffColor;
13758
+ const [altR, altG, altB] = diffColorAlt || diffColor;
13759
+ let diff = 0;
13760
+ for (let i = 0, pos = 0;i < len; i++, pos += 4) {
13761
+ const delta = a32[i] === b32[i] ? 0 : colorDelta(img1, img2, pos, pos, checkerboard);
13762
+ if (Math.abs(delta) > maxDelta) {
13763
+ const x = i % width;
13764
+ const y = i / width | 0;
13765
+ const isExcludedAA = !includeAA && (antialiased(img1, x, y, width, height, a32, b32, checkerboard) || antialiased(img2, x, y, width, height, b32, a32, checkerboard));
13766
+ if (isExcludedAA) {
13767
+ if (output && !diffMask)
13768
+ drawPixel(output, pos, aaR, aaG, aaB);
13769
+ } else {
13770
+ if (output) {
13771
+ if (delta < 0) {
13772
+ drawPixel(output, pos, altR, altG, altB);
13773
+ } else {
13774
+ drawPixel(output, pos, diffR, diffG, diffB);
13775
+ }
13776
+ }
13777
+ diff++;
13778
+ }
13779
+ } else if (output && !diffMask) {
13780
+ drawGrayPixel(img1, pos, alpha, output);
13781
+ }
13782
+ }
13783
+ return diff;
13784
+ }
13785
+ function isPixelData(arr) {
13786
+ return ArrayBuffer.isView(arr) && arr.BYTES_PER_ELEMENT === 1;
13787
+ }
13788
+ function antialiased(img, x1, y1, width, height, a32, b32, checkerboard) {
13789
+ const x0 = Math.max(x1 - 1, 0);
13790
+ const y0 = Math.max(y1 - 1, 0);
13791
+ const x2 = Math.min(x1 + 1, width - 1);
13792
+ const y2 = Math.min(y1 + 1, height - 1);
13793
+ const pos4 = (y1 * width + x1) * 4;
13794
+ const cr = img[pos4];
13795
+ const cg = img[pos4 + 1];
13796
+ const cb = img[pos4 + 2];
13797
+ const ca = img[pos4 + 3];
13798
+ let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
13799
+ let min = 0;
13800
+ let max = 0;
13801
+ let minX = 0;
13802
+ let minY = 0;
13803
+ let maxX = 0;
13804
+ let maxY = 0;
13805
+ for (let x = x0;x <= x2; x++) {
13806
+ for (let y = y0;y <= y2; y++) {
13807
+ if (x === x1 && y === y1)
13808
+ continue;
13809
+ const delta = brightnessDelta(img, pos4, (y * width + x) * 4, cr, cg, cb, ca, checkerboard);
13810
+ if (delta === 0) {
13811
+ zeroes++;
13812
+ if (zeroes > 2)
13813
+ return false;
13814
+ } else if (delta < min) {
13815
+ min = delta;
13816
+ minX = x;
13817
+ minY = y;
13818
+ } else if (delta > max) {
13819
+ max = delta;
13820
+ maxX = x;
13821
+ maxY = y;
13822
+ }
13823
+ }
13824
+ }
13825
+ if (min === 0 || max === 0)
13826
+ return false;
13827
+ return hasManySiblings(a32, minX, minY, width, height) && hasManySiblings(b32, minX, minY, width, height) || hasManySiblings(a32, maxX, maxY, width, height) && hasManySiblings(b32, maxX, maxY, width, height);
13828
+ }
13829
+ function hasManySiblings(img, x1, y1, width, height) {
13830
+ const x0 = Math.max(x1 - 1, 0);
13831
+ const y0 = Math.max(y1 - 1, 0);
13832
+ const x2 = Math.min(x1 + 1, width - 1);
13833
+ const y2 = Math.min(y1 + 1, height - 1);
13834
+ const val = img[y1 * width + x1];
13835
+ let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
13836
+ for (let x = x0;x <= x2; x++) {
13837
+ for (let y = y0;y <= y2; y++) {
13838
+ if (x === x1 && y === y1)
13839
+ continue;
13840
+ zeroes += +(val === img[y * width + x]);
13841
+ if (zeroes > 2)
13842
+ return true;
13843
+ }
13844
+ }
13845
+ return false;
13846
+ }
13847
+ function colorDelta(img1, img2, k, m, checkerboard) {
13848
+ const r1 = img1[k];
13849
+ const g1 = img1[k + 1];
13850
+ const b1 = img1[k + 2];
13851
+ const a1 = img1[k + 3];
13852
+ const r2 = img2[m];
13853
+ const g2 = img2[m + 1];
13854
+ const b2 = img2[m + 2];
13855
+ const a2 = img2[m + 3];
13856
+ let dr = r1 - r2;
13857
+ let dg = g1 - g2;
13858
+ let db = b1 - b2;
13859
+ const da = a1 - a2;
13860
+ if (a1 < 255 || a2 < 255) {
13861
+ let rb = 255, gb = 255, bb = 255;
13862
+ if (checkerboard) {
13863
+ rb = 48 + 159 * (k % 2);
13864
+ gb = 48 + 159 * ((k / 1.618033988749895 | 0) % 2);
13865
+ bb = 48 + 159 * ((k / 2.618033988749895 | 0) % 2);
13866
+ }
13867
+ dr = (r1 * a1 - r2 * a2 - rb * da) / 255;
13868
+ dg = (g1 * a1 - g2 * a2 - gb * da) / 255;
13869
+ db = (b1 * a1 - b2 * a2 - bb * da) / 255;
13870
+ }
13871
+ const y = dr * 0.29889531 + dg * 0.58662247 + db * 0.11448223;
13872
+ const i = dr * 0.59597799 - dg * 0.2741761 - db * 0.32180189;
13873
+ const q = dr * 0.21147017 - dg * 0.52261711 + db * 0.31114694;
13874
+ const delta = 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q;
13875
+ return y > 0 ? -delta : delta;
13876
+ }
13877
+ function brightnessDelta(img, k, m, r1, g1, b1, a1, checkerboard) {
13878
+ const r2 = img[m];
13879
+ const g2 = img[m + 1];
13880
+ const b2 = img[m + 2];
13881
+ const a2 = img[m + 3];
13882
+ let dr = r1 - r2;
13883
+ let dg = g1 - g2;
13884
+ let db = b1 - b2;
13885
+ const da = a1 - a2;
13886
+ if (!dr && !dg && !db && !da)
13887
+ return 0;
13888
+ if (a1 < 255 || a2 < 255) {
13889
+ let rb = 255, gb = 255, bb = 255;
13890
+ if (checkerboard) {
13891
+ rb = 48 + 159 * (k % 2);
13892
+ gb = 48 + 159 * ((k / 1.618033988749895 | 0) % 2);
13893
+ bb = 48 + 159 * ((k / 2.618033988749895 | 0) % 2);
13894
+ }
13895
+ dr = (r1 * a1 - r2 * a2 - rb * da) / 255;
13896
+ dg = (g1 * a1 - g2 * a2 - gb * da) / 255;
13897
+ db = (b1 * a1 - b2 * a2 - bb * da) / 255;
13898
+ }
13899
+ return dr * 0.29889531 + dg * 0.58662247 + db * 0.11448223;
13900
+ }
13901
+ function drawPixel(output, pos, r, g, b) {
13902
+ output[pos] = r;
13903
+ output[pos + 1] = g;
13904
+ output[pos + 2] = b;
13905
+ output[pos + 3] = 255;
13906
+ }
13907
+ function drawGrayPixel(img, i, alpha, output) {
13908
+ const val = 255 + (img[i] * 0.29889531 + img[i + 1] * 0.58662247 + img[i + 2] * 0.11448223 - 255) * alpha * img[i + 3] / 255;
13909
+ drawPixel(output, i, val, val, val);
13910
+ }
13911
+
13912
+ // tools/test/src/visual/compare.ts
13913
+ var import_pngjs = __toESM(require_png(), 1);
13914
+ function compareImages(baselinePath, actualPath, diffPath, options = {}) {
13915
+ const threshold = options.threshold ?? 0.1;
13916
+ const mismatchRatio = options.mismatchRatio ?? 0.001;
13917
+ const includeAA = options.includeAA ?? false;
13918
+ const baseline = import_pngjs.PNG.sync.read(readFileSync(baselinePath));
13919
+ const actual = import_pngjs.PNG.sync.read(readFileSync(actualPath));
13920
+ if (baseline.width !== actual.width || baseline.height !== actual.height) {
13921
+ throw new Error(`Image dimensions differ: baseline ${baseline.width}x${baseline.height}, actual ${actual.width}x${actual.height}`);
13922
+ }
13923
+ const { width, height } = baseline;
13924
+ const diff = new import_pngjs.PNG({ width, height });
13925
+ const diffPixels = pixelmatch(baseline.data, actual.data, diff.data, width, height, {
13926
+ threshold,
13927
+ includeAA
13928
+ });
13929
+ const totalPixels = width * height;
13930
+ const ratio = diffPixels / totalPixels;
13931
+ const match2 = ratio <= mismatchRatio;
13932
+ let diffPngPath;
13933
+ if (!match2) {
13934
+ writeFileSync(diffPath, import_pngjs.PNG.sync.write(diff));
13935
+ diffPngPath = diffPath;
13936
+ }
13937
+ return { match: match2, diffPixels, totalPixels, ratio, diffPngPath };
13938
+ }
13922
13939
  // tools/test/src/visual/harness.ts
13940
+ init_path();
13941
+ var {existsSync, mkdirSync, writeFileSync: writeFileSync2} = (() => ({}));
13923
13942
  var UPDATE_ENV = "POLLY_VISUAL_UPDATE";
13924
13943
  var CI_ENV = "CI";
13925
13944
  function isUpdateMode() {
@@ -14017,4 +14036,4 @@ export {
14017
14036
  assertSafeUpdateMode
14018
14037
  };
14019
14038
 
14020
- //# debugId=51DC7226BD2C4BE464756E2164756E21
14039
+ //# debugId=FE6BF93D8946345F64756E2164756E21