rapier-jxl 2.0.0 → 2.2.0

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 (55) hide show
  1. package/AGENTS.md +10 -1
  2. package/ENCODER-COMPARISON.md +6 -6
  3. package/KERNELS.md +58 -0
  4. package/README.md +75 -18
  5. package/admit.mjs +5 -1
  6. package/ans.mjs +157 -0
  7. package/bits.mjs +5 -2
  8. package/build-jxl-kernels.mjs +29 -0
  9. package/coefficient-ans.mjs +26 -0
  10. package/coefficient-effort.mjs +62 -0
  11. package/effort-job.mjs +229 -0
  12. package/effort-level.mjs +10 -0
  13. package/effort.d.mts +4 -2
  14. package/effort.min.mjs +2 -2
  15. package/effort.mjs +7 -199
  16. package/frame.mjs +29 -1
  17. package/index.mjs +2 -2
  18. package/jfif.mjs +11 -0
  19. package/jpeg-ans.d.mts +3 -0
  20. package/jpeg-ans.min.mjs +2 -0
  21. package/jpeg-ans.mjs +9 -0
  22. package/jpeg-job.mjs +29 -0
  23. package/jpeg.d.mts +6 -2
  24. package/jpeg.min.mjs +2 -2
  25. package/jpeg.mjs +12 -36
  26. package/kernel-control.d.mts +3 -0
  27. package/kernel-hooks.mjs +3 -0
  28. package/kernels-bytes.mjs +4 -0
  29. package/kernels-probe.wat +1 -0
  30. package/kernels-scalar.wat +831 -0
  31. package/kernels-simd.wat +252 -0
  32. package/kernels.mjs +141 -0
  33. package/local.mjs +201 -0
  34. package/lossless-coding.mjs +30 -0
  35. package/lossless.mjs +88 -67
  36. package/modular.mjs +11 -7
  37. package/package.json +40 -6
  38. package/photo-ans.d.mts +3 -0
  39. package/photo-ans.min.mjs +2 -0
  40. package/photo-ans.mjs +9 -0
  41. package/photo-dct.mjs +83 -0
  42. package/photo-job.mjs +27 -0
  43. package/photo-quant.mjs +150 -0
  44. package/photo.d.mts +5 -1
  45. package/photo.min.mjs +2 -2
  46. package/photo.mjs +7 -101
  47. package/pool.mjs +136 -0
  48. package/rapier-jxl.min.mjs +2 -2
  49. package/rct-search.mjs +61 -0
  50. package/sizes.json +237 -56
  51. package/vardct.mjs +45 -8
  52. package/wasm.d.mts +4 -0
  53. package/wasm.min.mjs +2 -0
  54. package/wasm.mjs +6 -0
  55. package/weighted.mjs +22 -10
@@ -1,2 +1,2 @@
1
- /*! Rapier JXL 2.0.0 | MIT License Copyright (c) 2026 rapier.website Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2
- function*t(t,n,o){let e,r;for(;!(e=t.next(r)).done;)r=yield(n+e.value)/o;return e.value}function n(t){return t>=0?2*t:2*-t-1}function o(t){return 31-Math.clz32(t)}function e(t){return t<=1?0:32-Math.clz32(t-1)}function r(t,n){t.t([[9,1],[13,1],[18,1],[30,1]],n)}function i(t,n,o,e,i,{xyb:s=!1,orientation:c=1,colorSpace:f}={}){t.write(16,2815),t.write(1,0),r(t,o),t.write(3,0),r(t,n),t.write(1,0);const l=1!==c;t.write(1,l?1:0),l&&t.write(6,c-1),t.write(4,8),i?t.write(3,5):t.write(2,0),t.write(1,s?1:0),3===e&&"display-p3"===f?t.write(21,903568):3===e?t.write(1,1):t.write(15,14100),l&&t.write(1,1),t.write(2,0),t.write(1,1),t.o()}function s(t,{alpha:n,shift:o=1}){t.write(9,8),n&&t.write(2,0),t.write(2,o),function(t,n){t.write(n?7:5,0),t.write(11,1)}(t,n)}function c(t,n,o=256){const e=Math.ceil(t/o),r=Math.ceil(n/o);return{i:e,u:r,p:Math.ceil(t/(8*o)),m:Math.ceil(n/(8*o)),M:1===e&&1===r}}function f(t,n){const o=n.map(t=>t.length);!function(t,n){t.write(1,0),t.o();for(const o of n)t.t([[10,0],[14,1024],[22,17408],[30,4211712]],o);t.o()}(t,o);const e=t.finish(),r=new Uint8Array(e.length+o.reduce((t,n)=>t+n,0));r.set(e);let i=e.length;for(const t of n)r.set(t,i),i+=t.length;return r}function l(t,n){const o=new Uint8Array(t.length),e=[];for(let n=0;n<t.length;n++)t[n]>0&&e.push(n);if(!e.length)return o;if(1===e.length)return o[e[0]]=1,o;for(let r=1;;r*=2){const i=e.map(n=>({w:Math.max(t[n],r),A:n,l:null,r:null})).sort((t,n)=>t.w-n.w||t.A-n.A),s=[];let c=0,f=0;const l=()=>c<i.length&&(f>=s.length||i[c].w<=s[f].w)?i[c++]:s[f++];for(;i.length-c+(s.length-f)>1;){const t=l(),n=l();s.push({w:t.w+n.w,A:-1,l:t,r:n})}const a=[[l(),0]];let u=0;for(;a.length;){const[t,n]=a.pop();t.A>=0?(o[t.A]=n,n>u&&(u=n)):a.push([t.l,n+1],[t.r,n+1])}if(u<=n)return o}}function a(t,n,o,e,r,i){const s=[];for(;s.push(e&r),e>>=i;)e--;for(let e=s.length-1;e>=0;e--)t.push(o),n.push(s[e])}function u(t,n){let o=0;for(let e=0;e<n;e++)o=o<<1|1&t,t>>=1;return o}function h(t){const n=new Uint32Array(17),o=new Uint32Array(17),e=new Uint16Array(t.length);for(const o of t)n[o]++;n[0]=0;for(let t=1,e=0;t<=16;t++)e=e+n[t-1]<<1,o[t]=e;for(let n=0;n<t.length;n++)t[n]&&(e[n]=u(o[t[n]]++,t[n]));return e}function p(t){const n=[];for(let o=0;o<t.length;o++)t[o]>0&&n.push(o);const o=n.length,e=n[o-1]+1||1,r=o<=4?new Uint8Array(e):l(t,15).subarray(0,e);let i=0;if(o<=4){n.sort((n,o)=>t[o]-t[n]||n-o),i=4===o&&t[n[0]]>t[n[2]]+t[n[3]]?1:0;const e=o<2?[0]:2===o?[1,1]:3===o?[1,2,2]:i?[1,2,3,3]:[2,2,2,2];n.forEach((t,n)=>{r[t]=e[n]}),n.sort((t,n)=>r[t]-r[n]||t-n)}return{U:e,S:r,I:h(r),C:o&&o<=4?n:null,T:i}}function y(t,n){if(n.U<=1)return;if(n.C){const e=o(n.U-1)+1;t.write(2,1),t.write(2,n.C.length-1);for(const o of n.C)t.write(e,o);return void(4===n.C.length&&t.write(1,n.T))}const e=n.S,r=[],i=[];let s=e.length-1;for(;s>0&&!e[s];)s--;let c=8;for(let t=0;t<=s;){const n=e[t];let o=1;for(;t+o<=s&&e[t+o]===n;)o++;let f=o;if(n&&n!==c&&(r.push(n),i.push(0),f--,c=n),f<3)for(let t=0;t<f;t++)r.push(n),i.push(0);else a(r,i,n?16:17,f-3,n?3:7,n?2:3);t+=o}const f=new Uint32Array(18);for(const t of r)f[t]++;let u=0;for(const t of f)t&&u++;1===u&&(f[r[0]?0:1]=f[r[0]]);const p=l(f,5),y=h(p);let w=18;for(;w>0&&!p[k[w-1]];)w--;t.write(2,0);for(let n=0;n<w;n++){const o=p[k[n]];t.write(Y[o],Z[o])}for(let n=0;n<r.length;n++){const o=r[n];t.write(p[o],y[o]),16===o?t.write(2,i[n]):17===o&&t.write(3,i[n])}}function w(t,n=0,o=0){return{split:t,L:n,N:o,P:1<<t}}function d(t,n,o=15){t.write(e(o+1),n.split),n.split!==o&&(t.write(e(n.split+1),n.L),t.write(e(n.split-n.L+1),n.N))}function g(t,n,e){if(n<t.P)return e[0]=n,e[1]=0,void(e[2]=0);const r=o(n),i=n-(1<<r),s=r-t.L-t.N;e[0]=t.P+(r-t.split<<t.L+t.N|i>>r-t.L<<t.N|i&(1<<t.N)-1),e[1]=s,e[2]=n>>t.N&(1<<s)-1}function m(t,n,o,e=0){g(t,n,D),o[e+D[0]]++}function M(t,n,o,e,r=0){g(o,e,D);const i=r+D[0];t.write(n.S[i],n.I[i]),D[1]&&t.write(D[1],D[2])}function b(t,{X:n=null,v:r,J:i}){t.write(1,n?1:0),n&&(t.t([[0,224],[0,512],[0,4096],[15,8]],n._),t.t([[0,3],[0,4],[2,5],[8,9]],n.minLength),d(t,n.q,8)),r.length>1&&function(t,n){let o=0;for(const t of n)o=Math.max(o,t);const r=o?e(o+1):0;if(r<=3){if(t.write(1,1),t.write(2,r),r)for(const o of n)t.write(r,o);return}t.write(1,0),t.write(1,0);const i=w(8),s=w(4),c=n.length>=64,f=new Uint32Array(c?257:o+1),l=[];for(let t=0;t<n.length;){let o=1;for(;c&&t+o<n.length&&n[t+o]===n[t];)o++;if(o>=8)l.push([n[t],o-1]),f[n[t]]++,m(s,o-1-7,f,224),t+=o;else{for(let e=0;e<o;e++)l.push([n[t],0]),f[n[t]]++;t+=o}}const a=p(f);if(!c){b(t,{v:new Uint8Array(1),J:[{config:i,code:a}]});for(const[n]of l)M(t,a,i,n);return}const u=new Uint32Array(1);u[0]=1,b(t,{X:{_:224,minLength:7,q:s},v:new Uint8Array([1,0]),J:[{config:w(0),code:p(u)},{config:i,code:a}]});for(const[n,o]of l)M(t,a,i,n),o&&M(t,a,s,o-7,224)}(t,r),t.write(1,1);for(const n of i)d(t,n.config,15);for(const n of i){const e=n.code.U-1;if(e){const n=o(e);t.write(1,1),t.write(4,n),t.write(n,e-(1<<n))}else t.write(1,0)}for(const n of i)y(t,n.code)}function A(t,n=0,o=1){return{G:t,offset:n,O:o,context:-1}}function U(t,n){const o=(e,r)=>{if(e===r)return n?t[e].j:t[e];const i=e+r>>1;return function(t,n,o,e){return{B:t,R:n,left:o,right:e}}(n,n?t[i].k:i,o(i+1,r),o(e,i))};return o(0,t.length-1)}function S(t){return U(t,0)}function x(t,o){const e=[o],r=[],i=[];for(const t of e){if(t.left){r.push(t.B+1,n(t.R)),e.push(t.left,t.right);continue}t.context=i.length,i.push(t);const o=1===t.O?0:31-Math.clz32(t.O&-t.O);r.push(0,t.G,n(t.offset),o,(t.O>>o)-1)}const s=new Uint32Array(64);for(const t of r)m(V,t,s);const c=p(s);b(t,{v:new Uint8Array(6),J:[{config:V,code:c}]});for(const n of r)M(t,c,V,n);return i}function I(t,n){const o=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===n.type)t.write(2,0),t.t(o,n.Y),t.t([[0,6],[2,0],[4,2],[6,10]],n.Z??6);else if("palette"===n.type)t.write(2,1),t.t(o,n.Y),t.t([[0,1],[0,3],[0,4],[13,1]],n.D),t.t([[8,0],[10,256],[12,1280],[16,5376]],n.F),t.t([[0,0],[8,1],[10,257],[16,1281]],n.H??0),t.write(4,n.G??0);else{if("squeeze"!==n.type)throw new Error("unknown transform "+n.type);{t.write(2,2);const e=n.K??[];t.t([[0,0],[4,1],[6,9],[8,41]],e.length);for(const n of e)t.write(1,n.V?1:0),t.write(1,n.W?1:0),t.t(o,n.Y),t.t([[0,1],[0,2],[0,3],[4,4]],n.D)}}}function C(t,{$:n=!0,tt:o=[]}={}){t.write(1,n?1:0),t.write(1,1),t.t([[0,0],[0,1],[4,2],[8,18]],o.length);for(const n of o)I(t,n)}function T(t,n,o,e=t=>t.context){const r=new Uint8Array(n.length+1);for(const t of n)r[t.context]=e(t)+1;const i=new Uint32Array(2);i[1]=1;const s=[{config:V,code:p(i)}],c=Math.max(...r);for(let t=0;t<c;t++)s.push({config:V,code:p(o[t])});return b(t,{X:K,v:r,J:s}),s}function E(t,o,e,r,i,s){const c=s.G,f=s.offset,l=s.O,a=V,u=H;let h=0;const p=(n,e=a,r=0)=>{t?M(t,o,e,n,r):m(e,n,o,r)},y=()=>{if(h){if(h>=8)p(0),p(h-7-1,u,224);else for(let t=0;t<h;t++)p(0);h=0}},w=(t,o)=>{const r=e[t];let i;1===l?i=r-o-f:(i=Math.round((r-o-f)/l),e[t]=o+f+i*l),0!==i?(y(),p(n(i))):h++};for(let t=0,n=0;t<i;t++)for(let o=0;o<r;o++,n++){let i;if(0===c)i=0;else{const s=o?e[n-1]:t?e[n-r]:0,f=t?e[n-r]:s;if(1===c)i=s;else if(2===c)i=f;else if(3===c)i=(s+f)/2|0;else{const l=s+f-(o&&t?e[n-r-1]:s);if(5===c){const t=s<f?s:f,n=s<f?f:s;i=l<t?t:l>n?n:l}else{if(4!==c)throw new Error("predictor "+c+" is not coded here");i=Math.abs(l-s)<Math.abs(l-f)?s:f}}}w(n,i)}y()}function L(t,n,o,{palette:e=!0}={}){const r=n*o;let i=!0,s=!0;for(let n=0,o=0;o<r&&(255===t[n+3]||(i=!1,s))&&(t[n]===t[n+1]&&t[n]===t[n+2]||(s=!1,i));o++,n+=4);const c=s?1:3,f=!i,l=c+(f?1:0),a=n=>s?f?t[n]+256*t[n+3]:t[n]:t[n]+256*t[n+1]+65536*t[n+2]+(f?16777216*t[n+3]:0),u=new Map;let h=null;for(let t=0,n=0;e&&n<r;n++,t+=4){const n=a(t);if(0!==n&&!u.has(n)&&(u.set(n,1),u.size>=2048))break}if(e&&u.size<2048){const t=[...u.keys()],n=(t,n)=>t>>>8*n&255,o=t=>(.299*n(t,0)+.587*n(t,1)+.114*n(t,2)+.01)*(4===l?n(t,3):1);t.sort((t,n)=>o(t)-o(n));const e=new Map([[0,0]]);t.forEach((t,n)=>e.set(t,n+1)),h={colours:[0,...t],index:e,key:a,byte:n}}return{colour:c,alpha:f,channels:l,palette:h}}function*N(n,o,e,{shape:r=L(n,o,e),colorSpace:i}={}){let s,c;const f=r.palette?[r,{...r,palette:null}]:[r];for(let r=0;r<f.length;r++)try{const c=yield*t(P(n,o,e,f[r],i),r,f.length);(!s||c.length<s.length)&&(s=c)}catch(t){if("JXL_SIZE"!==t.code)throw t;c=t}if(!s)throw c;return s}function*P(t,n,o,e,r){const{channels:l,palette:a}=e,u=c(n,o),h=a?2:l,w=Array.from({length:h},()=>A(F)),d=S(w),g=Array.from({length:h},()=>new Int16Array(65536)),m=(o,e,r,i)=>{for(let s=0;s<i;s++){let i=4*((e+s)*n+o),c=s*r;for(let n=0;n<r;n++,i+=4,c++)if(a)g[0][c]=a.index.get(a.key(i));else if(l>=3){const n=t[i],o=t[i+1],e=t[i+2],r=n-e,s=e+(r>>1),f=o-s;g[0][c]=s+(f>>1),g[1][c]=r,g[2][c]=f,4===l&&(g[3][c]=t[i+3])}else g[0][c]=t[i],2===l&&(g[1][c]=t[i+3])}};let M=null;if(a){const t=a.colours.length;M=new Int16Array(t*l),a.colours.forEach((n,o)=>{for(let e=0;e<l;e++)M[e*t+o]=a.byte(n,e)})}const b=t=>w[a?u.M?1:0:t],U=a?1:l,I=u.i*u.u,L=2*I,N=(t,e)=>{const r=t%u.i*R,i=(t/u.i|0)*R,s=Math.min(R,n-r),c=Math.min(R,o-i);m(r,i,s,c),e(s,c)};let P=0;if(!a){const t=t=>{const n=p(t),o=new B(128);y(o,n);let e=o.nt;for(let o=0;o<t.length;o++)t[o]&&(e+=t[o]*(n.S[o]+Math.max(0,o<224?o-1:o-236)));return e},e=Math.min(n,32),r=Math.min(o,32),i=[F,Q].map(t=>({G:t,ot:w.map(()=>new Uint32Array(257))}));for(const t of[0,.5,1]){m(Math.floor((n-e)*t),Math.floor((o-r)*t),e,r);for(const t of i)for(let n=0;n<l;n++)E(null,t.ot[n],g[n],e,r,A(t.G))}w.forEach((n,o)=>{const e=i.map(n=>t(n.ot[o])),r=e[1]<e[0]?1:0;n.G=i[r].G})}const X=a?[{type:"palette",Y:0,D:l,F:a.colours.length}]:l>=3?[{type:"rct",Y:0,Z:6}]:[],v=w.map(()=>new Uint32Array(257)),z=t=>v[w.indexOf(t)];M&&E(null,z(w[0]),M,a.colours.length,l,w[0]);for(let t=0;t<I;t++)N(t,(t,n)=>{for(let o=0;o<U;o++)E(null,z(b(o)),g[o],t,n,b(o))}),yield++P/L;const J=new B(256);i(J,n,o,e.colour,e.alpha,{colorSpace:r}),s(J,{alpha:e.alpha});const _=new B(4096);_.write(1,1),_.write(1,1);const q=x(_,d),G=T(_,q,v,t=>w.indexOf(t)),O=t=>G[w.indexOf(t)+1].code;C(_,{$:!0,tt:X}),M&&E(_,O(w[0]),M,a.colours.length,l,w[0]);const j=[];if(u.M)N(0,(t,n)=>{for(let o=0;o<U;o++)E(_,O(b(o)),g[o],t,n,b(o))}),yield 1,j.push(_.finish());else{j.push(_.finish());for(let t=0;t<u.p*u.m+1;t++)j.push(new Uint8Array(0));for(let t=0;t<I;t++)N(t,(t,n)=>{const o=new B(t*n*U+64);C(o,{$:!0,tt:[]});for(let e=0;e<U;e++)E(o,O(b(e)),g[e],t,n,b(e));j.push(o.finish())}),yield++P/L}return f(J,j)}function X(t,n,o){const e=t>=n&&n>=o?1:t<=n&&n<=o?-1:0;if(!e)return 0;let r=(4*(t*=e)-3*(o*=e)-(n*=e)+6)/12|0;return r-(1&r)>2*(t-n)&&(r=2*(t-n)+1),r+(1&r)>2*(n-o)&&(r=2*(n-o)),e*r}function v(t,n){const{w:o,h:e,data:r}=t,i=n?o:e,s=i+1>>1,c=i-s,f=n?s:o,l=n?e:s,a=n?c:o,u=n?e:c,h=new Int16Array(f*l),p=new Int16Array(a*u),y=n?1:o;for(let t=0;t<l;t++)for(let e=0;e<f;e++){const s=n?e:t,l=n?t*o+2*e:2*t*o+e;if(s===c){h[t*f+e]=r[l];continue}const u=r[l],w=r[l+y],d=W(u,w),g=s+1<c?W(r[l+2*y],r[l+3*y]):1&i?r[l+2*y]:d;h[t*f+e]=d,p[t*a+e]=u-w-X(s?r[l-y]:d,d,g)}const w=(o,e,r)=>({w:e,h:r,et:t.et+ +n,rt:t.rt+!n,data:o});return[w(h,f,l),w(p,a,u)]}function z(t){const n=[],o=t.length;let e=t[0].w,r=t[0].h;for(o>2&&t[1].w===e&&t[1].h===r&&(n.push({V:!0,W:!1,Y:1,D:2}),n.push({V:!1,W:!1,Y:1,D:2})),!(e>r)&&r>8&&(n.push({V:!1,W:!0,Y:0,D:o}),r=r+1>>1);e>8||r>8;)e>8&&(n.push({V:!0,W:!0,Y:0,D:o}),e=e+1>>1),r>8&&(n.push({V:!1,W:!0,Y:0,D:o}),r=r+1>>1);return n}function*J(t,n,o,{quality:e=90,shape:r=L(t,n,o,{palette:!1}),colorSpace:l}={}){const a=function(t){return t>=100?0:t>=30?.1+.09*(100-t):53/3e3*t*t-1.15*t+25}(e);if(!(a>0))throw new Error("lossy encoding needs a quality below 100");const{colour:u,alpha:h,channels:p}=r,y=n*o,w=Array.from({length:p},()=>new Int16Array(y));for(let n=0,o=0;o<y;o++,n+=4){if(3===u){const e=t[n],r=t[n+1],i=t[n+2],s=e-i,c=i+(s>>1),f=r-c;w[0][o]=c+(f>>1),w[1][o]=s,w[2][o]=f}else w[0][o]=t[n];h&&(w[p-1][o]=t[n+3])}const d=w.map((t,e)=>({w:n,h:o,et:0,rt:0,data:t,component:3===u?e:0===e?0:3})),g=1===n&&o>$&&3===u,m=g?z(d).filter(t=>!t.V):1!==n&&1!==o||3!==u?[]:z(d),M=function(t,n=z(t)){const o=t.map(t=>({...t,level:0,it:!1}));for(const t of n){const n=t.Y+t.D-1,e=t.W?n+1:o.length;for(let r=t.Y;r<=n;r++){const[n,i]=v(o[r],t.V),s=o[r].level+1;o[r]={...n,level:s,it:o[r].it,component:o[r].component},o.splice(e+(r-t.Y),0,{...i,level:s,it:!0,component:o[r].component})}}return o}(d,m.length?m:void 0),b=t=>t.it?0:F,I=t=>function(t,n,o,e){let r=Math.min(16,n+o);if(r>0&&r--,3===t)return 1;const i=.25*function(t){let n=1;for(let o=0;o<24;o++)n=(4*n+t/(n*n*n*n))/5;return t*n}(e),s=1<<r,c=1===t||2===t?.35*i*Math.max(.5,1024/s):.35*i*1.1*(163.84/s);return Math.max(1,Math.floor(c))}(t.component,t.et+(g&&t.component>0&&t.component<3?1:0),t.rt,a),N=[...3===u?[{type:"rct",Y:0,Z:6}]:[],{type:"squeeze",K:m}],P=c(n,o,$),X=P.p*P.m,J=P.i*P.u;let _=0;for(;_<M.length&&M[_].w<=$&&M[_].h<=$;)_++;const q=(t,n,o,e)=>{const r=n>>t.et,i=o>>t.rt;return{x:r,y:i,w:Math.min(t.w,r+(e>>t.et))-r,h:Math.min(t.h,i+(e>>t.rt))-i}},G=[{index:0,k:0,st:[]}];for(let t=0;t<_;t++)G[0].st.push({c:t,rect:{x:0,y:0,w:M[t].w,h:M[t].h}});if(!P.M){for(let t=0;t<X;t++){const n=t%P.p,o=t/P.p|0,e={index:1+t,k:1+X+t,st:[]};for(let t=_;t<M.length;t++){const r=M[t];if(Math.min(r.et,r.rt)<3)continue;const i=q(r,n*tt,o*tt,tt);i.w>0&&i.h>0&&e.st.push({c:t,rect:i})}G.push(e)}for(let t=0;t<J;t++){const n=t%P.i,o=t/P.i|0,e={index:2+X+t,k:1+3*X+17+t,st:[]};for(let t=_;t<M.length;t++){const r=M[t];if(Math.min(r.et,r.rt)>2)continue;const i=q(r,n*$,o*$,$);i.w>0&&i.h>0&&e.st.push({c:t,rect:i})}G.push(e)}}for(const t of G)for(const n of t.st){const t=M[n.c];n.ct=A(b(t),0,I(t)),n.ct.channel=n.c}const O=G.filter(t=>t.st.length),j=1===O.length?S(O[0].st.map(t=>t.ct)):function(t){return U(t,1)}(O.map(t=>({k:t.k,j:S(t.st.map(t=>t.ct))}))),R=new Int16Array(1048576),k=t=>{const n=M[t.c],o=t.rect;if(o.w===n.w&&o.h===n.h)return n.data;for(let t=0;t<o.h;t++)R.set(n.data.subarray((o.y+t)*n.w+o.x,(o.y+t)*n.w+o.x+o.w),t*o.w);return R},Y=[...new Set(G.flatMap(t=>t.st.map(t=>t.c)))].sort((t,n)=>t-n),Z=new Map(Y.map((t,n)=>[t,n])),D=Y.map(()=>new Uint32Array(257)),Q=1+2*G.length;let H=1;yield H/Q;for(const t of G){for(const n of t.st)E(null,D[Z.get(n.c)],k(n),n.rect.w,n.rect.h,n.ct);yield++H/Q}const K=new B(256);i(K,n,o,u,h,{colorSpace:l}),s(K,{alpha:h,shift:n>256||o>256?3:1});const V=Array.from({length:P.M?1:2+X+J},()=>null),W=V[0]=new B(65536);W.write(1,1),W.write(1,1);const nt=T(W,x(W,j),D,t=>Z.get(t.channel));C(W,{$:!0,tt:N});for(const t of G){let n=V[t.index];n||(n=V[t.index]=new B(4096),t.st.length&&C(n,{$:!0,tt:[]}));for(const o of t.st)E(n,nt[Z.get(o.c)+1].code,k(o),o.rect.w,o.rect.h,o.ct);yield++H/Q}return f(K,function(t){return t.map(t=>t?t.finish():new Uint8Array(0))}(V))}function _(t){try{return t()}catch(t){if(t instanceof RangeError&&!t.code)throw nt("JXL_MEMORY","Not enough memory for this picture.");throw t}}function q(t,n,o,e){return function(t){let n;for(;!(n=t.next()).done;);return n.value}(G(t,n,o,e))}function G(n,o,e,r){const{quality:i,colorSpace:s}=function(t={},n=100){if(null===t||"object"!=typeof t)throw nt("JXL_INPUT","Options are an object: {quality, colorSpace}.");if(void 0!==t.quality&&(n=t.quality),"number"!=typeof n||!Number.isFinite(n)||n<1||n>100)throw nt("JXL_INPUT","Quality is a number from 1 to 100.");const o=void 0===t.colorSpace?"srgb":t.colorSpace;if("srgb"!==o&&"display-p3"!==o)throw nt("JXL_INPUT","The colour space is srgb or display-p3.");return{quality:n,colorSpace:o}}(r);return function(t,n,o,e){if(function(t,n,o=O){if(!Number.isInteger(t)||!Number.isInteger(n)||t<1||n<1)throw nt("JXL_INPUT","A picture is at least one pixel wide and high, in whole pixels.");if(t>o.edge||n>o.edge)throw nt("JXL_DIMENSIONS","A picture is at most "+o.edge+" pixels on a side.");if(t*n>o.pixels)throw nt("JXL_DIMENSIONS","A picture is at most "+o.pixels.toLocaleString("en-US")+" pixels.")}(n,o,e),!(t instanceof Uint8Array||t instanceof Uint8ClampedArray))throw nt("JXL_INPUT","Pixels are a Uint8Array or Uint8ClampedArray of RGBA bytes.");if(t.length!==n*o*4)throw nt("JXL_INPUT","Pixels are width * height * 4 bytes: straight (not premultiplied) RGBA, row by row.")}(n,o,e),function(t){const n=function*(){let o,e;for(;!(o=_(()=>t.next(n.hurry))).done;)yield e=o.value;return e<1&&(yield 1),n.bytes=function(t){if(t.length>O.bytes)throw nt("JXL_SIZE","The encoded picture exceeds 16 MiB.");return t}(o.value)}();return n.bytes=null,n.hurry=!1,n}(function*(n,o,e,r,i){const s=L(n,o,e);if(r>=100)return yield*N(n,o,e,{shape:s,colorSpace:i});if(!s.palette)return yield*J(n,o,e,{quality:r,shape:s,colorSpace:i});const c=yield*t(N(n,o,e,{shape:s,colorSpace:i}),0,2);let f;try{f=yield*t(J(n,o,e,{quality:r,shape:s,colorSpace:i}),1,2)}catch(t){if(!(t instanceof RangeError)||t.code)throw t;f=c}return c.length<=f.length?c:f}(n,o,e,i,s))}const O=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),j=[1];for(let t=1;t<=32;t++)j.push(2*j[t-1]);class B{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.ft=0,this.pending=0}write(t,n){if(!(n>=0&&n<j[t]))throw new Error("bit write out of range: "+t+" bits, "+n);let o=this.ft+n*(1<<this.pending),e=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const r=this.bytes;for(;e>=8;)r[this.at++]=255&o,o=Math.floor(o/256),e-=8;this.ft=o,this.pending=e}t(t,n){for(let o=0;o<4;o++){const[e,r]=t[o];if(n>=r&&n-r<j[e])return this.write(2,o),void(e&&this.write(e,n-r))}throw new Error("U32 value out of range: "+n)}o(){this.pending&&(this.at+1>=this.bytes.length&&this.grow(),this.bytes[this.at++]=this.ft,this.ft=0,this.pending=0)}get nt(){return 8*this.at+this.pending}grow(t=0){const n=O.bytes+64;if(this.at+t+16>n)throw Object.assign(new Error("The encoded picture exceeds 16 MiB."),{code:"JXL_SIZE"});const o=new Uint8Array(Math.min(n,Math.max(2*this.bytes.length,this.at+t+16)));o.set(this.bytes.subarray(0,this.at)),this.bytes=o}append(t){if(this.at+t.at+8>=this.bytes.length&&this.grow(t.at+8),this.pending)for(let n=0;n<t.at;n++)this.write(8,t.bytes[n]);else this.bytes.set(t.bytes.subarray(0,t.at),this.at),this.at+=t.at;t.pending&&this.write(t.pending,t.ft)}finish(){const t=this.at+(this.pending?1:0),n=this.bytes.slice(0,t);return this.pending&&(n[this.at]=this.ft),n}}const R=256,k=[1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15],Y=[2,4,3,2,2,4],Z=[0,7,3,2,1,15],D=[0,0,0],Q=3,F=5,H=w(4),K=Object.freeze({_:224,minLength:7,q:H}),V=w(0),W=(t,n)=>t+n+(t>n?1:0)>>1,$=1024,tt=8192,nt=(t,n)=>Object.assign(new Error(n),{code:t});export{O as LIMITS,q as encode,G as encodeSteps};
1
+ /*! Rapier JXL 2.2.0 | MIT License Copyright (c) 2026 rapier.website Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2
+ const t={channel:null,weighted:null,fill:null},n=Object.freeze({bytes:16777216,pixels:24e6,edge:16384}),o=[1];for(let t=1;t<=32;t++)o.push(2*o[t-1]);class e{constructor(t=4096){this.bytes=new Uint8Array(t),this.at=0,this.t=0,this.pending=0}write(t,n){if(!(n>=0&&n<o[t]))throw new Error("bit write out of range: "+t+" bits, "+n);let e=this.t+n*(1<<this.pending),r=this.pending+t;this.at+5>=this.bytes.length&&this.grow();const i=this.bytes;for(;r>=8;)i[this.at++]=255&e,e=Math.floor(e/256),r-=8;this.t=e,this.pending=r}o(t,n){for(let e=0;e<4;e++){const[r,i]=t[e];if(n>=i&&n-i<o[r])return this.write(2,e),void(r&&this.write(r,n-i))}throw new Error("U32 value out of range: "+n)}i(){this.pending&&(this.at+1>=this.bytes.length&&this.grow(),this.bytes[this.at++]=this.t,this.t=0,this.pending=0)}get u(){return 8*this.at+this.pending}grow(t=0){const o=n.bytes+64;if(this.at+t+16>o)throw Object.assign(new Error("The encoded picture exceeds 16 MiB."),{code:"JXL_SIZE"});const e=new Uint8Array(Math.min(o,Math.max(2*this.bytes.length,this.at+t+16)));e.set(this.bytes.subarray(0,this.at)),this.bytes=e}append(t){if(this.at+t.at+8>=this.bytes.length&&this.grow(t.at+8),this.pending)for(let n=0;n<t.at;n++)this.write(8,t.bytes[n]);else this.bytes.set(t.bytes.subarray(0,t.at),this.at),this.at+=t.at;t.pending&&this.write(t.pending,t.t)}finish(){const t=this.at+(this.pending?1:0),n=this.bytes.slice(0,t);return this.pending&&(n[this.at]=this.t),n}}function*r(t,n,o){let e,r;for(;!(e=t.next(r)).done;)r=yield i(e.value,t=>(n+t)/o);return e.value}const i=(t,n)=>"number"==typeof t?n(t):{...t,at:o=>n(t.at(o))};function s(t){return t>=0?2*t:2*-t-1}function c(t){return 31-Math.clz32(t)}function f(t){return t<=1?0:32-Math.clz32(t-1)}const l=(t,n)=>Object.assign(new Error(n),{code:t});function a(t){if(t>n.bytes)throw l("JXL_SIZE","The encoded picture exceeds 16 MiB.")}function u(t){try{return t()}catch(t){if(t instanceof RangeError&&!t.code)throw l("JXL_MEMORY","Not enough memory for this picture.");throw t}}const h=256;function p(t,n){t.o([[9,1],[13,1],[18,1],[30,1]],n)}function y(t,n,o,e,r,{xyb:i=!1,orientation:s=1,colorSpace:c}={}){t.write(16,2815),t.write(1,0),p(t,o),t.write(3,0),p(t,n),t.write(1,0);const f=1!==s;t.write(1,f?1:0),f&&t.write(6,s-1),t.write(4,8),r?t.write(3,5):t.write(2,0),t.write(1,i?1:0),3===e&&"display-p3"===c?t.write(21,903568):3===e?t.write(1,1):t.write(15,14100),f&&t.write(1,1),t.write(2,0),t.write(1,1),t.i()}function w(t,{alpha:n,shift:o=1}){t.write(9,8),n&&t.write(2,0),t.write(2,o),function(t,n){t.write(n?7:5,0),t.write(11,1)}(t,n)}function d(t,n,o=256){const e=Math.ceil(t/o),r=Math.ceil(n/o);return{p:e,m:r,M:Math.ceil(t/(8*o)),A:Math.ceil(n/(8*o)),U:1===e&&1===r}}function*g(t,n,o,e){if(t.pooled){const n=yield t;return n?(n.results.forEach((t,n)=>e(n,t)),n.hurried):null}let r=!1;for(let e=0;e<n;e++)if(o(e),r=yield t.at(e),r&&t.stop(e))return null;return r}function m(t,n){const o=n.map(t=>t.length);!function(t,n){t.write(1,0),t.i();for(const o of n)t.o([[10,0],[14,1024],[22,17408],[30,4211712]],o);t.i()}(t,o);const e=t.finish(),r=e.length+o.reduce((t,n)=>t+n,0);a(r);const i=new Uint8Array(r);i.set(e);let s=e.length;for(const t of n)i.set(t,s),s+=t.length;return i}const b=[1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15],M=[2,4,3,2,2,4],A=[0,7,3,2,1,15];function U(t,n){const o=new Uint8Array(t.length),e=[];for(let n=0;n<t.length;n++)t[n]>0&&e.push(n);if(!e.length)return o;if(1===e.length)return o[e[0]]=1,o;for(let r=1;;r*=2){const i=e.map(n=>({w:Math.max(t[n],r),S:n,l:null,r:null})).sort((t,n)=>t.w-n.w||t.S-n.S),s=[];let c=0,f=0;const l=()=>c<i.length&&(f>=s.length||i[c].w<=s[f].w)?i[c++]:s[f++];for(;i.length-c+(s.length-f)>1;){const t=l(),n=l();s.push({w:t.w+n.w,S:-1,l:t,r:n})}const a=[[l(),0]];let u=0;for(;a.length;){const[t,n]=a.pop();t.S>=0?(o[t.S]=n,n>u&&(u=n)):a.push([t.l,n+1],[t.r,n+1])}if(u<=n)return o}}function S(t,n,o,e,r,i){const s=[];for(;s.push(e&r),e>>=i;)e--;for(let e=s.length-1;e>=0;e--)t.push(o),n.push(s[e])}function I(t,n){let o=0;for(let e=0;e<n;e++)o=o<<1|1&t,t>>=1;return o}function x(t){const n=new Uint32Array(17),o=new Uint32Array(17),e=new Uint16Array(t.length);for(const o of t)n[o]++;n[0]=0;for(let t=1,e=0;t<=16;t++)e=e+n[t-1]<<1,o[t]=e;for(let n=0;n<t.length;n++)t[n]&&(e[n]=I(o[t[n]]++,t[n]));return e}function C(t){const n=[];for(let o=0;o<t.length;o++)t[o]>0&&n.push(o);const o=n.length,e=n[o-1]+1||1,r=o<=4?new Uint8Array(e):U(t,15).subarray(0,e);let i=0;if(o<=4){n.sort((n,o)=>t[o]-t[n]||n-o),i=4===o&&t[n[0]]>t[n[2]]+t[n[3]]?1:0;const e=o<2?[0]:2===o?[1,1]:3===o?[1,2,2]:i?[1,2,3,3]:[2,2,2,2];n.forEach((t,n)=>{r[t]=e[n]}),n.sort((t,n)=>r[t]-r[n]||t-n)}return{I:e,C:r,T:x(r),v:o&&o<=4?n:null,L:i}}function T(t,n){if(n.I<=1)return;if(n.v){const o=c(n.I-1)+1;t.write(2,1),t.write(2,n.v.length-1);for(const e of n.v)t.write(o,e);return void(4===n.v.length&&t.write(1,n.L))}const o=n.C,e=[],r=[];let i=o.length-1;for(;i>0&&!o[i];)i--;let s=8;for(let t=0;t<=i;){const n=o[t];let c=1;for(;t+c<=i&&o[t+c]===n;)c++;let f=c;if(n&&n!==s&&(e.push(n),r.push(0),f--,s=n),f<3)for(let t=0;t<f;t++)e.push(n),r.push(0);else S(e,r,n?16:17,f-3,n?3:7,n?2:3);t+=c}const f=new Uint32Array(18);for(const t of e)f[t]++;let l=0;for(const t of f)t&&l++;1===l&&(f[e[0]?0:1]=f[e[0]]);const a=U(f,5),u=x(a);let h=18;for(;h>0&&!a[b[h-1]];)h--;t.write(2,0);for(let n=0;n<h;n++){const o=a[b[n]];t.write(M[o],A[o])}for(let n=0;n<e.length;n++){const o=e[n];t.write(a[o],u[o]),16===o?t.write(2,r[n]):17===o&&t.write(3,r[n])}}function v(t,n=0,o=0){return{split:t,X:n,N:o,P:1<<t}}function E(t,n,o=15){t.write(f(o+1),n.split),n.split!==o&&(t.write(f(n.split+1),n.X),t.write(f(n.split-n.X+1),n.N))}function L(t,n,o){if(n<t.P)return o[0]=n,o[1]=0,void(o[2]=0);const e=c(n),r=n-(1<<e),i=e-t.X-t.N;o[0]=t.P+(e-t.split<<t.X+t.N|r>>e-t.X<<t.N|r&(1<<t.N)-1),o[1]=i,o[2]=n>>t.N&(1<<i)-1}function X(t,n,o,e=0){L(t,n,N),o[e+N[0]]++}const N=[0,0,0];function P(t,n,o,e,r=0){L(o,e,N);const i=r+N[0];t.write(n.C[i],n.T[i]),N[1]&&t.write(N[1],N[2])}function z(t,{J:n=null,_:o,q:e}){t.write(1,n?1:0),n&&(t.o([[0,224],[0,512],[0,4096],[15,8]],n.G),t.o([[0,3],[0,4],[2,5],[8,9]],n.minLength),E(t,n.O,8)),o.length>1&&function(t,n){let o=0;for(const t of n)o=Math.max(o,t);const e=o?f(o+1):0;if(e<=3){if(t.write(1,1),t.write(2,e),e)for(const o of n)t.write(e,o);return}t.write(1,0),t.write(1,0);const r=v(8),i=v(4),s=n.length>=64,c=new Uint32Array(s?257:o+1),l=[];for(let t=0;t<n.length;){let o=1;for(;s&&t+o<n.length&&n[t+o]===n[t];)o++;if(o>=8)l.push([n[t],o-1]),c[n[t]]++,X(i,o-1-7,c,224),t+=o;else{for(let e=0;e<o;e++)l.push([n[t],0]),c[n[t]]++;t+=o}}const a=C(c);if(!s){z(t,{_:new Uint8Array(1),q:[{config:r,code:a}]});for(const[n]of l)P(t,a,r,n);return}const u=new Uint32Array(1);u[0]=1,z(t,{J:{G:224,minLength:7,O:i},_:new Uint8Array([1,0]),q:[{config:v(0),code:C(u)},{config:r,code:a}]});for(const[n,o]of l)P(t,a,r,n),o&&P(t,a,i,o-7,224)}(t,o),t.write(1,1);for(const n of e)E(t,n.config,15);for(const n of e){const o=n.code.I-1;if(o){const n=c(o);t.write(1,1),t.write(4,n),t.write(n,o-(1<<n))}else t.write(1,0)}for(const n of e)T(t,n.code)}const J=3,_=5,q=v(4),G=Object.freeze({G:224,minLength:7,O:q}),O=v(0);function j(t,n=0,o=1){return{j:t,offset:n,k:o,context:-1}}function k(t,n){const o=(e,r)=>{if(e===r)return n?t[e].B:t[e];const i=e+r>>1;return function(t,n,o,e){return{R:t,Z:n,left:o,right:e}}(n,n?t[i].Y:i,o(i+1,r),o(e,i))};return o(0,t.length-1)}function B(t){return k(t,0)}function R(t,n){const o=[n],e=[],r=[];for(const t of o){if(t.left){e.push(t.R+1,s(t.Z)),o.push(t.left,t.right);continue}t.context=r.length,r.push(t);const n=1===t.k?0:31-Math.clz32(t.k&-t.k);e.push(0,t.j,s(t.offset),n,(t.k>>n)-1)}const i=new Uint32Array(64);for(const t of e)X(O,t,i);const c=C(i);z(t,{_:new Uint8Array(6),q:[{config:O,code:c}]});for(const n of e)P(t,c,O,n);return r}function Z(t,n){const o=[[3,0],[6,8],[10,72],[13,1096]];if("rct"===n.type)t.write(2,0),t.o(o,n.D),t.o([[0,6],[2,0],[4,2],[6,10]],n.F??6);else if("palette"===n.type)t.write(2,1),t.o(o,n.D),t.o([[0,1],[0,3],[0,4],[13,1]],n.H),t.o([[8,0],[10,256],[12,1280],[16,5376]],n.K),t.o([[0,0],[8,1],[10,257],[16,1281]],n.V??0),t.write(4,n.j??0);else{if("squeeze"!==n.type)throw new Error("unknown transform "+n.type);{t.write(2,2);const e=n.W??[];t.o([[0,0],[4,1],[6,9],[8,41]],e.length);for(const n of e)t.write(1,n.$?1:0),t.write(1,n.tt?1:0),t.o(o,n.D),t.o([[0,1],[0,2],[0,3],[4,4]],n.H)}}}function Y(t,{nt:n=!0,ot:o=[]}={}){t.write(1,n?1:0),t.write(1,1),t.o([[0,0],[0,1],[4,2],[8,18]],o.length);for(const n of o)Z(t,n)}function D(t,n,o,e=t=>t.context,r=()=>O){const i=new Uint8Array(n.length+1);for(const t of n)i[t.context]=e(t)+1;const s=new Uint32Array(2);s[1]=1;const c=[{config:O,code:C(s)}],f=Math.max(...i);for(let t=0;t<f;t++)c.push({config:r(t),code:C(o[t])});return z(t,{J:G,_:i,q:c}),c}function Q(n,o,e,r,i,c,f=!1){if(t.channel?.(n,o,e,r,i,c,f))return;const l=c.j,a=c.offset,u=c.k,h=c.config||O,p=q;let y=0;const w=(t,e=h,r=0)=>{n?P(n,o,e,t,r):f&&!r?o[t]++:X(e,t,o,f?o.length-33:r)},d=()=>{if(y){if(y>=8)w(0),w(y-7-1,p,224);else for(let t=0;t<y;t++)w(0);y=0}},g=(t,n)=>{const o=e[t];let r;1===u?r=o-n-a:(r=Math.round((o-n-a)/u),e[t]=n+a+r*u),0!==r?(d(),w(s(r))):y++};for(let t=0,n=0;t<i;t++)for(let o=0;o<r;o++,n++){let i;if(0===l)i=0;else{const s=o?e[n-1]:t?e[n-r]:0,c=t?e[n-r]:s;if(1===l)i=s;else if(2===l)i=c;else if(3===l)i=(s+c)/2|0;else{const f=s+c-(o&&t?e[n-r-1]:s);if(5===l){const t=s<c?s:c,n=s<c?c:s;i=f<t?t:f>n?n:f}else{if(4!==l)throw new Error("predictor "+l+" is not coded here");i=Math.abs(f-s)<Math.abs(f-c)?s:c}}}g(n,i)}d()}const F=[v(0),v(4),v(4,1,1),v(3,0,1)];function H(t){const n=t.length-33,o=[0,0,0];let r,i;for(const s of F){const f=new Uint32Array(257);let l=0;for(let e=0;e<n;e++)t[e]&&(L(s,e,o),f[o[0]]+=t[e],l+=t[e]*o[1]);for(let o=0;o<33;o++)f[224+o]=t[n+o],l+=t[n+o]*Math.max(0,o-12);const a=C(f),u=new e(128);E(u,s),T(u,a);let h=u.u+l+(1===a.I?1:5+c(a.I-1));for(let t=0;t<f.length;t++)f[t]&&(h+=f[t]*a.C[t]);const p={config:s,et:f,rt:h,extra:l};r||(r=p),(!i||h<i.rt)&&(i=p)}return[r,i]}const K=(t,n,o,e)=>o?e?t[n]+256*t[n+3]:t[n]:t[n]+256*t[n+1]+65536*t[n+2]+(e?16777216*t[n+3]:0);function V(t,n,o,{palette:e=!0}={}){const r=n*o;let i=!0,s=!0;for(let n=0,o=0;o<r&&(255===t[n+3]||(i=!1,s))&&(t[n]===t[n+1]&&t[n]===t[n+2]||(s=!1,i));o++,n+=4);const c=s?1:3,f=!i,l=c+(f?1:0),a=n=>K(t,n,s,f),u=new Map;let h=null;for(let t=0,n=0;e&&n<r;n++,t+=4){const n=a(t);if(0!==n&&!u.has(n)&&(u.set(n,1),u.size>=2048))break}if(e&&u.size<2048){const t=[...u.keys()],n=(t,n)=>t>>>8*n&255,o=t=>(.299*n(t,0)+.587*n(t,1)+.114*n(t,2)+.01)*(4===l?n(t,3):1);t.sort((t,n)=>o(t)-o(n)),h={colours:[0,...t],byte:n}}return{colour:c,alpha:f,channels:l,palette:h}}function W({channels:n,alpha:o,palette:e},r){const i=n-(o?1:0)==1,s=e&&new Map(e.map((t,n)=>[t,n]));return(c,f,l,a,u,h,p)=>{if(r&&!e&&n>=3)r.fill(c,f,l,a,u,h,p);else if(e||!t.fill?.(f,l,a,u,h,p,n,c))for(let t=0;t<p;t++){let r=4*((u+t)*l+a),p=t*h;for(let t=0;t<h;t++,r+=4,p++)if(e)c[0][p]=s.get(K(f,r,i,o));else if(n>=3){const t=f[r],o=f[r+1],e=f[r+2],i=t-e,s=e+(i>>1),l=o-s;c[0][p]=s+(l>>1),c[1][p]=i,c[2][p]=l,4===n&&(c[3][p]=f[r+3])}else c[0][p]=f[r],2===n&&(c[1][p]=f[r+3])}}}function $(t,n){const{leaves:o,picture:r,T:i}=t,s=W(t,n),c=r.map(()=>new Int16Array(65536));return(t,n,f,l,a,u,h)=>{if(s(c,t,n,f,l,a,u),!i)return void r.forEach((t,n)=>Q(null,h[t],c[n],a,u,o[t],!0));const p=h||new e(a*u*r.length+64);return h||Y(p,{nt:!0,ot:[]}),r.forEach((t,n)=>Q(p,i[t],c[n],a,u,o[t])),h?void 0:p.finish()}}function*tt(t,n,o,{shape:e=V(t,n,o),colorSpace:i,rct:s,pooled:c}={}){let f,l;const a=e.palette?[e,{...e,palette:null}]:[e];for(let e=0;e<a.length;e++)try{const l=yield*r(nt(t,n,o,a[e],i,s,c),e,a.length);(!f||l.length<f.length)&&(f=l)}catch(t){if("JXL_SIZE"!==t.code)throw t;l=t}if(!f)throw l;return f}function*nt(t,n,o,r,i,s,c){const{channels:f,alpha:l,palette:a}=r,u=d(n,o),p=u.p*u.m,b=a?2:f,M=Array.from({length:b},()=>j(_)),A=B(M),U={channels:f,alpha:l,palette:a&&a.colours,rct:s?.type,leaves:M,picture:a?[u.U?1:0]:M.map((t,n)=>n)},S=W(U,s),I=Array.from({length:f},()=>new Int16Array(1024)),x=t=>function(t,n,o,e){const r=e%t.p*h,i=(e/t.p|0)*h;return[r,i,Math.min(h,n-r),Math.min(h,o-i)]}(u,n,o,t);let v=null;if(a){const t=a.colours.length;v=new Int16Array(t*f),a.colours.forEach((n,o)=>{for(let e=0;e<f;e++)v[e*t+o]=a.byte(n,e)})}if(!a){const r=t=>{const n=C(t),o=new e(128);T(o,n);let r=o.u;for(let o=0;o<t.length;o++)t[o]&&(r+=t[o]*(n.C[o]+Math.max(0,o<224?o-1:o-236)));return r},i=Math.min(n,32),s=Math.min(o,32),c=[_,J].map(t=>({j:t,et:M.map(()=>new Uint32Array(257))}));for(const e of[0,.5,1]){S(I,t,n,Math.floor((n-i)*e),Math.floor((o-s)*e),i,s);for(const t of c)for(let n=0;n<f;n++)Q(null,t.et[n],I[n],i,s,j(t.j))}M.forEach((t,n)=>{const o=c.map(t=>r(t.et[n])),e=o[1]<o[0]?1:0;t.j=c[e].j})}const E=a?[{type:"palette",D:0,H:f,K:a.colours.length}]:f>=3&&0!==s?.type?[{type:"rct",D:0,F:s?.type??6}]:[];let L=M.map(()=>new Uint32Array(33+(a?4096:1024)));v&&Q(null,L[0],v,a.colours.length,f,M[0],!0);const X=$(U,s);yield*g({pooled:c,kind:"plan",setup:{...U,sizes:L.map(t=>t.length)},at:t=>(t+1)/(2*p),stop:()=>!1},p,o=>X(t,n,...x(o),L),(t,n)=>function(t,n){t.forEach((t,o)=>{const e=n[o];for(let n=0;n<t.length;n++)t[n]+=e[n]})}(L,n));const N=L.map(H),P=N.reduce((t,n)=>t+n[0].rt-n[1].rt,0)>27*(u.U?1:p+1)+8?1:0;M.forEach((t,n)=>{t.config=N[n][P].config}),L=N.map(t=>t[P].et);const z=new e(256);y(z,n,o,r.colour,r.alpha,{colorSpace:i}),w(z,{alpha:r.alpha});const q=new e(4096);q.write(1,1),q.write(1,1);const G=D(q,R(q,A),L,t=>M.indexOf(t),t=>M[t].config),O={...U,T:M.map((t,n)=>G[n+1]?.code)},k=$(O,s);Y(q,{nt:!0,ot:E}),v&&Q(q,O.T[0],v,a.colours.length,f,M[0]);const Z=[];if(u.U)k(t,n,0,0,n,o,q),yield 1,Z.push(q.finish());else{Z.push(q.finish());for(let t=0;t<u.M*u.A+1;t++)Z.push(new Uint8Array(0));const o=Z.length,e=(t,n)=>{Z[o+t]=n};yield*g({pooled:c,kind:"plan",setup:O,at:t=>(p+t+1)/(2*p),stop:()=>!1},p,o=>e(o,k(t,n,...x(o))),e)}return m(z,Z)}const ot=(t,n)=>t+n+(t>n?1:0)>>1;function et(t,n,o){const e=t>=n&&n>=o?1:t<=n&&n<=o?-1:0;if(!e)return 0;let r=(4*(t*=e)-3*(o*=e)-(n*=e)+6)/12|0;return r-(1&r)>2*(t-n)&&(r=2*(t-n)+1),r+(1&r)>2*(n-o)&&(r=2*(n-o)),e*r}function rt(t,n){const{w:o,h:e,data:r}=t,i=n?o:e,s=i+1>>1,c=i-s,f=n?s:o,l=n?e:s,a=n?c:o,u=n?e:c,h=new Int16Array(f*l),p=new Int16Array(a*u),y=n?1:o;for(let t=0;t<l;t++)for(let e=0;e<f;e++){const s=n?e:t,l=n?t*o+2*e:2*t*o+e;if(s===c){h[t*f+e]=r[l];continue}const u=r[l],w=r[l+y],d=ot(u,w),g=s+1<c?ot(r[l+2*y],r[l+3*y]):1&i?r[l+2*y]:d;h[t*f+e]=d,p[t*a+e]=u-w-et(s?r[l-y]:d,d,g)}const w=(o,e,r)=>({w:e,h:r,it:t.it+ +n,st:t.st+!n,data:o});return[w(h,f,l),w(p,a,u)]}function it(t){const n=[],o=t.length;let e=t[0].w,r=t[0].h;for(o>2&&t[1].w===e&&t[1].h===r&&(n.push({$:!0,tt:!1,D:1,H:2}),n.push({$:!1,tt:!1,D:1,H:2})),!(e>r)&&r>8&&(n.push({$:!1,tt:!0,D:0,H:o}),r=r+1>>1);e>8||r>8;)e>8&&(n.push({$:!0,tt:!0,D:0,H:o}),e=e+1>>1),r>8&&(n.push({$:!1,tt:!0,D:0,H:o}),r=r+1>>1);return n}const st=1024,ct=8192;function*ft(t,n,o,{quality:r=90,shape:i=V(t,n,o,{palette:!1}),colorSpace:s}={}){const c=function(t){return t>=100?0:t>=30?.1+.09*(100-t):53/3e3*t*t-1.15*t+25}(r);if(!(c>0))throw new Error("lossy encoding needs a quality below 100");const{colour:f,alpha:l,channels:a}=i,u=n*o,h=Array.from({length:a},()=>new Int16Array(u));for(let n=0,o=0;o<u;o++,n+=4){if(3===f){const e=t[n],r=t[n+1],i=t[n+2],s=e-i,c=i+(s>>1),f=r-c;h[0][o]=c+(f>>1),h[1][o]=s,h[2][o]=f}else h[0][o]=t[n];l&&(h[a-1][o]=t[n+3])}const p=h.map((t,e)=>({w:n,h:o,it:0,st:0,data:t,component:3===f?e:0===e?0:3})),g=1===n&&o>st&&3===f,b=g?it(p).filter(t=>!t.$):1!==n&&1!==o||3!==f?[]:it(p),M=function(t,n=it(t)){const o=t.map(t=>({...t,level:0,ct:!1}));for(const t of n){const n=t.D+t.H-1,e=t.tt?n+1:o.length;for(let r=t.D;r<=n;r++){const[n,i]=rt(o[r],t.$),s=o[r].level+1;o[r]={...n,level:s,ct:o[r].ct,component:o[r].component},o.splice(e+(r-t.D),0,{...i,level:s,ct:!0,component:o[r].component})}}return o}(p,b.length?b:void 0),A=t=>t.ct?0:_,U=t=>function(t,n,o,e){let r=Math.min(16,n+o);if(r>0&&r--,3===t)return 1;const i=.25*function(t){let n=1;for(let o=0;o<24;o++)n=(4*n+t/(n*n*n*n))/5;return t*n}(e),s=1<<r,c=1===t||2===t?.35*i*Math.max(.5,1024/s):.35*i*1.1*(163.84/s);return Math.max(1,Math.floor(c))}(t.component,t.it+(g&&t.component>0&&t.component<3?1:0),t.st,c),S=[...3===f?[{type:"rct",D:0,F:6}]:[],{type:"squeeze",W:b}],I=d(n,o,st),x=I.M*I.A,C=I.p*I.m;let T=0;for(;T<M.length&&M[T].w<=st&&M[T].h<=st;)T++;const v=(t,n,o,e)=>{const r=n>>t.it,i=o>>t.st;return{x:r,y:i,w:Math.min(t.w,r+(e>>t.it))-r,h:Math.min(t.h,i+(e>>t.st))-i}},E=[{index:0,Y:0,ft:[]}];for(let t=0;t<T;t++)E[0].ft.push({c:t,rect:{x:0,y:0,w:M[t].w,h:M[t].h}});if(!I.U){for(let t=0;t<x;t++){const n=t%I.M,o=t/I.M|0,e={index:1+t,Y:1+x+t,ft:[]};for(let t=T;t<M.length;t++){const r=M[t];if(Math.min(r.it,r.st)<3)continue;const i=v(r,n*ct,o*ct,ct);i.w>0&&i.h>0&&e.ft.push({c:t,rect:i})}E.push(e)}for(let t=0;t<C;t++){const n=t%I.p,o=t/I.p|0,e={index:2+x+t,Y:1+3*x+17+t,ft:[]};for(let t=T;t<M.length;t++){const r=M[t];if(Math.min(r.it,r.st)>2)continue;const i=v(r,n*st,o*st,st);i.w>0&&i.h>0&&e.ft.push({c:t,rect:i})}E.push(e)}}for(const t of E)for(const n of t.ft){const t=M[n.c];n.lt=j(A(t),0,U(t)),n.lt.channel=n.c}const L=E.filter(t=>t.ft.length),X=1===L.length?B(L[0].ft.map(t=>t.lt)):function(t){return k(t,1)}(L.map(t=>({Y:t.Y,B:B(t.ft.map(t=>t.lt))}))),N=new Int16Array(1048576),P=t=>{const n=M[t.c],o=t.rect;if(o.w===n.w&&o.h===n.h)return n.data;for(let t=0;t<o.h;t++)N.set(n.data.subarray((o.y+t)*n.w+o.x,(o.y+t)*n.w+o.x+o.w),t*o.w);return N},z=[...new Set(E.flatMap(t=>t.ft.map(t=>t.c)))].sort((t,n)=>t-n),J=new Map(z.map((t,n)=>[t,n])),q=z.map(()=>new Uint32Array(257)),G=1+2*E.length;let O=1;yield O/G;for(const t of E){for(const n of t.ft)Q(null,q[J.get(n.c)],P(n),n.rect.w,n.rect.h,n.lt);yield++O/G}const Z=new e(256);y(Z,n,o,f,l,{colorSpace:s}),w(Z,{alpha:l,shift:n>256||o>256?3:1});const F=Array.from({length:I.U?1:2+x+C},()=>null),H=F[0]=new e(65536);H.write(1,1),H.write(1,1);const K=D(H,R(H,X),q,t=>J.get(t.channel));Y(H,{nt:!0,ot:S});for(const t of E){let n=F[t.index];n||(n=F[t.index]=new e(4096),t.ft.length&&Y(n,{nt:!0,ot:[]}));for(const o of t.ft)Q(n,K[J.get(o.c)+1].code,P(o),o.rect.w,o.rect.h,o.lt);yield++O/G}return m(Z,function(t){return t.map(t=>t?t.finish():new Uint8Array(0))}(F))}function lt(t,n,o,e){return function(t){let n;for(;!(n=t.next()).done;);return n.value}(at(t,n,o,e))}function at(t,o,e,i){const{quality:s,colorSpace:c}=function(t={},n=100){if(null===t||"object"!=typeof t)throw l("JXL_INPUT","Options are an object: {quality, colorSpace}.");if(void 0!==t.quality&&(n=t.quality),"number"!=typeof n||!Number.isFinite(n)||n<1||n>100)throw l("JXL_INPUT","Quality is a number from 1 to 100.");const o=void 0===t.colorSpace?"srgb":t.colorSpace;if("srgb"!==o&&"display-p3"!==o)throw l("JXL_INPUT","The colour space is srgb or display-p3.");return{quality:n,colorSpace:o}}(i);return function(t,o,e,r){if(function(t,o,e=n){if(!Number.isInteger(t)||!Number.isInteger(o)||t<1||o<1)throw l("JXL_INPUT","A picture is at least one pixel wide and high, in whole pixels.");if(t>e.edge||o>e.edge)throw l("JXL_DIMENSIONS","A picture is at most "+e.edge+" pixels on a side.");if(t*o>e.pixels)throw l("JXL_DIMENSIONS","A picture is at most "+e.pixels.toLocaleString("en-US")+" pixels.")}(o,e,r),!(t instanceof Uint8Array||t instanceof Uint8ClampedArray))throw l("JXL_INPUT","Pixels are a Uint8Array or Uint8ClampedArray of RGBA bytes.");if(t.length!==o*e*4)throw l("JXL_INPUT","Pixels are width * height * 4 bytes: straight (not premultiplied) RGBA, row by row.")}(t,o,e),function(t){const n=function*(){let o,e;for(;!(o=u(()=>t.next(n.hurry))).done;)yield e=o.value;return e<1&&(yield 1),n.bytes=function(t){return a(t.length),t}(o.value)}();return n.bytes=null,n.hurry=!1,n}(function*(t,n,o,e,i){const s=V(t,n,o);if(e>=100)return yield*tt(t,n,o,{shape:s,colorSpace:i});if(!s.palette)return yield*ft(t,n,o,{quality:e,shape:s,colorSpace:i});const c=yield*r(tt(t,n,o,{shape:s,colorSpace:i}),0,2);let f;try{f=yield*r(ft(t,n,o,{quality:e,shape:s,colorSpace:i}),1,2)}catch(t){if("JXL_SIZE"!==t.code&&(!(t instanceof RangeError)||t.code))throw t;f=c}return c.length<=f.length?c:f}(t,o,e,s,c))}export{n as LIMITS,lt as encode,at as encodeSteps};
package/rct-search.mjs ADDED
@@ -0,0 +1,61 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Optional lossless colour-transform search. Samples rank the 42 reversible transforms; only a complete
3
+ // candidate can displace an earlier stream. The page's effort-3 path does not pay for this higher rung.
4
+ import {BitWriter} from './bits.mjs';
5
+ import {leaf, codeChannel, writeTransform} from './modular.mjs';
6
+ import {losslessCoding} from './lossless-coding.mjs';
7
+ import {losslessSteps} from './lossless.mjs';
8
+
9
+ // Transform `type` of the specification's 42 (a permutation, then one of seven), filling planes as planeFill does.
10
+ export function colourTransform(type, channels) {
11
+ const permutation = Math.floor(type / 7), custom = type % 7;
12
+ const a = permutation % 3, b = (permutation + 1 + Math.floor(permutation / 3)) % 3;
13
+ const c = (permutation + 2 - Math.floor(permutation / 3)) % 3;
14
+ return {type, fill(planes, rgba, stride, x0, y0, w, h) {
15
+ for (let y = 0; y < h; y++) for (let x = 0, at = y * w, i = ((y0 + y) * stride + x0) * 4; x < w; x++, at++, i += 4) {
16
+ const first = rgba[i + a], second = rgba[i + b], third = rgba[i + c];
17
+ if (custom === 6) {
18
+ const co = first - third, tmp = third + (co >> 1), cg = second - tmp;
19
+ planes[0][at] = tmp + (cg >> 1); planes[1][at] = co; planes[2][at] = cg;
20
+ } else {
21
+ planes[0][at] = first;
22
+ planes[1][at] = second - ((custom >> 1) === 1 ? first : (custom >> 1) === 2 ? (first + third) >> 1 : 0);
23
+ planes[2][at] = third - (custom & 1 ? first : 0);
24
+ }
25
+ if (channels === 4) planes[3][at] = rgba[i + 3];
26
+ }
27
+ }};
28
+ }
29
+
30
+ export function* rctSearchSteps(rgba, width, height, shape, colorSpace, pooled) {
31
+ if (shape.colour !== 3 || width * height < 4096) return null;
32
+ const sw = Math.min(width, 32), sh = Math.min(height, 32);
33
+ const planes = Array.from({length: shape.channels}, () => new Int16Array(sw * sh));
34
+ const types = [6, ...Array.from({length: 42}, (_, i) => i).filter(i => i !== 6)];
35
+ let best;
36
+ for (let k = 0; k < types.length; k++) {
37
+ const rct = colourTransform(types[k], shape.channels);
38
+ const candidates = [5, 3].map(predictor => ({predictor, freqs: Array.from({length: 3}, () => new Uint32Array(1057))}));
39
+ for (let sample = 0; sample < 3; sample++) {
40
+ rct.fill(planes, rgba, width, Math.floor((width - sw) * sample / 2), Math.floor((height - sh) * sample / 2), sw, sh);
41
+ for (const candidate of candidates) for (let c = 0; c < 3; c++) codeChannel(null, candidate.freqs[c], planes[c], sw, sh, leaf(candidate.predictor), true);
42
+ }
43
+ const w = new BitWriter(32);
44
+ if (rct.type) writeTransform(w, {type: 'rct', beginC: 0, rctType: rct.type});
45
+ let bits = w.bitLength;
46
+ for (let c = 0; c < 3; c++) bits += Math.min(...candidates.map(p => losslessCoding(p.freqs[c])[1].bits));
47
+ if (!best || bits < best.bits) best = {rct, bits};
48
+ if (yield (k + 1) / (4 * types.length)) return null;
49
+ }
50
+ if (best.rct.type === 6) return null;
51
+ const plan = losslessSteps(rgba, width, height, {shape: {...shape, palette: null}, colorSpace, rct: best.rct, pooled});
52
+ let step, reply;
53
+ while (!(step = plan.next(reply)).done) {
54
+ // The final group is already complete: finish assembly and retain it even when the caller hurries there. A pooled
55
+ // pass ends at a hurry anywhere before that.
56
+ const done = step.value, inner = typeof done === 'number';
57
+ reply = yield inner ? 0.25 + 0.75 * done : {...done, at: g => 0.25 + 0.75 * done.at(g), stop: g => done.at(g) < 1};
58
+ if (inner ? reply && done < 1 : !reply) return null;
59
+ }
60
+ return step.value;
61
+ }
package/sizes.json CHANGED
@@ -1,30 +1,49 @@
1
1
  {
2
2
  "package": "rapier-jxl",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "measured": "exact bytes of the staged files; gzip level 9; Brotli quality 11, text mode; added is a door bundled with the core less the core alone, or the door alone less the core where it covers the core (effort); every measured bundle loads as a module",
5
5
  "node": "v22.22.2",
6
6
  "terser": "5.51.2",
7
7
  "privateProperties": "^(alphabetSize|lengths|codes|simple|treeSelect|splitToken|msb|lsb|contextMap|histograms|predictor|multiplier|context|splitval|property|offset|left|right|channel|acc|pending|at|bitLength|grow|zeroPadToByte|writeU32|append|finish|write|small|large|totals|contexts|tokens|cost|bucketOf|contextOf|nonZero|zeroDensityOffset|thresholds|numDc|numCtxs|freqs|hshift|vshift|residual|component|inPlace|horizontal|beginC|numC|rctType|nbColors|nbDeltas|useGlobalTree|streamId|pieces|rect|minSymbol|minLength|lengthConfig|params|type|leaf|groupsX|groupsY|dcGroupsX|dcGroupsY|single|config|bits|sym|tree|count|parts|lz77|transforms)$",
8
8
  "source": {
9
- "bytes": 136580,
10
- "gzip": 42707,
9
+ "bytes": 211215,
10
+ "gzip": 67195,
11
11
  "sha256": {
12
- "admit.mjs": "52177c34daece7e57aa0e3addf18da9611774ba3830958b054e00cd031d94fbd",
13
- "bits.mjs": "aee959d6bf46344f38291b461e8c40c225a23b7f4f093b21848432d9223abf3a",
14
- "effort.mjs": "fefa2a62508ab1969fe8f28e1eda7b829f4fb5d15dd48170077e7a6e43b7d47c",
12
+ "admit.mjs": "ccdbee9f68a0e0125853d5d786b95075bc39807e9a6e95d8a185a6c0c7b2fca4",
13
+ "ans.mjs": "c604457516a86c8697810d9ded6af20f91b59650f0ed5aea6683fc9f2051f79e",
14
+ "bits.mjs": "8f63d88635518231f0ad3bd2155b263fe9c0fef737dc0f1f69befa40c0cd6750",
15
+ "coefficient-ans.mjs": "8b7a080f440bc1894d7d13f6ee76b3a85fce7bbd0cfadc53ad06e4b58ed81ed1",
16
+ "coefficient-effort.mjs": "2d55459c7b96f85d7a6d029d87f0e4c2905d5982aa64334e38c4a401c2beebfb",
17
+ "effort.mjs": "70336f2eb5325da470bfb60afb808acc3ac1e985f8919387d214c385e7bc9b36",
18
+ "effort-job.mjs": "e2c5a735757edc72f6f6992fe360e66a7ffc218873a6372381f9fa71d2613c74",
19
+ "effort-level.mjs": "fe46adf2e34546c65e821400804cbd51c17c5a6d04b769310567082581b64f5d",
15
20
  "entropy.mjs": "9cb52a9d174d63dc2b694725267c5ab0e8d693f5366e76fa0134f87cc878fe3a",
16
- "frame.mjs": "139c001fc0e8f666b4b107dff3f135f866a69995305bb87c79de74c2b3cc28f9",
17
- "index.mjs": "7ac659657a069f75841053a9e18dcd00650006312c6ef2de128a20707ae69589",
18
- "jfif.mjs": "430c4a7efbf53007c7084fc6da85f4de9a05caad050b17ec9439ab0d17645d5c",
19
- "jpeg.mjs": "5189e1b68dea7449f3e8b42d1e27e59eaf13132a9510c497546d525c8ae47499",
20
- "lossless.mjs": "6260af5e685a94360ee7eb2c0f3e6ac94dc931ab0f199a7d5102ba13893f390c",
21
+ "frame.mjs": "b921e8bddcd021d1a1fe3afffda2816b90af1f81121c27de78db5746c462e378",
22
+ "index.mjs": "adf5f0d4ca70ce3e88c67a718d057c5dcab5098bd07308f4bf9406c365d81efe",
23
+ "jfif.mjs": "6b9a59f0b81ce5063191d1da9f658727ef03535144cd92b3908b249dfc99ed17",
24
+ "jpeg.mjs": "41bf5579a99f1870bc219228eb649589d027c807bdaee5c8b128a7aaa6711c95",
25
+ "jpeg-ans.mjs": "4a9cafe6eaf83f7c37f87513cc42458d6c2997c420830b0449d591c103993072",
26
+ "jpeg-job.mjs": "61370ed45ebd8c15c8edb3d043139dcde8a8bf7bd1ea52d030f3f73de5d6fa60",
27
+ "kernel-hooks.mjs": "c7a8578d0f16b10c3598d527778c99d1dd80b9eb283dffe5ed969e44850b63d4",
28
+ "kernels.mjs": "fc54852d11d1fffa16e7b2f788006ccc23b4757ac0170c59d41ff35224d55391",
29
+ "kernels-bytes.mjs": "d76d121612ddc74ae72fe05f9f643ef08ad578b70e9de28afeb38aa7cd0c237a",
30
+ "local.mjs": "546b39e8bc88de97c5d1d170bf30da68452a6c2bf8fc86a8bd81eb943dfe16bf",
31
+ "lossless.mjs": "6a13093b568597f2500dbd2032558d08c792babac4bd439b0f5b56b9872e0759",
32
+ "lossless-coding.mjs": "1f3ff9c914f3594ab024231fdf06e291412bf0abea1fb211d91e5b768e9244b8",
21
33
  "lossy.mjs": "e297311f5f2d304d17ea277fb156d2a575599aecb5d2473cbfbbd1be6b76ff6d",
22
- "modular.mjs": "9be937ceb8d4eb015a54f7e9f92aeff7be42eeaef94fd13a32530ea5ff204662",
23
- "photo.mjs": "6728fca4786f9a48404b1fdbd90c2496012ead8a3b9e11bae3f230c01336e339",
34
+ "modular.mjs": "0481868e103552ab6adc315442e00cf625f308831f5356d091e9fbad8fb5a421",
35
+ "photo.mjs": "4da303eebca4f52d8fea265a76ca879a06ebe394c699615195067339206f6c98",
36
+ "photo-ans.mjs": "23e2af95d9ac6c80a9b3e1ce4bec7ab39a93ebd2575182f548a0213aa527e387",
37
+ "photo-dct.mjs": "cc7252d877389885baa1d9866489f58a55d0a4d00800f0b358b54904b3cf91ad",
38
+ "photo-job.mjs": "271452713a2c03fbb472f5050483748de5d0cc7b3a0e0589decd143b0f087a68",
39
+ "photo-quant.mjs": "94854a56333a1d5c1346117e576013472857662f2e01a3fa54852d5567256a00",
40
+ "pool.mjs": "14817df64c11d13e6d93da26028b3b20bada214808ee2033ceadd71fa1a81608",
24
41
  "prefix.mjs": "ed51a5b6a3cf0a98b66fe54b3a1c050122ed312f7c47b136aa9fd5c84ac1a180",
42
+ "rct-search.mjs": "119e85e44e6bd259da144be4ac91e3c8aafe812291862a77b987a95e14398935",
25
43
  "squeeze.mjs": "ec01352dcf22b7346c7f0014e17e6ba2e4fe8243c358db77eee5fc830a3217e8",
26
- "vardct.mjs": "ad52f0f95fe1fe843caab986af4535308b4773c33bf52339b0a71d0289e78b2e",
27
- "weighted.mjs": "db14c4ec83ef9389436f7d4e75a46b7424d18b371946ce96cf0b68d49f32c8c2",
44
+ "vardct.mjs": "2befa3c606124fa6aa1f5ab7e856a4734217f0baefa5b3324fabbbbe13c04cd9",
45
+ "wasm.mjs": "00a51183d9bf8b1d8dbf3aded0e1b8a01531c3d77e6f3d9286f273a8d1f1efc6",
46
+ "weighted.mjs": "8f8ff41d572509987015eea0c9ead45d27492e4657db807ef1a12a612e19bf97",
28
47
  "writer.mjs": "f8ec54c0d79cdf148f6be797d72f375cf9635cb00097897bdf1d570457d3fcc9"
29
48
  }
30
49
  },
@@ -39,25 +58,26 @@
39
58
  "encodeSteps"
40
59
  ],
41
60
  "modules": [
61
+ "kernel-hooks",
42
62
  "bits",
63
+ "admit",
43
64
  "frame",
44
65
  "prefix",
45
66
  "modular",
67
+ "lossless-coding",
46
68
  "lossless",
47
69
  "squeeze",
48
70
  "lossy",
49
- "admit",
50
71
  "index"
51
72
  ],
52
73
  "alone": {
53
- "bytes": 19495,
54
- "gzip": 8475,
55
- "brotli": 7494,
56
- "sha256": "50ea1947a6f9e2b0bb4a557d859a29c44031dea2726127e62b29e6c809748fe2",
74
+ "bytes": 21326,
75
+ "gzip": 9271,
76
+ "brotli": 8233,
77
+ "sha256": "b09aa7249379c5ee4dde2d3e4472a6bd3a678c506dbe6550b5fa1274270bdfd7",
57
78
  "compress": {
58
79
  "passes": 2,
59
- "hoist_funs": true,
60
- "hoist_vars": true,
80
+ "inline": 1,
61
81
  "module": true
62
82
  }
63
83
  },
@@ -66,7 +86,7 @@
66
86
  "gzip": 0,
67
87
  "brotli": 0
68
88
  },
69
- "provedByteCases": 94
89
+ "provedByteCases": 98
70
90
  },
71
91
  {
72
92
  "entry": "./jpeg",
@@ -80,19 +100,23 @@
80
100
  "modules": [
81
101
  "bits",
82
102
  "jfif",
103
+ "admit",
104
+ "effort-level",
105
+ "jpeg-job",
83
106
  "frame",
107
+ "kernel-hooks",
84
108
  "prefix",
85
109
  "modular",
86
110
  "entropy",
87
111
  "vardct",
88
- "admit",
112
+ "coefficient-effort",
89
113
  "jpeg"
90
114
  ],
91
115
  "alone": {
92
- "bytes": 29592,
93
- "gzip": 12533,
94
- "brotli": 11072,
95
- "sha256": "4b408d463dbb6bf32f98143b4f2b0e4aa0b2f060ba7778795cedc9d2f26355e5",
116
+ "bytes": 32354,
117
+ "gzip": 13505,
118
+ "brotli": 11946,
119
+ "sha256": "8b3ae463bb9870e8903bafb337413ee9a81bcbc5983a93658f4743d7caff9990",
96
120
  "compress": {
97
121
  "passes": 2,
98
122
  "inline": 1,
@@ -100,11 +124,11 @@
100
124
  }
101
125
  },
102
126
  "added": {
103
- "bytes": 19242,
104
- "gzip": 7673,
105
- "brotli": 6802
127
+ "bytes": 21706,
128
+ "gzip": 8524,
129
+ "brotli": 7474
106
130
  },
107
- "provedByteCases": 9
131
+ "provedByteCases": 13
108
132
  },
109
133
  {
110
134
  "entry": "./photo",
@@ -117,21 +141,28 @@
117
141
  ],
118
142
  "modules": [
119
143
  "bits",
144
+ "admit",
145
+ "effort-level",
146
+ "kernel-hooks",
120
147
  "frame",
121
148
  "prefix",
122
149
  "modular",
150
+ "lossless-coding",
151
+ "lossless",
152
+ "photo-dct",
153
+ "photo-quant",
154
+ "photo-job",
123
155
  "entropy",
124
156
  "jfif",
125
157
  "vardct",
126
- "lossless",
127
- "admit",
158
+ "coefficient-effort",
128
159
  "photo"
129
160
  ],
130
161
  "alone": {
131
- "bytes": 25646,
132
- "gzip": 10804,
133
- "brotli": 9537,
134
- "sha256": "e7cdd24b5e9c1e718dad54c4b40ccc5a2088e7ae8144a457352fdc00b2e22c82",
162
+ "bytes": 33011,
163
+ "gzip": 13616,
164
+ "brotli": 12048,
165
+ "sha256": "ca769b30cb13573bc1e8a24a0cb77ca19d8932fa7761fc39e4b9fc416cfc87c5",
135
166
  "compress": {
136
167
  "passes": 2,
137
168
  "hoist_funs": true,
@@ -140,11 +171,104 @@
140
171
  }
141
172
  },
142
173
  "added": {
143
- "bytes": 11055,
144
- "gzip": 4242,
145
- "brotli": 3762
174
+ "bytes": 16576,
175
+ "gzip": 6249,
176
+ "brotli": 5481
146
177
  },
147
- "provedByteCases": 36
178
+ "provedByteCases": 43
179
+ },
180
+ {
181
+ "entry": "./jpeg-ans",
182
+ "module": "jpeg-ans",
183
+ "file": "jpeg-ans.min.mjs",
184
+ "exports": [
185
+ "LIMITS",
186
+ "transcode",
187
+ "transcodeSteps"
188
+ ],
189
+ "modules": [
190
+ "bits",
191
+ "jfif",
192
+ "admit",
193
+ "effort-level",
194
+ "jpeg-job",
195
+ "frame",
196
+ "kernel-hooks",
197
+ "prefix",
198
+ "modular",
199
+ "entropy",
200
+ "vardct",
201
+ "coefficient-effort",
202
+ "ans",
203
+ "coefficient-ans",
204
+ "jpeg-ans"
205
+ ],
206
+ "alone": {
207
+ "bytes": 35491,
208
+ "gzip": 14608,
209
+ "brotli": 12892,
210
+ "sha256": "3dda743aec24a3241745e8f275d2919fdbded11e9dfdaaf5c04e7c55fa923706",
211
+ "compress": {
212
+ "passes": 2,
213
+ "inline": 1,
214
+ "module": true
215
+ }
216
+ },
217
+ "added": {
218
+ "bytes": 24689,
219
+ "gzip": 9580,
220
+ "brotli": 8431
221
+ },
222
+ "provedByteCases": 13
223
+ },
224
+ {
225
+ "entry": "./photo-ans",
226
+ "module": "photo-ans",
227
+ "file": "photo-ans.min.mjs",
228
+ "exports": [
229
+ "LIMITS",
230
+ "encodePhoto",
231
+ "encodePhotoSteps"
232
+ ],
233
+ "modules": [
234
+ "bits",
235
+ "admit",
236
+ "effort-level",
237
+ "kernel-hooks",
238
+ "frame",
239
+ "prefix",
240
+ "modular",
241
+ "lossless-coding",
242
+ "lossless",
243
+ "photo-dct",
244
+ "photo-quant",
245
+ "photo-job",
246
+ "entropy",
247
+ "jfif",
248
+ "vardct",
249
+ "coefficient-effort",
250
+ "ans",
251
+ "coefficient-ans",
252
+ "photo-ans"
253
+ ],
254
+ "alone": {
255
+ "bytes": 35994,
256
+ "gzip": 14650,
257
+ "brotli": 12975,
258
+ "sha256": "f412840bd9a3bd91d034cfa9c684055e6584fe399a2d00bbaeae07861fb709ac",
259
+ "compress": {
260
+ "passes": 2,
261
+ "hoist_funs": true,
262
+ "hoist_vars": true,
263
+ "module": true
264
+ }
265
+ },
266
+ "added": {
267
+ "bytes": 19559,
268
+ "gzip": 7315,
269
+ "brotli": 6426
270
+ },
271
+ "provedByteCases": 43
148
272
  },
149
273
  {
150
274
  "entry": "./effort",
@@ -157,21 +281,75 @@
157
281
  ],
158
282
  "modules": [
159
283
  "bits",
284
+ "admit",
160
285
  "frame",
161
286
  "prefix",
287
+ "kernel-hooks",
162
288
  "modular",
289
+ "lossless-coding",
163
290
  "lossless",
164
291
  "squeeze",
165
292
  "lossy",
166
293
  "weighted",
167
- "admit",
294
+ "local",
295
+ "rct-search",
296
+ "effort-job",
168
297
  "effort"
169
298
  ],
170
299
  "alone": {
171
- "bytes": 25229,
172
- "gzip": 10606,
173
- "brotli": 9351,
174
- "sha256": "895c80728398f0f98e9154f9788cb9fbaa46a00d26d5518e3b8186bfe8bec7c0",
300
+ "bytes": 33584,
301
+ "gzip": 13793,
302
+ "brotli": 12173,
303
+ "sha256": "b47c702570a63a9b56c54c3557dd751aa89fe8680b3bbabf31afdd03a01f7d7d",
304
+ "compress": {
305
+ "passes": 2,
306
+ "inline": 1,
307
+ "module": true
308
+ }
309
+ },
310
+ "added": {
311
+ "bytes": 12258,
312
+ "gzip": 4522,
313
+ "brotli": 3940
314
+ },
315
+ "provedByteCases": 98
316
+ },
317
+ {
318
+ "entry": "./wasm",
319
+ "module": "wasm",
320
+ "file": "wasm.min.mjs",
321
+ "exports": [
322
+ "LIMITS",
323
+ "configureKernels",
324
+ "encode",
325
+ "encodeSteps",
326
+ "kernelMode"
327
+ ],
328
+ "modules": [
329
+ "kernel-hooks",
330
+ "bits",
331
+ "kernels-bytes",
332
+ "kernels",
333
+ "admit",
334
+ "frame",
335
+ "prefix",
336
+ "modular",
337
+ "lossless-coding",
338
+ "lossless",
339
+ "squeeze",
340
+ "lossy",
341
+ "weighted",
342
+ "local",
343
+ "rct-search",
344
+ "effort-job",
345
+ "effort",
346
+ "wasm"
347
+ ],
348
+ "alone": {
349
+ "bytes": 43535,
350
+ "gzip": 18533,
351
+ "brotli": 16239,
352
+ "sha256": "9ad98f7a23a148ed24c98d43dd3b0d968bfc4ad0bdf40d44b6c0cc5ffacdb683",
175
353
  "compress": {
176
354
  "passes": 2,
177
355
  "hoist_funs": true,
@@ -180,30 +358,33 @@
180
358
  }
181
359
  },
182
360
  "added": {
183
- "bytes": 5734,
184
- "gzip": 2131,
185
- "brotli": 1857
361
+ "bytes": 22209,
362
+ "gzip": 9262,
363
+ "brotli": 8006
186
364
  },
187
- "provedByteCases": 94
365
+ "provedByteCases": 98
188
366
  }
189
367
  ],
190
368
  "all": {
191
369
  "exports": [
192
370
  "LIMITS",
371
+ "configureKernels",
193
372
  "encode",
194
373
  "encodePhoto",
195
374
  "encodePhotoSteps",
196
375
  "encodeSteps",
376
+ "kernelMode",
197
377
  "transcode",
198
378
  "transcodeSteps"
199
379
  ],
200
380
  "doors": [
201
381
  "./effort",
202
- "./jpeg",
203
- "./photo"
382
+ "./jpeg-ans",
383
+ "./photo-ans",
384
+ "./wasm"
204
385
  ],
205
- "bytes": 47499,
206
- "gzip": 19228,
207
- "brotli": 16977
386
+ "bytes": 74625,
387
+ "gzip": 30285,
388
+ "brotli": 26433
208
389
  }
209
390
  }