big updat:

- update dependencies
- add webp support and webp conversion for profile images
This commit is contained in:
olcxja 2026-07-02 22:40:46 +02:00
commit 95aaaa69ea
244 changed files with 121382 additions and 86 deletions

31
node_modules/super-image-cropper/dist/lib/cropper.d.ts generated vendored Normal file
View file

@ -0,0 +1,31 @@
import { ICommonCropOptions } from '../index';
import type { IParsedFrameInfo } from './decoder';
export interface IFrameCropperProps {
commonCropOptions: ICommonCropOptions;
}
export declare class FrameCropper {
private frames;
private parsedFrames;
private commonCropOptions;
private convertorCanvas;
private containerCanvas;
private convertCtx;
private containerCtx;
private cropperJsOpts;
private offsetX;
private offsetY;
private containerCenterX;
private containerCenterY;
private resultFrames;
constructor(props: IFrameCropperProps);
init({ commonCropOptions }: IFrameCropperProps): void;
cropGif(parsedFrameInfo: IParsedFrameInfo): Promise<ImageData[]>;
cropStaticImage(canvasImageContainer: HTMLCanvasElement): ImageData;
private transformFrame;
private drawImgDataToCanvas;
private ifDebugRun;
private renderEachFrame;
private setupCanvas;
private setCanvasWH;
private frameToImgData;
}

2
node_modules/super-image-cropper/dist/lib/cropper.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
"use strict";exports.FrameCropper=class{frames;parsedFrames;commonCropOptions;convertorCanvas;containerCanvas;convertCtx;containerCtx;cropperJsOpts;offsetX=0;offsetY=0;containerCenterX=0;containerCenterY=0;resultFrames=[];constructor(t){this.init(t)}init({commonCropOptions:t}){this.commonCropOptions=t,this.cropperJsOpts=t.cropperJsOpts,this.resultFrames=[],this.containerCanvas&&this.convertorCanvas||this.setupCanvas(),this.setCanvasWH()}async cropGif(t){const{frames:s,parsedFrames:e}=t;this.frames=s,this.parsedFrames=e;let a=0;for(;a<this.frames.length;){const t=this.frames[a];if(1!==this.parsedFrames[a].disposalType&&this.containerCtx.clearRect(0,0,this.containerCanvas.width,this.containerCanvas.height),this.containerCtx.globalCompositeOperation&&this.cropperJsOpts?.background&&(this.containerCtx.fillStyle=this.cropperJsOpts?.background||"",this.containerCtx.globalCompositeOperation="destination-over",this.containerCtx.fillRect(0,0,this.containerCanvas.width,this.containerCanvas.height),this.containerCtx.globalCompositeOperation="source-over"),!t)continue;const s=this.transformFrame(this.drawImgDataToCanvas(t,a));this.resultFrames.push(s),this.ifDebugRun(s,a),a++}return this.resultFrames}cropStaticImage(t){return this.transformFrame(t)}transformFrame(t){this.containerCtx.save(),this.containerCtx.translate(this.containerCenterX,this.containerCenterY),this.containerCtx.rotate(this.cropperJsOpts.rotate*Math.PI/180),this.containerCtx.scale(this.cropperJsOpts.scaleX,this.cropperJsOpts.scaleY),this.containerCtx.drawImage(t,-this.convertorCanvas.width/2,-this.convertorCanvas.height/2),this.containerCtx.restore();return this.containerCtx.getImageData(1*this.cropperJsOpts.x+this.offsetX,1*this.cropperJsOpts.y+this.offsetY,this.cropperJsOpts.width,this.cropperJsOpts.height)}drawImgDataToCanvas(t,s){const e=this.parsedFrames[s]?.dims;return this.convertCtx.clearRect(0,0,this.convertorCanvas.width,this.convertorCanvas.height),this.convertCtx.putImageData(t,e.left,e.top),this.convertorCanvas}ifDebugRun(t,s){location.search.includes("isCropDebug=true")&&s&&this.renderEachFrame(t,s)}renderEachFrame(t,s){const e=this.parsedFrames[s]?.dims,a=document.createElement("canvas");a.width=this.convertorCanvas.width,a.height=this.convertorCanvas.height;const r=a.getContext("2d");r&&(r?.putImageData(t,e.left,e.top),r.fillStyle="red",r.strokeStyle="blue",r.lineWidth=5,r.save(),r.beginPath(),r.font="70px orbitron",r.fillText(String(s),10,50),r.restore(),r.closePath(),document.body.appendChild(a))}setupCanvas(){const t=this.containerCanvas=document.createElement("canvas"),s=this.convertorCanvas=document.createElement("canvas");t.className="containerCanvas",s.className="convertorCanvas",t.style.display="none",s.style.display="none";const e=t.getContext("2d",{willReadFrequently:!0}),a=s.getContext("2d");e&&(this.containerCtx=e),a&&(this.convertCtx=a),document.body.appendChild(s),document.body.appendChild(t)}setCanvasWH(){Math.PI,this.cropperJsOpts.rotate;const t=this.commonCropOptions.imageData,s=t.naturalWidth,e=t.naturalHeight;this.offsetX=-Math.min(this.cropperJsOpts.x,0),this.offsetY=-Math.min(this.cropperJsOpts.y,0),this.containerCenterX=this.offsetX+s/2,this.containerCenterY=this.offsetY+e/2,this.containerCanvas.width=Math.max(this.offsetX+s,this.offsetX+this.cropperJsOpts.width,this.cropperJsOpts.x+this.cropperJsOpts.width),this.containerCanvas.height=Math.max(this.offsetY+e,this.offsetY+this.cropperJsOpts.height,this.cropperJsOpts.y+this.cropperJsOpts.height),this.convertorCanvas.width=t.naturalWidth,this.convertorCanvas.height=t.naturalHeight,this.containerCtx.clearRect(0,0,this.containerCanvas.width,this.containerCanvas.height),this.convertCtx.clearRect(0,0,this.convertorCanvas.width,this.convertorCanvas.height)}frameToImgData(t,s){if(!t)return;const e=s.pixels.length,a=t.createImageData(s.dims.width,s.dims.height),r=a.data;for(let t=0;t<e;t++){const e=4*t,a=s.pixels[t],n=s.colorTable[a];r[e]=n[0],r[e+1]=n[1],r[e+2]=n[2],r[e+3]=a!==s.transparentIndex?255:0}return a}};
//# sourceMappingURL=cropper.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"cropper.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}

38
node_modules/super-image-cropper/dist/lib/decoder.d.ts generated vendored Normal file
View file

@ -0,0 +1,38 @@
import { ParsedGif, ParsedFrame } from 'gifuct-js';
import { GetArrTypeUnion } from './helper';
export type IFrames = Pick<ParsedGif, 'frames'>['frames'];
export type IFrame = GetArrTypeUnion<IFrames>;
export interface IParsedFrameInfo {
frames: ImageData[];
delays: number[];
parsedFrames: ParsedFrame[];
}
export declare class Decoder {
private url;
private parseGIF;
constructor(url: string);
decode(): Promise<ParsedGif>;
decompressFrames(): Promise<IParsedFrameInfo>;
/**
* Validates and fixes frames that have lost pixels.
* @param gif
*/
private validateAndFixFrame;
/**
* Generates ImageData objects from parsed frames.
* @param frames
*/
private generate2ImageData;
/**
* Generates ImageData objects from frames with modified pixels.
* @param frames
*/
private generate2ImageDataWithPixelsModified;
/**
* @param {string} url
* @returns
*/
private fetchImageData;
private handlePixels;
private putPixels;
}

2
node_modules/super-image-cropper/dist/lib/decoder.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
"use strict";var e=require("gifuct-js");exports.Decoder=class{url;parseGIF;constructor(e){this.url=e}async decode(){const t=await this.fetchImageData(this.url);return this.parseGIF=e.parseGIF(t),this.validateAndFixFrame(this.parseGIF),this.parseGIF}async decompressFrames(){this.parseGIF||await this.decode();const t=await e.decompressFrames(this.parseGIF,!0);return{frames:this.generate2ImageData(t),delays:t.map((e=>e.delay)),parsedFrames:t}}validateAndFixFrame=e=>{let t=null;for(const r of e.frames)t=r.gce?r.gce:t,"image"in r&&!("gce"in r)&&(r.gce=t)};generate2ImageData(e){return e.map((e=>{const t=e?.dims,r=new ImageData(t.width,t.height);return r.data.set(e.patch),r}))}generate2ImageDataWithPixelsModified(e,t){return e.map(((e,r)=>{t[r];const a=this.parseGIF.lsd,s=new ImageData(a.width,a.height);return s.data.set(new Uint8ClampedArray(e)),s}))}fetchImageData(e){return new Promise(((t,r)=>{const a=new XMLHttpRequest;a.open("GET",e,!0),a.responseType="arraybuffer",a.onload=e=>{if(!(e.target instanceof XMLHttpRequest))return;if(200!==e.target.status&&304!==e.target.status)return void r("Status Error: "+e.target.status);let a=e.target.response;a.toString().indexOf("ArrayBuffer")>0&&(a=new Uint8Array(a)),t(a)},a.onerror=e=>{r(e)},a.send()}))}handlePixels(e){const t=this.parseGIF.lsd,r=t.width*t.height*4,a=[];for(let s=0;s<e.length;++s){const i=e[s],n=0===s||2===e[s-1].disposalType?new Uint8ClampedArray(r):a[s-1].slice();a.push(this.putPixels(n,i,t))}return a}putPixels(e,t,r){if(!t.dims)return e;const{width:a,height:s,top:i,left:n}=t.dims,o=i*r.width+n;for(let i=0;i<s;i++)for(let s=0;s<a;s++){const n=i*a+s,d=t.pixels[n],h=o+i*r.width+s,p=t.colorTable[d]||[0,0,0];d===t.transparentIndex?(e[4*h]=0,e[4*h+1]=0,e[4*h+2]=0,e[4*h+3]=0):(e[4*h]=p[0],e[4*h+1]=p[1],e[4*h+2]=p[2],e[4*h+3]=255)}return e}};
//# sourceMappingURL=decoder.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"decoder.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}

20
node_modules/super-image-cropper/dist/lib/helper.d.ts generated vendored Normal file
View file

@ -0,0 +1,20 @@
import { IImageData } from '../index';
export type GetArrTypeUnion<T extends any[]> = T extends (infer I)[] ? I : never;
export type IImageLoadData = {
imageInstance: HTMLImageElement;
data: Event;
imageType: IImageTypeInfo | null;
};
export interface IImageTypeInfo {
ext: string;
mime: string;
}
export interface IGetImageParams {
src?: string;
crossOrigin?: '' | 'anonymous' | 'use-credentials';
}
export declare const getImageInfo: (params: IGetImageParams) => Promise<IImageData>;
export declare const getImageType: (imageBufferData: ArrayBuffer) => Promise<IImageTypeInfo | null>;
export declare const loadImage: (params: IGetImageParams) => Promise<IImageLoadData>;
export declare const transformImageData2ArrayBuffer: (image: HTMLImageElement) => ArrayBufferLike;
export declare const getImageBufferFromRemote: (url?: string) => Promise<ArrayBuffer>;

2
node_modules/super-image-cropper/dist/lib/helper.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
"use strict";var e=require("image-type");const t=async t=>e(new Uint8Array(t)),a=async e=>{const{src:a="",crossOrigin:n}=e;return{...await new Promise(((e,t)=>{const r=new Image;void 0!==n&&(r.crossOrigin=n),r.onload=async t=>{e({imageInstance:r,data:t})},r.src=a,r.onerror=t})),imageType:await t(await r(a))}},r=(e="")=>new Promise(((t,a)=>{const r=new XMLHttpRequest;r.open("GET",e),r.responseType="arraybuffer",r.onload=()=>{t(r.response)},r.onerror=a,r.send()}));exports.getImageBufferFromRemote=r,exports.getImageInfo=async e=>{const{src:t=""}=e;if(!t)return{width:0,height:0,naturalWidth:0,naturalHeight:0};const{imageInstance:r}=await a(e);return{width:r.width,height:r.height,naturalWidth:r.naturalWidth,naturalHeight:r.naturalHeight}},exports.getImageType=t,exports.loadImage=a;
//# sourceMappingURL=helper.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"helper.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}

View file

@ -0,0 +1,19 @@
import { ICommonCropOptions, ICropperOptions } from '../index';
import { IOutputTypeUnion } from '../index';
export interface IFrameCropperProps {
commonCropOptions: ICommonCropOptions;
frames: ImageData[];
frameDelays: number[];
gifJsOptions?: ICropperOptions['gifJsOptions'];
outputType?: IOutputTypeUnion;
}
export declare class SyntheticGIF {
private cropperJsOpts;
private frames;
private frameDelays;
private gifJsOptions;
private outputType;
constructor({ frames, commonCropOptions, frameDelays, gifJsOptions, outputType }: IFrameCropperProps);
bootstrap(): Promise<string | Blob>;
private convertBlob2Base64;
}

View file

@ -0,0 +1,2 @@
"use strict";var e=require("gif-build-worker-js"),t=require("gif.js"),s=require("../index.js");exports.SyntheticGIF=class{cropperJsOpts;frames;frameDelays;gifJsOptions;outputType;constructor({frames:e,commonCropOptions:t,frameDelays:s,gifJsOptions:r={},outputType:i}){this.cropperJsOpts=t.cropperJsOpts,this.frames=e,this.frameDelays=s,this.gifJsOptions=r,this.outputType=i}bootstrap(){return new Promise(((r,i)=>{const o=e.transformToUrl(),p=Object.assign({workers:2,quality:10,workerScript:o,width:this.cropperJsOpts.width,height:this.cropperJsOpts.height,transparent:"transparent"},this.gifJsOptions||{}),a=new t(p);a.on("finished",(e=>{if(this.outputType===s.OutputType.BLOB)r(e);else if(this.outputType===s.OutputType.BASE64)r(this.convertBlob2Base64(e));else{const t=window.URL.createObjectURL(e);r(t)}})),this.frames.forEach(((e,t)=>{a.addFrame(e,{delay:this.frameDelays[t],copy:!0})})),a.render()}))}convertBlob2Base64(e){return new Promise(((t,s)=>{const r=new FileReader;r.onload=function(e){t(e?.target?.result)},r.onerror=e=>{s(e)},r.readAsDataURL(e)}))}};
//# sourceMappingURL=synthetic-gif.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"synthetic-gif.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}