Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@beenotung/tslib

Package Overview
Dependencies
Maintainers
0
Versions
398
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@beenotung/tslib - npm Package Compare versions

Comparing version 23.9.0 to 23.10.0

3

image.d.ts

@@ -7,2 +7,5 @@ import { Result } from './result';

export declare function imageToBase64(img: HTMLImageElement, width: number, height: number): string;
export declare function convertHeicFile(file: File): Promise<File>;
/** @alias convertHeicFile */
export declare const convertHeifFile: typeof convertHeicFile;
export declare function base64ToImage(data: string): Promise<HTMLImageElement>;

@@ -9,0 +12,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResizeTypes = void 0;
exports.ResizeTypes = exports.convertHeifFile = void 0;
exports.imageToCanvas = imageToCanvas;
exports.imageToBase64 = imageToBase64;
exports.convertHeicFile = convertHeicFile;
exports.base64ToImage = base64ToImage;

@@ -46,3 +47,43 @@ exports.checkBase64ImagePrefix = checkBase64ImagePrefix;

}
async function convertHeicFile(file) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const heic2any = require('heic2any');
const blob = await heic2any({ blob: file });
const blobs = Array.isArray(blob) ? blob : [blob];
const type = blobs[0].type;
let filename = file.name;
{
const ext = type.split('/')[1].split(';')[0];
const parts = filename.split('.');
parts.pop();
parts.push(ext);
filename = parts.join('.');
}
file = new File(blobs, filename, { type, lastModified: file.lastModified });
return file;
}
/** @alias convertHeicFile */
exports.convertHeifFile = convertHeicFile;
function is_heic2any_installed() {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('heic2any');
return true;
}
catch (error) {
// heic2any is not installed
return false;
}
}
async function base64ToImage(data) {
if (data.startsWith('data:image/heic') ||
data.startsWith('data:image/heif')) {
if (is_heic2any_installed()) {
const res = await fetch(data);
const blob = await res.blob();
const file = new File([blob], 'image.heic', { type: 'image/heic' });
return toImage(file);
}
console.warn('heic2any is not installed, skip format conversion');
}
return new Promise((resolve, reject) => {

@@ -390,2 +431,8 @@ const image = new Image();

if (image instanceof File) {
if (image.type == 'image/heic' || image.type == 'image/heif') {
if (is_heic2any_installed()) {
return convertHeicFile(image).then(file => toImage(file));
}
console.warn('heic2any is not installed, skip format conversion');
}
return (0, file_1.fileToBase64String)(image).then(base64 => toImage(base64));

@@ -392,0 +439,0 @@ }

7

package.json
{
"name": "@beenotung/tslib",
"version": "23.9.0",
"version": "23.10.0",
"description": "utils library in Typescript",

@@ -20,6 +20,6 @@ "keywords": [

},
"homepage": "https://github.com/beenotung/tslib#readme",
"bugs": {
"url": "https://github.com/beenotung/tslib/issues"
},
"homepage": "https://github.com/beenotung/tslib#readme",
"dependencies": {

@@ -30,3 +30,6 @@ "cache-dir.ts": "^1.1.0",

"tslib": "^2.6.3"
},
"optionalDependencies": {
"heic2any": "^0.0.4"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc