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

mp-painter

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mp-painter - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

dist/utils/downloadFile.d.ts

21

dist/lib/paint-image.js

@@ -39,5 +39,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var downloadFile_1 = require("../utils/downloadFile");
function paintImage(image) {
return __awaiter(this, void 0, void 0, function () {
var left, top, width, height, _a, objectFit, contentSize;
var left, top, width, height, _a, objectFit, contentSize, src;
return __generator(this, function (_b) {

@@ -48,7 +49,4 @@ switch (_b.label) {

if (!(objectFit == "contain")) return [3 /*break*/, 2];
return [4 /*yield*/, calculateContainSize(image)
// console.timeEnd("calculateContainSize");
];
return [4 /*yield*/, calculateContainSize(image)];
case 1:
// console.time("calculateContainSize");
contentSize = _b.sent();

@@ -60,3 +58,14 @@ return [3 /*break*/, 3];

case 3:
this.ctx.drawImage(image.src, this.upx2px(contentSize.left), this.upx2px(contentSize.top), this.upx2px(contentSize.width), this.upx2px(contentSize.height));
if (!(this.platform == "mp-alipay" && !/^https:\/\/resource\//.test(image.src))) return [3 /*break*/, 5];
return [4 /*yield*/, downloadFile_1.downloadFileToLocal(image.src).catch(function (err) { return console.log("下载错误: ", err); })];
case 4:
src = (_b.sent()) || "";
return [3 /*break*/, 6];
case 5:
src = image.src;
_b.label = 6;
case 6:
if (src) {
this.ctx.drawImage(src, this.upx2px(contentSize.left), this.upx2px(contentSize.top), this.upx2px(contentSize.width), this.upx2px(contentSize.height));
}
return [2 /*return*/, {

@@ -63,0 +72,0 @@ width: width,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var swan;
var my;
var wx;
exports.PLATFORM = (function () {
// @ts-ignore
if (typeof swan == "object")
return "mp-baidu";
// @ts-ignore
if (typeof my == "object")
return "mp-alipay";
// @ts-ignore
if (typeof wx == "object")

@@ -12,0 +12,0 @@ return "mp-weixin";

{
"name": "mp-painter",
"version": "0.0.6",
"version": "0.0.7",
"description": "A declarative canvas lib using with mini-program, espacially with uniapp.",

@@ -5,0 +5,0 @@ "main": "dist/lib/painter.js",

import Painter, { PaintBaseOption } from "./painter";
import { downloadFileToLocal } from "../utils/downloadFile";

@@ -31,5 +32,3 @@ interface Rect {

if(objectFit == "contain"){
// console.time("calculateContainSize");
contentSize = await calculateContainSize(image)
// console.timeEnd("calculateContainSize");
} else { // fill

@@ -39,9 +38,19 @@ contentSize = { left, top, width, height }

this.ctx.drawImage(
image.src,
this.upx2px(contentSize.left),
this.upx2px(contentSize.top),
this.upx2px(contentSize.width),
this.upx2px(contentSize.height),
)
let src: string;
// 支付宝中需要先下载图片再绘制
if(this.platform == "mp-alipay" && !/^https:\/\/resource\//.test(image.src)){
src = await downloadFileToLocal(image.src).catch(err => console.log("下载错误: ", err)) || "";
}else{
src = image.src;
}
if(src){
this.ctx.drawImage(
src,
this.upx2px(contentSize.left),
this.upx2px(contentSize.top),
this.upx2px(contentSize.width),
this.upx2px(contentSize.height),
)
}

@@ -48,0 +57,0 @@ return {

@@ -1,12 +0,11 @@

var swan: unknown;
var my: unknown;
var wx: unknown;
export type UniPlatforms = "mp-weixin" | "mp-alipay" | "mp-baidu";
export const PLATFORM: UniPlatforms = (function(){
// @ts-ignore
if(typeof swan == "object")
return "mp-baidu"
// @ts-ignore
if(typeof my == "object")
return "mp-alipay"
// @ts-ignore
if(typeof wx == "object")

@@ -13,0 +12,0 @@ return "mp-weixin"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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