Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@leafer/image

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafer/image - npm Package Compare versions

Comparing version
2.0.1
to
2.0.2
+10
src/LeaferFilm.ts
import { ILeaferFilm } from '@leafer/interface'
import { LeaferImage } from './LeaferImage'
export class LeaferFilm extends LeaferImage implements ILeaferFilm {
public get tag() { return 'Film' }
}
import { ILeaferVideo } from '@leafer/interface'
import { LeaferImage } from './LeaferImage'
export class LeaferVideo extends LeaferImage implements ILeaferVideo {
public get tag() { return 'Video' }
}
+7
-7
{
"name": "@leafer/image",
"version": "2.0.1",
"version": "2.0.2",
"description": "@leafer/image",

@@ -25,11 +25,11 @@ "author": "Chao (Leafer) Wan",

"dependencies": {
"@leafer/task": "2.0.1",
"@leafer/file": "2.0.1",
"@leafer/data": "2.0.1",
"@leafer/math": "2.0.1",
"@leafer/platform": "2.0.1"
"@leafer/task": "2.0.2",
"@leafer/file": "2.0.2",
"@leafer/data": "2.0.2",
"@leafer/math": "2.0.2",
"@leafer/platform": "2.0.2"
},
"devDependencies": {
"@leafer/interface": "2.0.1"
"@leafer/interface": "2.0.2"
}
}

@@ -1,5 +0,4 @@

import { IImageManager, ILeaferImageConfig, ILeaferImage, IExportFileType } from '@leafer/interface'
import { IImageManager, ILeaferImageConfig, ILeaferImage, IExportFileType, IMultimediaType } from '@leafer/interface'
import { Creator, Platform } from '@leafer/platform'
import { FileHelper, Resource } from '@leafer/file'
import { TaskProcessor } from '@leafer/task'

@@ -13,7 +12,7 @@

patternTasker: new TaskProcessor({ parallel: 1 }),
patternTasker: Resource.queue, // 全局按顺序执行的任务队列,防止阻塞主线程
get(config: ILeaferImageConfig): ILeaferImage {
get(config: ILeaferImageConfig, type?: IMultimediaType): ILeaferImage {
let image: ILeaferImage = Resource.get(config.url)
if (!image) Resource.set(config.url, image = Creator.image(config))
if (!image) Resource.set(config.url, image = type === 'film' ? Creator.film(config) : Creator.image(config))
image.use++

@@ -61,3 +60,3 @@ return image

if (url.startsWith('data:')) {
if (url.startsWith('data:' + FileHelper.mineType(format))) return true
if (url.startsWith('data:' + FileHelper.mimeType(format))) return true
} else {

@@ -64,0 +63,0 @@ if (url.includes('.' + format) || url.includes('.' + FileHelper.upperCaseTypeMap[format])) return true

export { LeaferImage } from './LeaferImage'
export { LeaferFilm } from './LeaferFilm'
export { LeaferVideo } from './LeaferVideo'
export { ImageManager } from './ImageManager'

@@ -1,2 +0,2 @@

import { ILeaferImage, ILeaferImageConfig, IFunction, IObject, InnerId, IMatrixData, ICanvasPattern, ILeaferImageCacheCanvas, ILeaferImagePatternPaint, ILeaferImageLevel, ISizeData, IImageCrossOrigin, IImageLOD, IInterlace } from '@leafer/interface'
import { ILeaferImage, ILeaferImageConfig, IFunction, IObject, InnerId, ILeaf, IMatrixData, ICanvasPattern, ILeaferImageCacheCanvas, ILeaferImagePatternPaint, ILeaferImageLevel, ISizeData, IImageCrossOrigin, IImageLOD, IInterlace } from '@leafer/interface'
import { Platform } from '@leafer/platform'

@@ -15,2 +15,4 @@ import { Resource } from '@leafer/file'

public readonly innerId: InnerId
public get tag() { return 'Image' }
public get url() { return this.config.url }

@@ -57,3 +59,3 @@ public lod?: IImageLOD

this.loading = true
Resource.tasker.add(async () => await Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
Resource.tasker.add(async () => await Platform.origin['load' + this.tag as 'loadImage'](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
if (thumbSize) this.setThumbView(img)

@@ -132,2 +134,6 @@ this.setView(img)

public render(canvas: any, x: number, y: number, width: number, height: number, _leaf: ILeaf, _paint: any, _imageScaleX: number, _imageScaleY: number): void {
canvas.drawImage(this.view, x, y, width, height)
}
// need rewrite

@@ -134,0 +140,0 @@ public getLoadUrl(_thumbSize?: ISizeData): string { return this.url }

@@ -1,5 +0,6 @@

import { ILeaferImage, InnerId, IImageLOD, IImageCrossOrigin, IObject, ILeaferImageConfig, IFunction, ILeaferImageCacheCanvas, ISizeData, IInterlace, IMatrixData, ILeaferImagePatternPaint, ICanvasPattern, ILeaferImageLevel, IImageManager } from '@leafer/interface';
import { ILeaferImage, InnerId, IImageLOD, IImageCrossOrigin, IObject, ILeaferImageConfig, IFunction, ILeaferImageCacheCanvas, ISizeData, IInterlace, IMatrixData, ILeaferImagePatternPaint, ICanvasPattern, ILeaf, ILeaferImageLevel, ILeaferFilm, ILeaferVideo, IImageManager } from '@leafer/interface';
declare class LeaferImage implements ILeaferImage {
readonly innerId: InnerId;
get tag(): string;
get url(): string;

@@ -29,2 +30,3 @@ lod?: IImageLOD;

getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern;
render(canvas: any, x: number, y: number, width: number, height: number, _leaf: ILeaf, _paint: any, _imageScaleX: number, _imageScaleY: number): void;
getLoadUrl(_thumbSize?: ISizeData): string;

@@ -39,4 +41,12 @@ setThumbView(_view: number): void;

declare class LeaferFilm extends LeaferImage implements ILeaferFilm {
get tag(): string;
}
declare class LeaferVideo extends LeaferImage implements ILeaferVideo {
get tag(): string;
}
declare const ImageManager: IImageManager;
export { ImageManager, LeaferImage };
export { ImageManager, LeaferFilm, LeaferImage, LeaferVideo };