skinview-utils
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -1,31 +0,20 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
export function loadImage(source) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const image = document.createElement("img"); | ||
return new Promise((resolve, reject) => { | ||
image.onload = () => resolve(image); | ||
image.onerror = reject; | ||
if (typeof source === "string") { | ||
image.src = source; | ||
export async function loadImage(source) { | ||
const image = document.createElement("img"); | ||
return new Promise((resolve, reject) => { | ||
image.onload = () => resolve(image); | ||
image.onerror = reject; | ||
if (typeof source === "string") { | ||
image.src = source; | ||
} | ||
else { | ||
if (source.crossOrigin !== undefined) { | ||
image.crossOrigin = source.crossOrigin; | ||
} | ||
else { | ||
if (source.crossOrigin !== undefined) { | ||
image.crossOrigin = source.crossOrigin; | ||
} | ||
if (source.referrerPolicy !== undefined) { | ||
image.referrerPolicy = source.referrerPolicy; | ||
} | ||
image.src = source.src; | ||
if (source.referrerPolicy !== undefined) { | ||
image.referrerPolicy = source.referrerPolicy; | ||
} | ||
}); | ||
image.src = source.src; | ||
} | ||
}); | ||
} | ||
//# sourceMappingURL=load-image.js.map |
import { RemoteImage } from "./load-image.js"; | ||
import { ModelType, TextureCanvas, TextureSource } from "./types.js"; | ||
export declare function applyMixins(derivedCtor: any, baseCtors: any[]): void; | ||
export declare function isTextureSource(value: TextureSource | RemoteImage): value is TextureSource; | ||
export declare abstract class SkinContainer<T> { | ||
@@ -5,0 +6,0 @@ protected abstract skinLoaded(model: ModelType, options?: T): void; |
@@ -1,13 +0,5 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import { loadImage } from "./load-image.js"; | ||
import { inferModelType, loadCapeToCanvas, loadSkinToCanvas } from "./process.js"; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// https://www.typescriptlang.org/docs/handbook/mixins.html | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any | ||
export function applyMixins(derivedCtor, baseCtors) { | ||
@@ -20,3 +12,3 @@ baseCtors.forEach(baseCtor => { | ||
} | ||
function isTextureSource(value) { | ||
export function isTextureSource(value) { | ||
return value instanceof EventTarget || value instanceof ImageBitmap; | ||
@@ -35,3 +27,3 @@ } | ||
else { | ||
return (() => __awaiter(this, void 0, void 0, function* () { return this.loadSkin(yield loadImage(source), model, options); }))(); | ||
return (async () => this.loadSkin(await loadImage(source), model, options))(); | ||
} | ||
@@ -50,3 +42,3 @@ } | ||
else { | ||
return (() => __awaiter(this, void 0, void 0, function* () { return this.loadCape(yield loadImage(source), options); }))(); | ||
return (async () => this.loadCape(await loadImage(source), options))(); | ||
} | ||
@@ -53,0 +45,0 @@ } |
{ | ||
"name": "skinview-utils", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Utilities for working with Minecraft skins", | ||
@@ -14,21 +14,21 @@ "type": "module", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^12.0.0", | ||
"@rollup/plugin-commonjs": "^13.0.0", | ||
"@rollup/plugin-image": "^2.0.5", | ||
"@rollup/plugin-node-resolve": "^8.0.0", | ||
"@rollup/plugin-node-resolve": "^8.0.1", | ||
"@rollup/plugin-typescript": "^4.1.2", | ||
"@types/chai": "^4.2.11", | ||
"@types/mocha": "^7.0.2", | ||
"@typescript-eslint/eslint-plugin": "^3.0.0", | ||
"@typescript-eslint/parser": "^3.0.0", | ||
"@typescript-eslint/eslint-plugin": "^3.2.0", | ||
"@typescript-eslint/parser": "^3.2.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.1.0", | ||
"karma": "^5.0.9", | ||
"eslint": "^7.2.0", | ||
"karma": "^5.1.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-mocha": "^2.0.1", | ||
"karma-rollup-preprocessor": "^7.0.5", | ||
"mocha": "^7.2.0", | ||
"puppeteer": "^3.1.0", | ||
"mocha": "^8.0.1", | ||
"puppeteer": "^3.3.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.10.9", | ||
"typescript": "^3.9.3" | ||
"rollup": "^2.16.1", | ||
"typescript": "^3.9.5" | ||
}, | ||
@@ -35,0 +35,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25505
276