mirror of
https://github.com/skillbert/rsmv.git
synced 2025-12-23 21:47:48 -05:00
dependency ffixes. properly make canvas/sharp optional. fix ts typings
This commit is contained in:
10825
package-lock.json
generated
10825
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,6 @@
|
|||||||
"autobind-decorator": "^2.4.0",
|
"autobind-decorator": "^2.4.0",
|
||||||
"browserify-zlib": "^0.2.0",
|
"browserify-zlib": "^0.2.0",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"canvas": "^2.10.2",
|
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"copy-webpack-plugin": "^10.2.4",
|
"copy-webpack-plugin": "^10.2.4",
|
||||||
"electron": "^26.3.0",
|
"electron": "^26.3.0",
|
||||||
@@ -53,7 +52,6 @@
|
|||||||
"react": "^18.1.0",
|
"react": "^18.1.0",
|
||||||
"react-dom": "^18.1.0",
|
"react-dom": "^18.1.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"sharp": "^0.33.2",
|
|
||||||
"sql.js": "file:./src/libs/sqljsfork",
|
"sql.js": "file:./src/libs/sqljsfork",
|
||||||
"sqlite3": "^5.0.8",
|
"sqlite3": "^5.0.8",
|
||||||
"stream-browserify": "^3.0.0",
|
"stream-browserify": "^3.0.0",
|
||||||
|
|||||||
@@ -41,17 +41,14 @@ export async function pixelsToImageFile(imgdata: ImageData, format: "png" | "web
|
|||||||
|
|
||||||
|
|
||||||
let warnedstripalpha = false;
|
let warnedstripalpha = false;
|
||||||
declare global {
|
|
||||||
const ImageDecoder: any;
|
|
||||||
interface ImageDecoder { }
|
|
||||||
}
|
|
||||||
export async function fileToImageData(file: Uint8Array, mimetype: "image/png" | "image/jpg", stripAlpha: boolean) {
|
export async function fileToImageData(file: Uint8Array, mimetype: "image/png" | "image/jpg", stripAlpha: boolean) {
|
||||||
if (typeof ImageDecoder != "undefined") {
|
if (typeof ImageDecoder != "undefined") {
|
||||||
let decoder = new ImageDecoder({ data: file, type: mimetype, premultiplyAlpha: (stripAlpha ? "none" : "default"), colorSpaceConversion: "none" });
|
//typescript claims premultiplyAlpha option doesn't exist
|
||||||
|
let decoder = new ImageDecoder({ data: file, type: mimetype, premultiplyAlpha: (stripAlpha ? "none" : "default"), colorSpaceConversion: "none" } as any);
|
||||||
let frame = await decoder.decode();
|
let frame = await decoder.decode();
|
||||||
let pixels = new Uint8Array(frame.image.allocationSize());
|
let pixels = new Uint8Array(frame.image.allocationSize());
|
||||||
frame.image.copyTo(pixels);
|
frame.image.copyTo(pixels);
|
||||||
let pixelcount = frame.image.visibleRect.width * frame.image.visibleRect.height;
|
let pixelcount = frame.image.visibleRect!.width * frame.image.visibleRect!.height;
|
||||||
if (frame.image.format == "BGRX" || frame.image.format == "RGBX") {
|
if (frame.image.format == "BGRX" || frame.image.format == "RGBX") {
|
||||||
stripAlpha = true;
|
stripAlpha = true;
|
||||||
}
|
}
|
||||||
@@ -72,7 +69,7 @@ export async function fileToImageData(file: Uint8Array, mimetype: "image/png" |
|
|||||||
} else {
|
} else {
|
||||||
throw new Error("unexpected image format");
|
throw new Error("unexpected image format");
|
||||||
}
|
}
|
||||||
return makeImageData(pixels, frame.image.visibleRect.width, frame.image.visibleRect.height);
|
return makeImageData(pixels, frame.image.visibleRect!.width, frame.image.visibleRect!.height);
|
||||||
} else if (typeof HTMLCanvasElement != "undefined") {
|
} else if (typeof HTMLCanvasElement != "undefined") {
|
||||||
if (stripAlpha && !warnedstripalpha) {
|
if (stripAlpha && !warnedstripalpha) {
|
||||||
console.warn("can not strip alpha in browser context that does not support ImageDecoder");
|
console.warn("can not strip alpha in browser context that does not support ImageDecoder");
|
||||||
|
|||||||
@@ -995,7 +995,7 @@ const rendermodeHeight: RenderMode<"height"> = function (engine, config, cnf, de
|
|||||||
async run2d(chunks) {
|
async run2d(chunks) {
|
||||||
//TODO what to do with classic 48x48 chunks?
|
//TODO what to do with classic 48x48 chunks?
|
||||||
let file = chunks[0].grid.getHeightCollisionFile(singlerect.x * 64, singlerect.z * 64, thiscnf.level, 64, 64);
|
let file = chunks[0].grid.getHeightCollisionFile(singlerect.x * 64, singlerect.z * 64, thiscnf.level, 64, 64);
|
||||||
let buf = Buffer.from(file.buffer, file.byteOffset, file.byteLength);
|
let buf: Buffer = Buffer.from(file.buffer, file.byteOffset, file.byteLength);
|
||||||
if (thiscnf.usegzip) {
|
if (thiscnf.usegzip) {
|
||||||
buf = zlib.gzipSync(buf);
|
buf = zlib.gzipSync(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ async function mipCanvas(render: MapRender, files: (MipFile | null)[], format: "
|
|||||||
}
|
}
|
||||||
// imagedecoder API doesn't support svg
|
// imagedecoder API doesn't support svg
|
||||||
if (mimetype != "image/svg+xml" && typeof ImageDecoder != "undefined") {
|
if (mimetype != "image/svg+xml" && typeof ImageDecoder != "undefined") {
|
||||||
let decoder = new ImageDecoder({ data: res.body, type: mimetype, desiredWidth: subtilesize, desiredHeight: subtilesize });
|
//typescript types seem broken here? these properties are not depricated either
|
||||||
|
let decoder = new ImageDecoder({ data: res.body, type: mimetype, desiredWidth: subtilesize, desiredHeight: subtilesize } as any);
|
||||||
img = (await decoder.decode()).image;
|
img = (await decoder.decode()).image;
|
||||||
} else {
|
} else {
|
||||||
let blobsrc = URL.createObjectURL(await res.blob());
|
let blobsrc = URL.createObjectURL(await res.blob());
|
||||||
|
|||||||
Reference in New Issue
Block a user