mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 13:34:04 +03:00
feat(Image to SVG): intégration de esm-potrace-wasm et VTracer pour le mode couleur
Fix #391
This commit is contained in:
1 parent
eaea6e9fd5
commit
bce809a5cc
9 files changed
+901
-22
No files matched your search
@@ -3088,6 +3088,37 @@ tools:
|
|||||||
title-drag-and-drop-an-image-here-or-click-to-select-a-file: Drag and drop an image here, or click to select a file
|
title-drag-and-drop-an-image-here-or-click-to-select-a-file: Drag and drop an image here, or click to select a file
|
||||||
tag-posterize: Posterize?
|
tag-posterize: Posterize?
|
||||||
tag-potrace-result: Potrace result
|
tag-potrace-result: Potrace result
|
||||||
|
button-trace: Trace
|
||||||
|
minimum-angle-displacement-in-degrees-to-be-considered-a-cutting-point-between-curves: >-
|
||||||
|
Minimum Angle Displacement (in degrees) to be considered a cutting point
|
||||||
|
between curves
|
||||||
|
splice-threshold-more-accurate: 'Splice Threshold (More accurate):'
|
||||||
|
perform-iterative-subdivide-smooth-until-all-segments-are-shorter-than-this-length: >-
|
||||||
|
Perform Iterative Subdivide Smooth until all segments are shorter than
|
||||||
|
this length
|
||||||
|
length-threshold-more-coarse: 'Length Threshold (More coarse):'
|
||||||
|
minimum-momentary-angle-in-degrees-to-be-considered-a-corner-to-be-kept-after-smoothing: >-
|
||||||
|
Minimum Momentary Angle (in degrees) to be considered a corner (to be
|
||||||
|
kept after smoothing)
|
||||||
|
corner-threshold-smoother: 'Corner Threshold (Smoother):'
|
||||||
|
layer-difference: 'Layer Difference:'
|
||||||
|
number-of-significant-bits-to-use-in-a-rgb-channel: Number of significant bits to use in a RGB channel
|
||||||
|
color-precision-more-accurate: 'Color Precision (More accurate):'
|
||||||
|
color-difference-between-gradient-layers: Color difference between gradient layers
|
||||||
|
gradient-step-less-layers: 'Gradient Step (Less layers):'
|
||||||
|
discard-patches-small-than-x-px-in-size: Discard patches small than X px in size
|
||||||
|
filter-speckle-cleaner: 'Filter Speckle (Cleaner):'
|
||||||
|
hierarchical-mode: 'Hierarchical Mode:'
|
||||||
|
curve-fitting: 'Curve Fitting:'
|
||||||
|
color-vtracer: Color (VTracer)
|
||||||
|
color-potrace: Color (Potrace)
|
||||||
|
bw: BW
|
||||||
|
interpolate: Interpolate?
|
||||||
|
pixel: Pixel
|
||||||
|
polygon: Polygon
|
||||||
|
spline: Spline
|
||||||
|
stacked: Stacked
|
||||||
|
cutout: Cutout
|
||||||
power-converter:
|
power-converter:
|
||||||
title: Power Converter
|
title: Power Converter
|
||||||
description: Convert values between power units
|
description: Convert values between power units
|
||||||
|
|||||||
+3
-1
@@ -165,6 +165,7 @@
|
|||||||
"email-normalizer": "^1.0.0",
|
"email-normalizer": "^1.0.0",
|
||||||
"emojilib": "^4.0.2",
|
"emojilib": "^4.0.2",
|
||||||
"epubjs": "^0.3.93",
|
"epubjs": "^0.3.93",
|
||||||
|
"esm-potrace-wasm": "^0.4.4",
|
||||||
"ethers": "^6.16.0",
|
"ethers": "^6.16.0",
|
||||||
"event-cron-parser": "^1.0.37",
|
"event-cron-parser": "^1.0.37",
|
||||||
"exif-be-gone": "^1.5.1",
|
"exif-be-gone": "^1.5.1",
|
||||||
@@ -464,7 +465,8 @@
|
|||||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
||||||
},
|
},
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"node-forge@1.4.0": "patches/node-forge@1.4.0.patch"
|
"node-forge@1.4.0": "patches/node-forge@1.4.0.patch",
|
||||||
|
"esm-potrace-wasm": "patches/esm-potrace-wasm.patch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scarfSettings": {
|
"scarfSettings": {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
diff --git a/dist/index.js b/dist/index.js
|
||||||
|
index ba40e7a8d4d4d56621fa467ff0f6fdc3a30e0fa6..9136f03df05cb2ff615e43fa2df4e32b784465ba 100644
|
||||||
|
--- a/dist/index.js
|
||||||
|
+++ b/dist/index.js
|
||||||
|
@@ -1 +1 @@
|
||||||
|
-var A=void 0!==A?A:{},r=!!globalThis.window,v=!!globalThis.WorkerGlobalScope,t=(globalThis.process?.versions?.node&&globalThis.process?.type,globalThis.document?.currentScript?.src);v&&(t=self.location.href);if(r||v){try{new URL(".",t).href}catch{}v&&(A=>{var r=new XMLHttpRequest;return r.open("GET",A,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),async A=>{var r=await fetch(A,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)}}var j,f,b,n=console.log.bind(console),e=console.error.bind(console),o=!1;var a,k=!1;function s(){var A=y.buffer;j=new Int8Array(A),new Int16Array(A),f=new Uint8Array(A),new Uint16Array(A),new Int32Array(A),b=new Uint32Array(A),new Float32Array(A),new Float64Array(A),new BigInt64Array(A),new BigUint64Array(A)}function x(r){throw A.onAbort?.(r),e(r="Aborted("+r+")"),o=!0,r+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(r)}function i(){return function(A){for(var r,v=0,t=A.length,j=new Uint8Array(t);v<t;++v)r=A.charCodeAt(v),j[v]=~r>>8&r;return j}('\0asm\0\0\0``\0`\0```\0`\0`\0`\0`\0\0`~~`|``~`~```||`\0`\r||+aa\0ab\0\fac\0ad\0\tae\0\0af\0\rag\0\0ZY\0\0\0\0\0\0\0\0\0\0\t\0\0\0\0\0\b\b\0\v\n\0\0\n\0\0\0\0\tp11\bA°Ô\vh\0i\0_j\0^k\0Al\0@m\0?\t6\0A\v0(]\\>[ZYXW>VUTS8RQPONMLKJDFIEGHC\'B\'\f\nËÿY\f\b@ \0E\r\0 \0A\bk" \0Ak(\0"Axq"\0j!@ Aq\r\0 AqE\r (\0"k"AÄÐ\0(\0I\r \0 j!\0@@@AÈÐ\0(\0 G@ (\f! AÿM@ (\b"G\rA´Ð\0A´Ð\0(\0A~ Avwq6\0\f\v (! G@ (\b" 6\f 6\b\f\v (" Aj ("E\r Aj\v!@ ! "Aj! ("\r\0 Aj! ("\r\0\v A\x006\0\f\v ("AqAG\rA¼Ð\0 \x006\0 A~q6 \0Ar6 \x006\0\v 6\f 6\b\f\vA\0!\v E\r\0@ ("At"(äR F@ AäÒ\0j 6\0 \rA¸Ð\0A¸Ð\0(\0A~ wq6\0\f\v@ (F@ 6\f\v 6\v E\r\v 6 ("@ 6 6\v ("E\r\0 6 6\v O\r\0 ("AqE\r\0@@@@ AqE@AÌÐ\0(\0 F@AÌÐ\0 6\0AÀÐ\0AÀÐ\0(\0 \0j"\x006\0 \0Ar6 AÈÐ\0(\0G\rA¼Ð\0A\x006\0AÈÐ\0A\x006\0\vAÈÐ\0(\0" F@AÈÐ\0 6\0A¼Ð\0A¼Ð\0(\0 \0j"\x006\0 \0Ar6 \0 j \x006\0\v Axq \0j!\0 (\f! AÿM@ (\b" F@A´Ð\0A´Ð\0(\0A~ Avwq6\0\f\v 6\f 6\b\f\v (!\b G@ (\b" 6\f 6\b\f\v (" Aj ("E\r Aj\v!@ ! "Aj! ("\r\0 Aj! ("\r\0\v A\x006\0\f\v A~q6 \0Ar6 \0 j \x006\0\f\vA\0!\v \bE\r\0@ ("At"(äR F@ AäÒ\0j 6\0 \rA¸Ð\0A¸Ð\0(\0A~ wq6\0\f\v@ \b(F@ \b 6\f\v \b 6\v E\r\v \b6 ("@ 6 6\v ("E\r\0 6 6\v \0Ar6 \0 j \x006\0 G\r\0A¼Ð\0 \x006\0\v \0AÿM@ \0AøqAÜÐ\0j!A´Ð\0(\0"A \0Avt"\0qE@A´Ð\0 \0 r6\0 \f\v (\b\v!\0 6\b \0 6\f 6\f \x006\b\vA! \0AÿÿÿM@ \0A& \0A\bvg"kvAq AtrA>s!\v 6 B\x007 AtAäÒ\0j!@A¸Ð\0(\0"A t"qE@A¸Ð\0 r6\0 6\0A!A\b\f\v \0A AvkA\0 AGt! (\0!@ "(Axq \0F\r Av! At! Aqj"("\r\0\v 6A! !A\b\v!\0 "\f\v (\b" 6\f 6\bA!\0A\b!A\0\v! j 6\0 6\f \0 j 6\0AÔÐ\0AÔÐ\0(\0Ak"\0A \06\0\v\vY~@A\0 \0E\r\0 \0 ~"§" \0 rAI\r\0A B §\v"\f"\0E\r\0 \0Ak-\0\0AqE\r\0 \0A\0 \v \0\v\0 \0-\0\0A qE@ \0"\v\vj#\0Ak"$\0@ L\r\0 AÀq\r\0 k"A AI" E@@ \0 A\t Ak"AÿK\r\0\v\v \0 \t\v Aj$\0\v8\0 l! (LA\0H@ \0 "\f\v \0 "\v"\0F@\v \0 n\v»(\v#\0Ak"\n$\0@@@@@@@@@@ \0AôM@A´Ð\0(\0"A \0A\vjAøq \0A\vI"Av"\0v"Aq@@ AsAq \0j"At"AÜÐ\0j"\0 (äP"(\b"F@A´Ð\0 A~ wq6\0\f\v \x006\f \0 6\b\v A\bj!\0 Ar6 j" (Ar6\f\v\v A¼Ð\0(\0"\bM\r @@A \0t"A\0 kr \0tqh"At"AÜÐ\0j" (äP"\0(\b"F@A´Ð\0 A~ wq"6\0\f\v 6\f 6\b\v \0 Ar6 \0 j" k"Ar6 \0 j 6\0 \b@ \bAxqAÜÐ\0j!AÈÐ\0(\0! A \bAvt"qE@A´Ð\0 r6\0 \f\v (\b\v! 6\b 6\f 6\f 6\b\v \0A\bj!\0AÈÐ\0 6\0A¼Ð\0 6\0\f\v\vA¸Ð\0(\0"\vE\r \vhAt(äR"(Axq k! !@@ ("\0E@ ("\0E\r\v \0(Axq k" I"! \0 ! \0!\f\v\v (!\t (\f"\0G@ (\b" \x006\f \0 6\b\f\n\v (" Aj ("E\r Aj\v!@ ! "\0Aj! \0("\r\0 \0Aj! \0("\r\0\v A\x006\0\f\t\vA! \0A¿K\r\0 \0A\vj"Axq!A¸Ð\0(\0"E\r\0A!\bA\0 k! \0AôÿÿM@ A& A\bvg"\0kvAq \0AtkA>j!\b\v@@@ \bAt(äR"E@A\0!\0\f\vA\0!\0 A \bAvkA\0 \bAGt!@@ (Axq k" O\r\0 ! "\r\0A\0! !\0\f\v \0 (" AvAqj("F \0 !\0 At! \r\0\v\v \0 rE@A\0!A \bt"\0A\0 \0kr
Line truncated
|
||||||
|
\ No newline at end of file
|
||||||
|
+var A,I,g=void 0!==g?g:{},C=Object.assign({},g),Q=(A,I)=>{throw I},B="object"==typeof window,E="function"==typeof importScripts,i="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,D="";if(i){var o=require("fs"),w=require("path");D=E?w.dirname(D)+"/":__dirname+"/",A=(A,I)=>(A=b(A)?new URL(A):w.normalize(A),o.readFileSync(A,I?void 0:"utf8")),I=I=>{var g=A(I,!0);return g.buffer||(g=new Uint8Array(g)),g},(A,I,g,C=!0)=>{A=b(A)?new URL(A):w.normalize(A),o.readFile(A,C?void 0:"utf8",((A,Q)=>{A?g(A):I(C?Q.buffer:Q)}))},!g.thisProgram&&process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),"undefined"!=typeof module&&(module.exports=g),process.on("uncaughtException",(A=>{if(!("unwind"===A||A instanceof l||A.context instanceof l))throw A})),Q=(A,I)=>{throw process.exitCode=A,I},g.inspect=()=>"[Emscripten Module object]"}else(B||E)&&(E?D=self.location.href:"undefined"!=typeof document&&document.currentScript&&(D=document.currentScript.src),D=0!==D.indexOf("blob:")?D.substr(0,D.replace(/[?#].*/,"").lastIndexOf("/")+1):"",A=A=>{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.send(null),I.responseText},E&&(I=A=>{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.responseType="arraybuffer",I.send(null),new Uint8Array(I.response)}),(A,I,g)=>{var C=new XMLHttpRequest;C.open("GET",A,!0),C.responseType="arraybuffer",C.onload=()=>{200==C.status||0==C.status&&C.response?I(C.response):g()},C.onerror=g,C.send(null)},A=>document.title=A);var N,s=g.print||console.log.bind(console),h=g.printErr||console.error.bind(console);Object.assign(g,C),C=null,g.arguments&&g.arguments,g.thisProgram&&g.thisProgram,g.quit&&(Q=g.quit),g.wasmBinary&&(N=g.wasmBinary);var y,R=g.noExitRuntime||!0;"object"!=typeof WebAssembly&&L("no native wasm support detected");var F,G,M,a=!1;function K(){var A=y.buffer;g.HEAP8=F=new Int8Array(A),g.HEAP16=new Int16Array(A),g.HEAPU8=G=new Uint8Array(A),g.HEAPU16=new Uint16Array(A),g.HEAP32=new Int32Array(A),g.HEAPU32=M=new Uint32Array(A),g.HEAPF32=new Float32Array(A),g.HEAPF64=new Float64Array(A)}var S=[],t=[],r=[],c=!1;var Y=0,U=null,J=null;function L(A){throw g.onAbort&&g.onAbort(A),h(A="Aborted("+A+")"),a=!0,1,A+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(A)}var k,H,e="data:application/octet-stream;base64,";function n(A){return A.startsWith("data:application/octet-stream;base64,")}function b(A){return A.startsWith("file://")}function d(A){if(A==k&&N)return new Uint8Array(N);var g=function(A){if(!n(A))return;return function(A){if(void 0!==i&&i){var I=Buffer.from(A,"base64");return new Uint8Array(I.buffer,I.byteOffset,I.length)}try{for(var g=atob(A),C=new Uint8Array(g.length),Q=0;Q<g.length;++Q)C[Q]=g.charCodeAt(Q);return C}catch(A){throw new Error("Converting base64 string to bytes failed.")}}(A.slice(e.length))}(A);if(g)return g;if(I)return I(A);throw"both async and sync fetching of the wasm failed"}function q(A,I,g){return function(A){return Promise.resolve().then((()=>d(A)))}(A).then((A=>WebAssembly.instantiate(A,I))).then((A=>A)).then(g,(A=>{h(`failed to asynchronously prepare wasm: ${A}`),L(A)}))}function l(A){this.name="ExitStatus",this.message=`Program terminated with exit(${A})`,this.status=A}n(k="data:application/octet-stream;base64,AGFzbQEAAAABigETYAF/AX9gAX8AYAJ/fwBgAn9/AX9gA39/fwF/YAR/f39/AGADf39/AGAAAGAFf39/f38AYAZ/f39/f38AYAN/fn8BfmAFf39/f38Bf2AGf3x/f39/AX9gBH9/f38Bf2ACfn8Bf2AHf39/f39/fwF/YAJ8fwF8YAABf2AMf39/f39/f39/fH98AX8CMQgBYQFhAAYBYQFiAA0BYQFjAAEBYQFkAAsBYQFlAAcBYQFmAAABYQFnAAABYQFoAAYDX14BAwYECAUABgAEBAEADgAGAAIEAAUBBQALAAQCAQAHAgcBAgAFBgMCAgMDBAUADxADBAMCAQEDAgABEQAAAAAACQkICAEFBQQABAIMCgQAAAoAAwMCAAADAwIABwMSBAUBcAE2NgUHAQGAAoCAAgYIAX8BQaDVBAsHKQoBaQIAAWoAKAFrAGUBbABkAW0AYwFuAQABbwBCAXAAQQFxAEABcgBHCTsBAEEBCzUbGytMGxNiYR0TYF9eE11cHRNbWllYOVdWVVRTUlETUBsTHR1PSEpOE0lLTRNFE0QTRilDKQq09QJe9QsBB38CQCAARQ0AIABBCGsiAiAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAIgAigCACIBayICQbTRACgCAEkNASAAIAFqIQACQAJAQbjRACgCACACRwRAIAFB/wFNBEAgAUEDdiEEIAIoAgwiASACKAIIIgNGBEBBpNEAQaTRACgCAEF+IAR3cTYCAAwFCyADIAE2AgwgASADNgIIDAQLIAIoAhghBiACIAIoAgwiAUcEQCACKAIIIgMgATYCDCABIAM2AggMAwsgAkEUaiIEKAIAIgNFBEAgAigCECIDRQ0CIAJBEGohBAsDQCAEIQcgAyIBQRRqIgQoAgAiAw0AIAFBEGohBCABKAIQIgMNAAsgB0EANgIADAILIAUoAgQiAUEDcUEDRw0CQazRACAANgIAIAUgAUF+cTYCBCACIABBAXI2AgQgBSAANgIADwtBACEBCyAGRQ0AAkAgAigCHCIDQQJ0QdTTAGoiBCgCACACRgRAIAQgATYCACABDQFBqNEAQajRACgCAEF+IAN3cTYCAAwCCyAGQRBBFCAGKAIQIAJGG2ogATYCACABRQ0BCyABIAY2AhggAigCECIDBEAgASADNgIQIAMgATYCGAsgAigCFCIDRQ0AIAEgAzYCFCADIAE2AhgLIAIgBU8NACAFKAIEIgFBAXFFDQACQAJAAkACQCABQQJxRQRAQbzRACgCACAFRgRAQbzRACACNgIAQbDRAEGw0QAoAgAgAGoiADYCACACIABBAXI2AgQgAkG40QAoAgBHDQZBrNEAQQA2AgBBuNEAQQA2AgAPC0G40QAoAgAgBUYEQEG40QAgAjYCAEGs0QBBrNEAKAIAIABqIgA2AgAgAiAAQQFyNgIEIAAgAmogADYCAA8LIAFBeHEgAGohACABQf8BTQRAIAFBA3YhBCAFKAIMIgEgBSgCCCIDRgRAQaTRAEGk0QAoAgBBfiAEd3E2AgAMBQsgAyABNgIMIAEgAzYCCAwECyAFKAIYIQYgBSAFKAIMIgFHBEBBtNEAKAIAGiAFKAIIIgMgATYCDCABIAM2AggMAwsgBUEUaiIEKAIAIgNFBEAgBSgCECIDRQ0CIAVB
Line truncated
|
||||||
Generated
+11
@@ -9,6 +9,9 @@ overrides:
|
|||||||
xlsx: https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz
|
xlsx: https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz
|
||||||
|
|
||||||
patchedDependencies:
|
patchedDependencies:
|
||||||
|
esm-potrace-wasm:
|
||||||
|
hash: 4txgfquopg5wxm3hbowsmko764
|
||||||
|
path: patches/esm-potrace-wasm.patch
|
||||||
node-forge@1.4.0:
|
node-forge@1.4.0:
|
||||||
hash: be4w4shpo4tldv77tcysxrioha
|
hash: be4w4shpo4tldv77tcysxrioha
|
||||||
path: patches/node-forge@1.4.0.patch
|
path: patches/node-forge@1.4.0.patch
|
||||||
@@ -386,6 +389,9 @@ importers:
|
|||||||
epubjs:
|
epubjs:
|
||||||
specifier: ^0.3.93
|
specifier: ^0.3.93
|
||||||
version: 0.3.93
|
version: 0.3.93
|
||||||
|
esm-potrace-wasm:
|
||||||
|
specifier: ^0.4.4
|
||||||
|
version: 0.4.4(patch_hash=4txgfquopg5wxm3hbowsmko764)
|
||||||
ethers:
|
ethers:
|
||||||
specifier: ^6.16.0
|
specifier: ^6.16.0
|
||||||
version: 6.16.0
|
version: 6.16.0
|
||||||
@@ -6892,6 +6898,9 @@ packages:
|
|||||||
esm-env@1.2.2:
|
esm-env@1.2.2:
|
||||||
resolution: {integrity: sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==}
|
resolution: {integrity: sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==}
|
||||||
|
|
||||||
|
esm-potrace-wasm@0.4.4:
|
||||||
|
resolution: {integrity: sha512-2t9Rds/ZWf4n2bvyLv/fAkZdLCgv02q316xoBSSm5qp7jstlheTAZbdu4Q/ojbS6kwJwVoSv1Pjpx+e7niAp+A==}
|
||||||
|
|
||||||
esniff@2.0.1:
|
esniff@2.0.1:
|
||||||
resolution: {integrity: sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==}
|
resolution: {integrity: sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==}
|
||||||
engines: {node: '>=0.10'}
|
engines: {node: '>=0.10'}
|
||||||
@@ -18590,6 +18599,8 @@ snapshots:
|
|||||||
|
|
||||||
esm-env@1.2.2: {}
|
esm-env@1.2.2: {}
|
||||||
|
|
||||||
|
esm-potrace-wasm@0.4.4(patch_hash=4txgfquopg5wxm3hbowsmko764): {}
|
||||||
|
|
||||||
esniff@2.0.1:
|
esniff@2.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
d: 1.0.2
|
d: 1.0.2
|
||||||
|
|||||||
@@ -0,0 +1,561 @@
|
|||||||
|
let wasm;
|
||||||
|
|
||||||
|
function addToExternrefTable0(obj) {
|
||||||
|
const idx = wasm.__externref_table_alloc();
|
||||||
|
wasm.__wbindgen_export_2.set(idx, obj);
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleError(f, args) {
|
||||||
|
try {
|
||||||
|
return f.apply(this, args);
|
||||||
|
} catch (e) {
|
||||||
|
const idx = addToExternrefTable0(e);
|
||||||
|
wasm.__wbindgen_exn_store(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
||||||
|
|
||||||
|
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
||||||
|
|
||||||
|
let cachedUint8ArrayMemory0 = null;
|
||||||
|
|
||||||
|
function getUint8ArrayMemory0() {
|
||||||
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
||||||
|
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||||||
|
}
|
||||||
|
return cachedUint8ArrayMemory0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStringFromWasm0(ptr, len) {
|
||||||
|
ptr = ptr >>> 0;
|
||||||
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
||||||
|
}
|
||||||
|
|
||||||
|
let WASM_VECTOR_LEN = 0;
|
||||||
|
|
||||||
|
function passArray8ToWasm0(arg, malloc) {
|
||||||
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
||||||
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
||||||
|
WASM_VECTOR_LEN = arg.length;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cachedDataViewMemory0 = null;
|
||||||
|
|
||||||
|
function getDataViewMemory0() {
|
||||||
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
||||||
|
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
||||||
|
}
|
||||||
|
return cachedDataViewMemory0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLikeNone(x) {
|
||||||
|
return x === undefined || x === null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
||||||
|
|
||||||
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
||||||
|
? function (arg, view) {
|
||||||
|
return cachedTextEncoder.encodeInto(arg, view);
|
||||||
|
}
|
||||||
|
: function (arg, view) {
|
||||||
|
const buf = cachedTextEncoder.encode(arg);
|
||||||
|
view.set(buf);
|
||||||
|
return {
|
||||||
|
read: arg.length,
|
||||||
|
written: buf.length
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function passStringToWasm0(arg, malloc, realloc) {
|
||||||
|
|
||||||
|
if (realloc === undefined) {
|
||||||
|
const buf = cachedTextEncoder.encode(arg);
|
||||||
|
const ptr = malloc(buf.length, 1) >>> 0;
|
||||||
|
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||||
|
WASM_VECTOR_LEN = buf.length;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
let len = arg.length;
|
||||||
|
let ptr = malloc(len, 1) >>> 0;
|
||||||
|
|
||||||
|
const mem = getUint8ArrayMemory0();
|
||||||
|
|
||||||
|
let offset = 0;
|
||||||
|
|
||||||
|
for (; offset < len; offset++) {
|
||||||
|
const code = arg.charCodeAt(offset);
|
||||||
|
if (code > 0x7F) break;
|
||||||
|
mem[ptr + offset] = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset !== len) {
|
||||||
|
if (offset !== 0) {
|
||||||
|
arg = arg.slice(offset);
|
||||||
|
}
|
||||||
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
||||||
|
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
||||||
|
const ret = encodeString(arg, view);
|
||||||
|
|
||||||
|
offset += ret.written;
|
||||||
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WASM_VECTOR_LEN = offset;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function debugString(val) {
|
||||||
|
// primitive types
|
||||||
|
const type = typeof val;
|
||||||
|
if (type == 'number' || type == 'boolean' || val == null) {
|
||||||
|
return `${val}`;
|
||||||
|
}
|
||||||
|
if (type == 'string') {
|
||||||
|
return `"${val}"`;
|
||||||
|
}
|
||||||
|
if (type == 'symbol') {
|
||||||
|
const description = val.description;
|
||||||
|
if (description == null) {
|
||||||
|
return 'Symbol';
|
||||||
|
} else {
|
||||||
|
return `Symbol(${description})`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == 'function') {
|
||||||
|
const name = val.name;
|
||||||
|
if (typeof name == 'string' && name.length > 0) {
|
||||||
|
return `Function(${name})`;
|
||||||
|
} else {
|
||||||
|
return 'Function';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// objects
|
||||||
|
if (Array.isArray(val)) {
|
||||||
|
const length = val.length;
|
||||||
|
let debug = '[';
|
||||||
|
if (length > 0) {
|
||||||
|
debug += debugString(val[0]);
|
||||||
|
}
|
||||||
|
for(let i = 1; i < length; i++) {
|
||||||
|
debug += ', ' + debugString(val[i]);
|
||||||
|
}
|
||||||
|
debug += ']';
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
// Test for built-in
|
||||||
|
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
||||||
|
let className;
|
||||||
|
if (builtInMatches && builtInMatches.length > 1) {
|
||||||
|
className = builtInMatches[1];
|
||||||
|
} else {
|
||||||
|
// Failed to match the standard '[object ClassName]'
|
||||||
|
return toString.call(val);
|
||||||
|
}
|
||||||
|
if (className == 'Object') {
|
||||||
|
// we're a user defined class or Object
|
||||||
|
// JSON.stringify avoids problems with cycles, and is generally much
|
||||||
|
// easier than looping through ownProperties of `val`.
|
||||||
|
try {
|
||||||
|
return 'Object(' + JSON.stringify(val) + ')';
|
||||||
|
} catch (_) {
|
||||||
|
return 'Object';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// errors
|
||||||
|
if (val instanceof Error) {
|
||||||
|
return `${val.name}: ${val.message}\n${val.stack}`;
|
||||||
|
}
|
||||||
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function main() {
|
||||||
|
wasm.main();
|
||||||
|
}
|
||||||
|
|
||||||
|
const BinaryImageConverterFinalization = (typeof FinalizationRegistry === 'undefined')
|
||||||
|
? { register: () => {}, unregister: () => {} }
|
||||||
|
: new FinalizationRegistry(ptr => wasm.__wbg_binaryimageconverter_free(ptr >>> 0, 1));
|
||||||
|
|
||||||
|
export class BinaryImageConverter {
|
||||||
|
|
||||||
|
static __wrap(ptr) {
|
||||||
|
ptr = ptr >>> 0;
|
||||||
|
const obj = Object.create(BinaryImageConverter.prototype);
|
||||||
|
obj.__wbg_ptr = ptr;
|
||||||
|
BinaryImageConverterFinalization.register(obj, obj.__wbg_ptr, obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
__destroy_into_raw() {
|
||||||
|
const ptr = this.__wbg_ptr;
|
||||||
|
this.__wbg_ptr = 0;
|
||||||
|
BinaryImageConverterFinalization.unregister(this);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
free() {
|
||||||
|
const ptr = this.__destroy_into_raw();
|
||||||
|
wasm.__wbg_binaryimageconverter_free(ptr, 0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {string} params
|
||||||
|
* @returns {BinaryImageConverter}
|
||||||
|
*/
|
||||||
|
static new_with_string(params) {
|
||||||
|
const ptr0 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
const ret = wasm.binaryimageconverter_new_with_string(ptr0, len0);
|
||||||
|
return BinaryImageConverter.__wrap(ret);
|
||||||
|
}
|
||||||
|
init() {
|
||||||
|
wasm.binaryimageconverter_init(this.__wbg_ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
tick() {
|
||||||
|
const ret = wasm.binaryimageconverter_tick(this.__wbg_ptr);
|
||||||
|
return ret !== 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
progress() {
|
||||||
|
const ret = wasm.binaryimageconverter_progress(this.__wbg_ptr);
|
||||||
|
return ret >>> 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ColorImageConverterFinalization = (typeof FinalizationRegistry === 'undefined')
|
||||||
|
? { register: () => {}, unregister: () => {} }
|
||||||
|
: new FinalizationRegistry(ptr => wasm.__wbg_colorimageconverter_free(ptr >>> 0, 1));
|
||||||
|
|
||||||
|
export class ColorImageConverter {
|
||||||
|
|
||||||
|
static __wrap(ptr) {
|
||||||
|
ptr = ptr >>> 0;
|
||||||
|
const obj = Object.create(ColorImageConverter.prototype);
|
||||||
|
obj.__wbg_ptr = ptr;
|
||||||
|
ColorImageConverterFinalization.register(obj, obj.__wbg_ptr, obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
__destroy_into_raw() {
|
||||||
|
const ptr = this.__wbg_ptr;
|
||||||
|
this.__wbg_ptr = 0;
|
||||||
|
ColorImageConverterFinalization.unregister(this);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
free() {
|
||||||
|
const ptr = this.__destroy_into_raw();
|
||||||
|
wasm.__wbg_colorimageconverter_free(ptr, 0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {string} params
|
||||||
|
* @returns {ColorImageConverter}
|
||||||
|
*/
|
||||||
|
static new_with_string(params) {
|
||||||
|
const ptr0 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len0 = WASM_VECTOR_LEN;
|
||||||
|
const ret = wasm.colorimageconverter_new_with_string(ptr0, len0);
|
||||||
|
return ColorImageConverter.__wrap(ret);
|
||||||
|
}
|
||||||
|
init() {
|
||||||
|
wasm.colorimageconverter_init(this.__wbg_ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
tick() {
|
||||||
|
const ret = wasm.colorimageconverter_tick(this.__wbg_ptr);
|
||||||
|
return ret !== 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
progress() {
|
||||||
|
const ret = wasm.colorimageconverter_progress(this.__wbg_ptr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function __wbg_load(module, imports) {
|
||||||
|
if (typeof Response === 'function' && module instanceof Response) {
|
||||||
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
||||||
|
try {
|
||||||
|
return await WebAssembly.instantiateStreaming(module, imports);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
if (module.headers.get('Content-Type') != 'application/wasm') {
|
||||||
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const bytes = await module.arrayBuffer();
|
||||||
|
return await WebAssembly.instantiate(bytes, imports);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const instance = await WebAssembly.instantiate(module, imports);
|
||||||
|
|
||||||
|
if (instance instanceof WebAssembly.Instance) {
|
||||||
|
return { instance, module };
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function __wbg_get_imports() {
|
||||||
|
const imports = {};
|
||||||
|
imports.wbg = {};
|
||||||
|
imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
||||||
|
const ret = arg0.call(arg1);
|
||||||
|
return ret;
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_createElementNS_914d752e521987da = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
const ret = arg0.createElementNS(arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
||||||
|
return ret;
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_data_d1ed736c1e42b10e = function(arg0, arg1) {
|
||||||
|
const ret = arg1.data;
|
||||||
|
const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
|
||||||
|
const len1 = WASM_VECTOR_LEN;
|
||||||
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||||
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_debug_e17b51583ca6a632 = function(arg0, arg1, arg2, arg3) {
|
||||||
|
console.debug(arg0, arg1, arg2, arg3);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_document_d249400bd7bd996d = function(arg0) {
|
||||||
|
const ret = arg0.document;
|
||||||
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
||||||
|
let deferred0_0;
|
||||||
|
let deferred0_1;
|
||||||
|
try {
|
||||||
|
deferred0_0 = arg0;
|
||||||
|
deferred0_1 = arg1;
|
||||||
|
console.error(getStringFromWasm0(arg0, arg1));
|
||||||
|
} finally {
|
||||||
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_error_80de38b3f7cc3c3c = function(arg0, arg1, arg2, arg3) {
|
||||||
|
console.error(arg0, arg1, arg2, arg3);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_getContext_e9cf379449413580 = function() { return handleError(function (arg0, arg1, arg2) {
|
||||||
|
const ret = arg0.getContext(getStringFromWasm0(arg1, arg2));
|
||||||
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_getElementById_f827f0d6648718a8 = function(arg0, arg1, arg2) {
|
||||||
|
const ret = arg0.getElementById(getStringFromWasm0(arg1, arg2));
|
||||||
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_getImageData_c02374a30b126dab = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
const ret = arg0.getImageData(arg1, arg2, arg3, arg4);
|
||||||
|
return ret;
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_height_838cee19ba8597db = function(arg0) {
|
||||||
|
const ret = arg0.height;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_info_033d8b8a0838f1d3 = function(arg0, arg1, arg2, arg3) {
|
||||||
|
console.info(arg0, arg1, arg2, arg3);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_instanceof_CanvasRenderingContext2d_df82a4d3437bf1cc = function(arg0) {
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = arg0 instanceof CanvasRenderingContext2D;
|
||||||
|
} catch (_) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
const ret = result;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_instanceof_HtmlCanvasElement_2ea67072a7624ac5 = function(arg0) {
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = arg0 instanceof HTMLCanvasElement;
|
||||||
|
} catch (_) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
const ret = result;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_instanceof_Window_def73ea0955fc569 = function(arg0) {
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = arg0 instanceof Window;
|
||||||
|
} catch (_) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
const ret = result;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_log_c222819a41e063d3 = function(arg0) {
|
||||||
|
console.log(arg0);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_log_cad59bb680daec67 = function(arg0, arg1, arg2, arg3) {
|
||||||
|
console.log(arg0, arg1, arg2, arg3);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
||||||
|
const ret = new Error();
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
|
||||||
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_prepend_536a5a2dc0b99b47 = function() { return handleError(function (arg0, arg1) {
|
||||||
|
arg0.prepend(arg1);
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_setAttribute_2704501201f15687 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
||||||
|
arg0.setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
||||||
|
}, arguments) };
|
||||||
|
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
||||||
|
const ret = arg1.stack;
|
||||||
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len1 = WASM_VECTOR_LEN;
|
||||||
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||||
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
||||||
|
const ret = typeof global === 'undefined' ? null : global;
|
||||||
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
|
||||||
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
||||||
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
|
||||||
|
const ret = typeof self === 'undefined' ? null : self;
|
||||||
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
|
||||||
|
const ret = typeof window === 'undefined' ? null : window;
|
||||||
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_warn_aaf1f4664a035bd6 = function(arg0, arg1, arg2, arg3) {
|
||||||
|
console.warn(arg0, arg1, arg2, arg3);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbg_width_5dde457d606ba683 = function(arg0) {
|
||||||
|
const ret = arg0.width;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
||||||
|
const ret = debugString(arg1);
|
||||||
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||||
|
const len1 = WASM_VECTOR_LEN;
|
||||||
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||||
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_init_externref_table = function() {
|
||||||
|
const table = wasm.__wbindgen_export_2;
|
||||||
|
const offset = table.grow(4);
|
||||||
|
table.set(0, undefined);
|
||||||
|
table.set(offset + 0, undefined);
|
||||||
|
table.set(offset + 1, null);
|
||||||
|
table.set(offset + 2, true);
|
||||||
|
table.set(offset + 3, false);
|
||||||
|
;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
||||||
|
const ret = arg0 === undefined;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
||||||
|
const ret = getStringFromWasm0(arg0, arg1);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
||||||
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||||
|
};
|
||||||
|
|
||||||
|
return imports;
|
||||||
|
}
|
||||||
|
|
||||||
|
function __wbg_init_memory(imports, memory) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function __wbg_finalize_init(instance, module) {
|
||||||
|
wasm = instance.exports;
|
||||||
|
__wbg_init.__wbindgen_wasm_module = module;
|
||||||
|
cachedDataViewMemory0 = null;
|
||||||
|
cachedUint8ArrayMemory0 = null;
|
||||||
|
|
||||||
|
|
||||||
|
wasm.__wbindgen_start();
|
||||||
|
return wasm;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initSync(module) {
|
||||||
|
if (wasm !== undefined) return wasm;
|
||||||
|
|
||||||
|
|
||||||
|
if (typeof module !== 'undefined') {
|
||||||
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
||||||
|
({module} = module)
|
||||||
|
} else {
|
||||||
|
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const imports = __wbg_get_imports();
|
||||||
|
|
||||||
|
__wbg_init_memory(imports);
|
||||||
|
|
||||||
|
if (!(module instanceof WebAssembly.Module)) {
|
||||||
|
module = new WebAssembly.Module(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
const instance = new WebAssembly.Instance(module, imports);
|
||||||
|
|
||||||
|
return __wbg_finalize_init(instance, module);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function __wbg_init(module_or_path) {
|
||||||
|
if (wasm !== undefined) return wasm;
|
||||||
|
|
||||||
|
|
||||||
|
if (typeof module_or_path !== 'undefined') {
|
||||||
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
||||||
|
({module_or_path} = module_or_path)
|
||||||
|
} else {
|
||||||
|
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof module_or_path === 'undefined') {
|
||||||
|
module_or_path = new URL('vtracer_webapp_bg.wasm', import.meta.url);
|
||||||
|
}
|
||||||
|
const imports = __wbg_get_imports();
|
||||||
|
|
||||||
|
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
||||||
|
module_or_path = fetch(module_or_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
__wbg_init_memory(imports);
|
||||||
|
|
||||||
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
||||||
|
|
||||||
|
return __wbg_finalize_init(instance, module);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { initSync };
|
||||||
|
export default __wbg_init;
|
||||||
|
window.vtracerInit = __wbg_init;
|
||||||
|
window.ColorImageConverter = ColorImageConverter;
|
||||||
Binary file not shown.
@@ -0,0 +1,111 @@
|
|||||||
|
// Assumes vtracer_webapp.js, vtracer_webapp_bg.wasm, and vtracer_webapp.d.ts are in './wasm/'
|
||||||
|
|
||||||
|
export interface ColorVTracerOptions {
|
||||||
|
wasmPath?: string // custom path to vtracer_webapp_bg.wasm
|
||||||
|
potraceOptions?: any // options for Potrace
|
||||||
|
// VTracer and Potrace options can be passed through
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createCanvasFromFile(file: File | Blob): Promise<HTMLCanvasElement> {
|
||||||
|
// Convert File → data URL
|
||||||
|
const dataUrl = await new Promise<string>((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => resolve(reader.result as string);
|
||||||
|
reader.onerror = reject;
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load image
|
||||||
|
const img = await new Promise<HTMLImageElement>((resolve, reject) => {
|
||||||
|
const image = new Image();
|
||||||
|
image.onload = () => resolve(image);
|
||||||
|
image.onerror = reject;
|
||||||
|
image.src = dataUrl;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create canvas
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = img.width;
|
||||||
|
canvas.height = img.height;
|
||||||
|
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
if (!ctx) {
|
||||||
|
throw new Error('Unable to get 2D context');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw image into canvas
|
||||||
|
ctx.drawImage(img, 0, 0);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert PNG/JPG to SVG using VTracer (color) or Potrace (B/W)
|
||||||
|
* @param image File, Blob, or ArrayBuffer
|
||||||
|
* @param options SVGit4MeOptions (use 'wasmPath' to customize WASM location for VTracer)
|
||||||
|
* @returns SVG string
|
||||||
|
*/
|
||||||
|
export async function convertToSVG(
|
||||||
|
image: File | Blob,
|
||||||
|
options: ColorVTracerOptions = {},
|
||||||
|
): Promise<string> {
|
||||||
|
// Decide which engine to use
|
||||||
|
|
||||||
|
// Use VTracer for color (default)
|
||||||
|
let vtracerInit: any;
|
||||||
|
let ColorImageConverter: any;
|
||||||
|
if (typeof window !== 'undefined' && (window as any).ColorImageConverter) {
|
||||||
|
// Loaded globally (e.g. via <Script src="/vtracer_webapp.js" /> in Next.js)
|
||||||
|
vtracerInit = (window as any).default || (window as any).vtracerInit;
|
||||||
|
ColorImageConverter = (window as any).ColorImageConverter;
|
||||||
|
}
|
||||||
|
if (options.wasmPath) {
|
||||||
|
await vtracerInit(options.wasmPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await vtracerInit();
|
||||||
|
}
|
||||||
|
// Create a hidden SVG element in the DOM
|
||||||
|
const svgId = options.svg_id || `svgit4me-svg-${Math.random().toString(36).slice(2)}`;
|
||||||
|
let svgElem = document.getElementById(svgId) as SVGSVGElement | null;
|
||||||
|
if (!svgElem) {
|
||||||
|
svgElem = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as SVGSVGElement;
|
||||||
|
svgElem.setAttribute('id', svgId);
|
||||||
|
svgElem.style.display = 'none';
|
||||||
|
document.body.appendChild(svgElem);
|
||||||
|
}
|
||||||
|
// Add svg_id to options for WASM
|
||||||
|
options.svg_id = svgId;
|
||||||
|
|
||||||
|
// Create a hidden SVG element in the DOM
|
||||||
|
const canvasId = options.canvas_id || `svgit4me-canvas-${Math.random().toString(36).slice(2)}`;
|
||||||
|
let canvasElem = document.getElementById(canvasId) as HTMLCanvasElement | null;
|
||||||
|
if (!canvasElem) {
|
||||||
|
canvasElem = await createCanvasFromFile(image);
|
||||||
|
canvasElem.setAttribute('id', canvasId);
|
||||||
|
canvasElem.style.display = 'none';
|
||||||
|
document.body.appendChild(canvasElem);
|
||||||
|
}
|
||||||
|
// Add canvas_id to options for WASM
|
||||||
|
options.canvas_id = canvasId;
|
||||||
|
|
||||||
|
options.max_iterations = 10;
|
||||||
|
|
||||||
|
const params = JSON.stringify(options);
|
||||||
|
const converter = ColorImageConverter.new_with_string(params);
|
||||||
|
converter.init();
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
while (!converter.tick()) {}
|
||||||
|
// Get the SVG string from the DOM
|
||||||
|
let svgString = '';
|
||||||
|
if (svgElem) {
|
||||||
|
svgString = new XMLSerializer().serializeToString(svgElem);
|
||||||
|
svgString = svgString.replace(/<svg[^>]*>/,
|
||||||
|
`<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns="http://www.w3.org/2000/svg" width="${canvasElem.width}" height="${canvasElem.height}" viewBox="0 0 ${canvasElem.width} ${canvasElem.height}" version="1.1">`);
|
||||||
|
converter.free();
|
||||||
|
svgElem.remove();
|
||||||
|
canvasElem.remove();
|
||||||
|
}
|
||||||
|
return svgString;
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
declare module 'esm-potrace-wasm' {
|
||||||
|
export function potrace(
|
||||||
|
imageBitmapSource: ImageBitmapSource,
|
||||||
|
options: Object
|
||||||
|
): Promise<string>;
|
||||||
|
export function init(): Promise<void>;
|
||||||
|
}
|
||||||
+169
-21
@@ -5,6 +5,9 @@ import type { Ref } from 'vue';
|
|||||||
import potrace from 'potrace';
|
import potrace from 'potrace';
|
||||||
import { Base64 } from 'js-base64';
|
import { Base64 } from 'js-base64';
|
||||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||||
|
import { potrace as colorPotrace, init as colorPotraceInit } from 'esm-potrace-wasm';
|
||||||
|
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||||
|
import { convertToSVG } from './colorVTracer';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
@@ -42,22 +45,92 @@ function file2Buffer(file: File) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const posterize = ref(true);
|
// import vtracer as JS module populating window.vtracerInit and ColorImageConverter
|
||||||
|
const base = import.meta.env.BASE_URL ?? '/';
|
||||||
|
const { load: loadVTracer } = useScriptTag(`${base}vtracer/vtracer_webapp.js`, undefined, { type: 'module', manual: true });
|
||||||
|
await loadVTracer();
|
||||||
|
|
||||||
|
const file2Blob = async (file: File) => new Blob([new Uint8Array(await file.arrayBuffer())], { type: file.type });
|
||||||
|
|
||||||
|
const processing = ref(false);
|
||||||
|
|
||||||
|
const colorspace = useQueryParamOrStorage<'bw' | 'gray' | 'color' | 'vtracer'>({ name: 'mode', storageName: 'potrace:m', defaultValue: 'bw' });
|
||||||
|
|
||||||
|
const hierarchical = useQueryParamOrStorage<'stacked' | 'cutout'>({ name: 'hierarchical', storageName: 'potrace:h', defaultValue: 'stacked' });
|
||||||
|
const filter_speckle = useQueryParamOrStorage<number>({ name: 'filter_speckle', storageName: 'potrace:fs', defaultValue: 4 });
|
||||||
|
const corner_threshold = useQueryParamOrStorage<number>({ name: 'corner_threshold', storageName: 'potrace:ct', defaultValue: 60 });
|
||||||
|
const color_precision = useQueryParamOrStorage<number>({ name: 'color_precision', storageName: 'potrace:cp', defaultValue: 6 });
|
||||||
|
const length_threshold = useQueryParamOrStorage<number>({ name: 'length_threshold', storageName: 'potrace:lt', defaultValue: 4 });
|
||||||
|
const splice_threshold = useQueryParamOrStorage<number>({ name: 'splice_threshold', storageName: 'potrace:st', defaultValue: 45 });
|
||||||
|
const layer_difference = useQueryParamOrStorage<number>({ name: 'layer_difference', storageName: 'potrace:ld', defaultValue: 16 });
|
||||||
|
const fitting = useQueryParamOrStorage<'pixel' | 'polygon' | 'spline'>({ name: 'fit', storageName: 'potrace:f', defaultValue: 'spline' });
|
||||||
|
|
||||||
|
const interpolate = ref(false);
|
||||||
const fileInput = ref() as Ref<File>;
|
const fileInput = ref() as Ref<File>;
|
||||||
const svg = computedAsync(async () => {
|
const svg = ref<string>('');
|
||||||
const trace = !posterize.value;
|
|
||||||
|
function deg2rad(deg: number) {
|
||||||
|
return deg / 180 * 3.141592654;
|
||||||
|
}
|
||||||
|
async function computeSVG() {
|
||||||
const file = fileInput.value;
|
const file = fileInput.value;
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const colorspaceValue = colorspace.value;
|
||||||
|
const interpolateValue = interpolate.value;
|
||||||
|
|
||||||
|
processing.value = true;
|
||||||
try {
|
try {
|
||||||
const buffer = await file2Buffer(file);
|
switch (colorspaceValue) {
|
||||||
return (trace ? await traceAsync(buffer) : await posterizeAsync(buffer));
|
case 'bw':
|
||||||
|
svg.value = await traceAsync(await file2Buffer(file));
|
||||||
|
break;
|
||||||
|
case 'gray':
|
||||||
|
svg.value = await posterizeAsync(await file2Buffer(file));
|
||||||
|
break;
|
||||||
|
case 'color':
|
||||||
|
await colorPotraceInit();
|
||||||
|
|
||||||
|
svg.value = await colorPotrace(await file2Blob(file), {
|
||||||
|
turdsize: 2,
|
||||||
|
turnpolicy: 4, // minority
|
||||||
|
alphamax: 1,
|
||||||
|
opticurve: 1,
|
||||||
|
opttolerance: 0.2,
|
||||||
|
pathonly: false,
|
||||||
|
extractcolors: true,
|
||||||
|
posterizelevel: 2,
|
||||||
|
posterizationalgorithm: interpolateValue ? 1 : 0,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'vtracer':
|
||||||
|
svg.value = await convertToSVG(file, {
|
||||||
|
color: true,
|
||||||
|
color_precision: 8 - color_precision.value,
|
||||||
|
corner_threshold: deg2rad(corner_threshold.value),
|
||||||
|
filter_speckle: filter_speckle.value * filter_speckle.value,
|
||||||
|
hierarchical: hierarchical.value,
|
||||||
|
length_threshold: length_threshold.value,
|
||||||
|
splice_threshold: deg2rad(splice_threshold.value),
|
||||||
|
mode: fitting.value,
|
||||||
|
wasmPath: `${base}vtracer/vtracer_webapp_bg.wasm`,
|
||||||
|
clustering_mode: 'color',
|
||||||
|
layer_difference: layer_difference.value,
|
||||||
|
path_precision: 8,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (e: any) {
|
catch (e: any) {
|
||||||
return e.toString();
|
svg.value = e.toString();
|
||||||
}
|
}
|
||||||
});
|
finally {
|
||||||
|
processing.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const svgBase64 = computed(() => svg.value ? `data:image/svg+xml;base64,${Base64.encode(svg.value)}` : '');
|
const svgBase64 = computed(() => svg.value ? `data:image/svg+xml;base64,${Base64.encode(svg.value)}` : '');
|
||||||
|
|
||||||
@@ -76,28 +149,103 @@ async function onUpload(file: File) {
|
|||||||
@file-upload="onUpload"
|
@file-upload="onUpload"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div style="text-align: center;">
|
<n-space justify="center" mb-2>
|
||||||
<n-checkbox v-model:checked="posterize" mt-2>
|
<n-radio-group v-model:value="colorspace" mt-2>
|
||||||
{{ t('tools.potrace.texts.tag-posterize') }}
|
<n-radio value="bw">
|
||||||
</n-checkbox>
|
{{ $t('tools.potrace.texts.bw') }}
|
||||||
|
</n-radio>
|
||||||
|
<n-radio value="gray">
|
||||||
|
{{ $t('tools.color-converter.texts.label-grayscale') }}
|
||||||
|
</n-radio>
|
||||||
|
<n-radio value="color">
|
||||||
|
{{ $t('tools.potrace.texts.color-potrace') }}
|
||||||
|
</n-radio>
|
||||||
|
<n-radio value="vtracer">
|
||||||
|
{{ $t('tools.potrace.texts.color-vtracer') }}
|
||||||
|
</n-radio>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<div v-if="colorspace === 'color'" mb-2>
|
||||||
|
<n-space justify="center" mt-2>
|
||||||
|
<n-form-item label-placement="left">
|
||||||
|
<n-checkbox v-model:checked="interpolate">
|
||||||
|
{{ $t('tools.potrace.texts.interpolate') }}
|
||||||
|
</n-checkbox>
|
||||||
|
</n-form-item>
|
||||||
|
</n-space>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<n-divider />
|
<div v-if="colorspace === 'vtracer'" mb-2>
|
||||||
|
<n-space justify="center" wrap mt-2>
|
||||||
|
<n-form-item :label="$t('tools.potrace.texts.curve-fitting')" label-placement="left">
|
||||||
|
<n-select
|
||||||
|
v-model:value="fitting"
|
||||||
|
:options="[
|
||||||
|
{ label: t('tools.potrace.texts.pixel'), value: 'pixel' },
|
||||||
|
{ label: t('tools.potrace.texts.polygon'), value: 'polygon' },
|
||||||
|
{ label: t('tools.potrace.texts.spline'), value: 'spline' },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
|
||||||
|
<n-form-item :label="$t('tools.potrace.texts.hierarchical-mode')" label-placement="left">
|
||||||
|
<n-select
|
||||||
|
v-model:value="hierarchical"
|
||||||
|
:options="[
|
||||||
|
{ label: t('tools.potrace.texts.stacked'), value: 'stacked' },
|
||||||
|
{ label: t('tools.potrace.texts.cutout'), value: 'cutout' },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
|
||||||
|
<n-form-item :label="$t('tools.potrace.texts.filter-speckle-cleaner')" label-placement="left" :title="$t('tools.potrace.texts.discard-patches-small-than-x-px-in-size')">
|
||||||
|
<n-input-number v-model:value="filter_speckle" min="0" max="128" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="$t('tools.potrace.texts.gradient-step-less-layers')" label-placement="left" :title="$t('tools.potrace.texts.color-difference-between-gradient-layers')">
|
||||||
|
<n-input-number v-model:value="layer_difference" min="0" max="255" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item :label="$t('tools.potrace.texts.color-precision-more-accurate')" label-placement="left" :title="$t('tools.potrace.texts.number-of-significant-bits-to-use-in-a-rgb-channel')">
|
||||||
|
<n-input-number v-model:value="color_precision" min="1" max="8" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item v-if="fitting === 'spline'" :label="$t('tools.potrace.texts.corner-threshold-smoother')" label-placement="left" :title="$t('tools.potrace.texts.minimum-momentary-angle-in-degrees-to-be-considered-a-corner-to-be-kept-after-smoothing')">
|
||||||
|
<n-input-number v-model:value="corner_threshold" min="0" max="180" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item v-if="fitting === 'spline'" :label="$t('tools.potrace.texts.length-threshold-more-coarse')" label-placement="left" :title="$t('tools.potrace.texts.perform-iterative-subdivide-smooth-until-all-segments-are-shorter-than-this-length')">
|
||||||
|
<n-input-number v-model:value="length_threshold" min="3.5" max="10" step="0.5" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item v-if="fitting === 'spline'" :label="$t('tools.potrace.texts.splice-threshold-more-accurate')" label-placement="left" :title="$t('tools.potrace.texts.minimum-angle-displacement-in-degrees-to-be-considered-a-cutting-point-between-curves')">
|
||||||
|
<n-input-number v-model:value="splice_threshold" min="0" max="180" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-space>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<n-space justify="center" mb-2>
|
||||||
|
<n-button
|
||||||
|
:disabled="!fileInput"
|
||||||
|
@click="computeSVG"
|
||||||
|
>
|
||||||
|
{{ t('tools.potrace.texts.button-trace') }}
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<n-space v-if="processing" justify="center" mb-2>
|
||||||
|
<n-spin />
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<n-card v-if="svg && !processing" :title="t('tools.potrace.texts.tag-potrace-result')">
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<img width="300" :src="svgBase64" style="background-color: white">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<n-divider />
|
||||||
|
|
||||||
<div>
|
|
||||||
<h3>{{ t('tools.potrace.texts.tag-potrace-result') }}</h3>
|
|
||||||
<TextareaCopyable
|
<TextareaCopyable
|
||||||
:value="svg"
|
:value="svg"
|
||||||
word-wrap
|
word-wrap
|
||||||
download-file-name="output.svg"
|
download-file-name="output.svg"
|
||||||
/>
|
/>
|
||||||
|
</n-card>
|
||||||
<n-divider />
|
|
||||||
|
|
||||||
<div style="text-align: center;">
|
|
||||||
<img width="150" :src="svgBase64" style="background-color: white">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user