Comparing version 1.1.3 to 1.1.4
@@ -0,1 +1,2 @@ | ||
import { ImageSrcToWebpDataUrlOptions } from './utils/imageSrcToWebpDataUrl'; | ||
interface IFromImageArrayOptions { | ||
@@ -8,4 +9,5 @@ fps?: number; | ||
fromImageArray(images: string[], fps: number, outputAsArray?: boolean): Blob | Uint8Array; | ||
fromImageArrayWithOptions(images: string[], options?: IFromImageArrayOptions): Uint8Array | Blob; | ||
fromImageArrayWithOptions(images: string[], options?: IFromImageArrayOptions): Blob | Uint8Array; | ||
fixImageDataList(images: string[], options?: ImageSrcToWebpDataUrlOptions): Promise<string[]>; | ||
}; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
import { __assign } from "tslib"; | ||
import { __assign, __awaiter, __generator } from "tslib"; | ||
import toWebM from './utils/toWebM'; | ||
@@ -6,2 +6,3 @@ import parseWebP from './utils/parseWebP'; | ||
import { autoAtob } from './utils/adaptor'; | ||
import { imageSrcToWebpDataUrl } from './utils/imageSrcToWebpDataUrl'; | ||
var defaultFps = 1; | ||
@@ -12,6 +13,12 @@ export default { | ||
var curFps = fps || defaultFps; | ||
return toWebM(images.map(function (image) { | ||
var webp = parseWebP(parseRIFF(autoAtob(image.slice(23)))); | ||
var webpFrame = __assign(__assign({}, webp), { duration: 1000 / curFps }); | ||
return webpFrame; | ||
return toWebM(images.map(function (image, index) { | ||
try { | ||
var webp = parseWebP(parseRIFF(autoAtob(image.slice(23)))); | ||
var webpFrame = __assign(__assign({}, webp), { duration: 1000 / curFps }); | ||
return webpFrame; | ||
} | ||
catch (error) { | ||
console.error("Before toWebM Error, Image Index ".concat(index)); | ||
throw error; | ||
} | ||
}), curOutputAsArray); | ||
@@ -28,2 +35,27 @@ }, | ||
}, | ||
fixImageDataList: function (images, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result, _i, images_1, item, temp; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
result = []; | ||
_i = 0, images_1 = images; | ||
_a.label = 1; | ||
case 1: | ||
if (!(_i < images_1.length)) return [3 /*break*/, 4]; | ||
item = images_1[_i]; | ||
return [4 /*yield*/, imageSrcToWebpDataUrl(item, options)]; | ||
case 2: | ||
temp = _a.sent(); | ||
result.push(temp); | ||
_a.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [2 /*return*/, result]; | ||
} | ||
}); | ||
}); | ||
} | ||
}; |
@@ -8,2 +8,3 @@ "use strict"; | ||
var adaptor_1 = require("./utils/adaptor"); | ||
var imageSrcToWebpDataUrl_1 = require("./utils/imageSrcToWebpDataUrl"); | ||
var defaultFps = 1; | ||
@@ -14,6 +15,12 @@ exports.default = { | ||
var curFps = fps || defaultFps; | ||
return (0, toWebM_1.default)(images.map(function (image) { | ||
var webp = (0, parseWebP_1.default)((0, parseRIFF2_1.default)((0, adaptor_1.autoAtob)(image.slice(23)))); | ||
var webpFrame = tslib_1.__assign(tslib_1.__assign({}, webp), { duration: 1000 / curFps }); | ||
return webpFrame; | ||
return (0, toWebM_1.default)(images.map(function (image, index) { | ||
try { | ||
var webp = (0, parseWebP_1.default)((0, parseRIFF2_1.default)((0, adaptor_1.autoAtob)(image.slice(23)))); | ||
var webpFrame = tslib_1.__assign(tslib_1.__assign({}, webp), { duration: 1000 / curFps }); | ||
return webpFrame; | ||
} | ||
catch (error) { | ||
console.error("Before toWebM Error, Image Index ".concat(index)); | ||
throw error; | ||
} | ||
}), curOutputAsArray); | ||
@@ -30,2 +37,27 @@ }, | ||
}, | ||
fixImageDataList: function (images, options) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var result, _i, images_1, item, temp; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
result = []; | ||
_i = 0, images_1 = images; | ||
_a.label = 1; | ||
case 1: | ||
if (!(_i < images_1.length)) return [3 /*break*/, 4]; | ||
item = images_1[_i]; | ||
return [4 /*yield*/, (0, imageSrcToWebpDataUrl_1.imageSrcToWebpDataUrl)(item, options)]; | ||
case 2: | ||
temp = _a.sent(); | ||
result.push(temp); | ||
_a.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [2 /*return*/, result]; | ||
} | ||
}); | ||
}); | ||
} | ||
}; |
{ | ||
"name": "ts-whammy", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "A modern typescript version of whammy. You can use it to encode images(webp) to webm video.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,2 +6,3 @@ import toWebM from './utils/toWebM' | ||
import { IWebP, IWebPFrame } from './interfaces' | ||
import { ImageSrcToWebpDataUrlOptions, imageSrcToWebpDataUrl } from './utils/imageSrcToWebpDataUrl' | ||
@@ -20,12 +21,17 @@ interface IFromImageArrayOptions { | ||
const curFps = fps || defaultFps | ||
return toWebM(images.map(image => { | ||
const webp: IWebP = parseWebP(parseRIFF(autoAtob(image.slice(23)))) | ||
const webpFrame: IWebPFrame = { | ||
...webp, | ||
duration: 1000 / curFps, | ||
return toWebM(images.map((image, index) => { | ||
try { | ||
const webp: IWebP = parseWebP(parseRIFF(autoAtob(image.slice(23)))) | ||
const webpFrame: IWebPFrame = { | ||
...webp, | ||
duration: 1000 / curFps, | ||
} | ||
return webpFrame | ||
} catch (error) { | ||
console.error(`Before toWebM Error, Image Index ${index}`) | ||
throw error; | ||
} | ||
return webpFrame | ||
}), curOutputAsArray) | ||
}, | ||
fromImageArrayWithOptions(images: string[], options: IFromImageArrayOptions = {}) { | ||
fromImageArrayWithOptions(images: string[], options: IFromImageArrayOptions = {}): Blob | Uint8Array { | ||
const { fps, duration, outputAsArray } = options | ||
@@ -38,2 +44,10 @@ let curFps = fps || defaultFps | ||
}, | ||
async fixImageDataList(images: string[], options?: ImageSrcToWebpDataUrlOptions): Promise<string[]> { | ||
const result: string[] = [] | ||
for (const item of images) { | ||
const temp = await imageSrcToWebpDataUrl(item, options); | ||
result.push(temp) | ||
} | ||
return result | ||
} | ||
} |
@@ -14,3 +14,3 @@ { | ||
"jsx": "preserve", | ||
"jsxImportSource": "solid-js", | ||
"jsxImportSource": "react", | ||
"types": ["jest", "node"], | ||
@@ -17,0 +17,0 @@ "noEmit": true, |
78028
75
2125
123