polotno 4.19.0 → 4.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DOWNSCALE_KERNEL_WASM as t}from"./downscale-kernel.wasm";import{bandRows as s,planBands as e}from"./downscale-bands.js";import{decodeBase64 as r}from"../utils/base64.js";import*as n from"./downscale-passes.js";let a,o=!1;const l=(async()=>{try{return a=await WebAssembly.compile(r(t)),!0}catch(s){return!1}})();export const loadDownscaleKernel=()=>l;export function runResample(t,r,l,c,i,m,w){const u=t.width,p=e(i.starts,i.counts,l),y=Math.max(0,...p.map(t=>t.srcCount)),h=function(t,e,r,n,a,o){let l=0;const c=t=>{const s=l;return l+=16*Math.ceil(t/16),s},i=t*e;return{srcU8:c(4*i),srcU16:c(8*i),rows:c(r*e*16),columns:c(r*s(n)*16),out:c(r*n*4),scratch:c(3*r*16),rowBuf:c(16*t),startsX:c(4*r),countsX:c(4*r),weightsX:c(a.weights.byteLength),startsY:c(4*s(n)),countsY:c(4*n),weightsY:c(o.weights.byteLength),bytes:l}}(u,y,r,l,c,i),f="js"===w?void 0:a;if("wasm"===w&&!f){throw new Error("downscale kernel unavailable")}let g,d;if(f){o||(o=!0,function(){const t=new Uint8ClampedArray(262144);for(let r=0;r<t.length;r++){t[r]=31*r&255}const s=function(t){const s=new Int32Array(t),e=new Int32Array(t).fill(2),r=new Float32Array(256).fill(.5);for(let n=0;n<t;n++){s[n]=2*n}return{starts:s,counts:e,weights:r,maxTaps:2}}(128),e={width:256,rows:(s,e)=>t.subarray(256*s*4,256*(s+e)*4)};for(let r=0;r<8;r++){runResample(e,128,128,s,s,.1,"wasm")}}());const t=Math.ceil(h.bytes/65536),s=new WebAssembly.Memory({initial:t,maximum:t});d=new WebAssembly.Instance(f,{env:{memory:s}}).exports,g=s.buffer}else{g=new ArrayBuffer(h.bytes),d=function(t){const s=(s,e)=>new Uint8ClampedArray(t,s,e),e=(s,e)=>new Uint16Array(t,s,e),r=(s,e)=>new Float32Array(t,s,e),a=(s,e,n,a,o)=>({starts:new Int32Array(t,s,a),counts:new Int32Array(t,e,a),weights:r(n,a*o),maxTaps:o});return{toPremultiplied:(t,r,a)=>n.toPremultiplied(s(t,4*a),e(r,4*a)),resampleRows:(t,s,o,l,c,i,m,w,u,p)=>n.resampleRows(e(t,l*c*4),l,c,i,a(m,w,u,i,p),r(s,i*c*4)),resampleColumns:(t,s,e,o,l,c,i,m)=>n.resampleColumns(r(t),e,o,a(l,c,i,o,m),r(s,e*o)),fromPremultiplied:(t,e,a)=>n.fromPremultiplied(r(t,4*a),s(e,4*a)),magicSharpen:(t,e,a,o)=>n.magicSharpen(s(t,a*o*4),r(e,9*a),a,o),gatedUnsharp:(t,e,r,a,o)=>n.gatedUnsharp(s(t,r*a*4),s(e,12*r),r,a,o)}}(g)}new Int32Array(g,h.startsX,r).set(c.starts),new Int32Array(g,h.countsX,r).set(c.counts),new Float32Array(g,h.weightsX,c.weights.length).set(c.weights),new Int32Array(g,h.countsY,l).set(i.counts),new Float32Array(g,h.weightsY,i.weights.length).set(i.weights);const A=new Int32Array(g,h.startsY,s(l)),b=new Uint8ClampedArray(g,h.srcU8,u*y*4);for(const s of p){const e=s.y1-s.y0;s.srcCount>0&&b.set(t.rows(s.srcFirst,s.srcCount));for(let t=0;t<e;t++){A[t]=i.starts[s.y0+t]-s.srcFirst}d.toPremultiplied(h.srcU8,h.srcU16,u*s.srcCount),d.resampleRows(h.srcU16,h.rows,h.rowBuf,u,s.srcCount,r,h.startsX,h.countsX,h.weightsX,c.maxTaps),d.resampleColumns(h.rows,h.columns,4*r,e,h.startsY,h.countsY+4*s.y0,h.weightsY+s.y0*i.maxTaps*4,i.maxTaps),d.fromPremultiplied(h.columns,h.out+s.y0*r*4,e*r)}return d.magicSharpen(h.out,h.scratch,r,l),m>0&&d.gatedUnsharp(h.out,h.scratch,r,l,m),new ImageData(new Uint8ClampedArray(g,h.out,r*l*4),r,l)}
|
|
1
|
+
import{DOWNSCALE_KERNEL_WASM as t}from"./downscale-kernel.wasm.js";import{bandRows as s,planBands as e}from"./downscale-bands.js";import{decodeBase64 as r}from"../utils/base64.js";import*as n from"./downscale-passes.js";let a,o=!1;const l=(async()=>{try{return a=await WebAssembly.compile(r(t)),!0}catch(s){return!1}})();export const loadDownscaleKernel=()=>l;export function runResample(t,r,l,c,i,m,w){const u=t.width,p=e(i.starts,i.counts,l),y=Math.max(0,...p.map(t=>t.srcCount)),h=function(t,e,r,n,a,o){let l=0;const c=t=>{const s=l;return l+=16*Math.ceil(t/16),s},i=t*e;return{srcU8:c(4*i),srcU16:c(8*i),rows:c(r*e*16),columns:c(r*s(n)*16),out:c(r*n*4),scratch:c(3*r*16),rowBuf:c(16*t),startsX:c(4*r),countsX:c(4*r),weightsX:c(a.weights.byteLength),startsY:c(4*s(n)),countsY:c(4*n),weightsY:c(o.weights.byteLength),bytes:l}}(u,y,r,l,c,i),f="js"===w?void 0:a;if("wasm"===w&&!f){throw new Error("downscale kernel unavailable")}let g,d;if(f){o||(o=!0,function(){const t=new Uint8ClampedArray(262144);for(let r=0;r<t.length;r++){t[r]=31*r&255}const s=function(t){const s=new Int32Array(t),e=new Int32Array(t).fill(2),r=new Float32Array(256).fill(.5);for(let n=0;n<t;n++){s[n]=2*n}return{starts:s,counts:e,weights:r,maxTaps:2}}(128),e={width:256,rows:(s,e)=>t.subarray(256*s*4,256*(s+e)*4)};for(let r=0;r<8;r++){runResample(e,128,128,s,s,.1,"wasm")}}());const t=Math.ceil(h.bytes/65536),s=new WebAssembly.Memory({initial:t,maximum:t});d=new WebAssembly.Instance(f,{env:{memory:s}}).exports,g=s.buffer}else{g=new ArrayBuffer(h.bytes),d=function(t){const s=(s,e)=>new Uint8ClampedArray(t,s,e),e=(s,e)=>new Uint16Array(t,s,e),r=(s,e)=>new Float32Array(t,s,e),a=(s,e,n,a,o)=>({starts:new Int32Array(t,s,a),counts:new Int32Array(t,e,a),weights:r(n,a*o),maxTaps:o});return{toPremultiplied:(t,r,a)=>n.toPremultiplied(s(t,4*a),e(r,4*a)),resampleRows:(t,s,o,l,c,i,m,w,u,p)=>n.resampleRows(e(t,l*c*4),l,c,i,a(m,w,u,i,p),r(s,i*c*4)),resampleColumns:(t,s,e,o,l,c,i,m)=>n.resampleColumns(r(t),e,o,a(l,c,i,o,m),r(s,e*o)),fromPremultiplied:(t,e,a)=>n.fromPremultiplied(r(t,4*a),s(e,4*a)),magicSharpen:(t,e,a,o)=>n.magicSharpen(s(t,a*o*4),r(e,9*a),a,o),gatedUnsharp:(t,e,r,a,o)=>n.gatedUnsharp(s(t,r*a*4),s(e,12*r),r,a,o)}}(g)}new Int32Array(g,h.startsX,r).set(c.starts),new Int32Array(g,h.countsX,r).set(c.counts),new Float32Array(g,h.weightsX,c.weights.length).set(c.weights),new Int32Array(g,h.countsY,l).set(i.counts),new Float32Array(g,h.weightsY,i.weights.length).set(i.weights);const A=new Int32Array(g,h.startsY,s(l)),b=new Uint8ClampedArray(g,h.srcU8,u*y*4);for(const s of p){const e=s.y1-s.y0;s.srcCount>0&&b.set(t.rows(s.srcFirst,s.srcCount));for(let t=0;t<e;t++){A[t]=i.starts[s.y0+t]-s.srcFirst}d.toPremultiplied(h.srcU8,h.srcU16,u*s.srcCount),d.resampleRows(h.srcU16,h.rows,h.rowBuf,u,s.srcCount,r,h.startsX,h.countsX,h.weightsX,c.maxTaps),d.resampleColumns(h.rows,h.columns,4*r,e,h.startsY,h.countsY+4*s.y0,h.weightsY+s.y0*i.maxTaps*4,i.maxTaps),d.fromPremultiplied(h.columns,h.out+s.y0*r*4,e*r)}return d.magicSharpen(h.out,h.scratch,r,l),m>0&&d.gatedUnsharp(h.out,h.scratch,r,l,m),new ImageData(new Uint8ClampedArray(g,h.out,r*l*4),r,l)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno",
|
|
3
|
-
"version": "4.19.
|
|
3
|
+
"version": "4.19.1",
|
|
4
4
|
"description": "Design editor SDK: embed a Canva-like editor, generate designs from templates and data, export PNG, PDF, and video in the browser or on a server.",
|
|
5
5
|
"author": "Anton Lavrenov",
|
|
6
6
|
"repository": {
|
package/utils/validate-key.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"mobx";import{getAPI as o}from"./api.js";import{removeBackgroundState as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const u=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let p=fetch;export const __=e=>{p=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await p(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.19.
|
|
1
|
+
import*as e from"mobx";import{getAPI as o}from"./api.js";import{removeBackgroundState as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const u=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let p=fetch;export const __=e=>{p=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await p(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.19.1"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(u,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{t.defaultEnabled=s.remove_background_enabled}),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(s)&&!e||r()}
|