@wasmedia/wexiftool 0.1.0 → 0.1.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.
- package/dist/cli.cjs +1 -1
- package/dist/cli.es.js +1 -1
- package/dist/{index-D8B3sucz.js → index-BUUKaFua.js} +2 -2
- package/dist/{index-B49L_wsJ.cjs → index-Czh_jOH1.cjs} +1 -1
- package/dist/{node-CRF3Yhkk.cjs → node-6KJNNt7l.cjs} +1 -1
- package/dist/{node-P4tq-yoT.js → node-WHSUCdKF.js} +2 -2
- package/dist/{wexiftool-CL0NBE7L.js → wexiftool-CUKoJisL.js} +19 -19
- package/dist/{wexiftool-DICKi0_a.cjs → wexiftool-Dt9AnMsh.cjs} +3 -3
- package/dist/wexiftool.cjs +1 -1
- package/dist/wexiftool.es.js +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.es.js +2 -2
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";const f=require("fs"),u=require("path"),p=require("./wexiftool-
|
|
2
|
+
"use strict";const f=require("fs"),u=require("path"),p=require("./wexiftool-Dt9AnMsh.cjs");async function d(){const t=process.argv.slice(2);t.length===0&&(w(),process.exit(1));const{flags:o,filePaths:i}=x(t);if(o.includes("-ver")||o.includes("-version")){const e=await p.WExifTool.create(),n=await e.exec([...o]);process.stdout.write(n.stdout+`
|
|
3
3
|
`),n.stderr&&process.stderr.write(n.stderr+`
|
|
4
4
|
`),e.destroy(),process.exit(n.exitCode)}i.length===0&&(console.error("Error: No input files specified."),process.exit(1));for(const e of i){const n=u.resolve(e);f.existsSync(n)||(console.error(`Error: File not found: ${e}`),process.exit(1)),f.statSync(n).isFile()||(console.error(`Error: Not a file: ${e}`),process.exit(1))}const c=o.some(e=>e.includes("=")&&e.startsWith("-")&&!e.startsWith("-if")),s=await p.WExifTool.create(),r=new Map(i.map(e=>[e,e])),a=[...o,...i];c&&!o.includes("-overwrite_original")&&!o.includes("-overwrite_original_in_place")&&a.unshift("-overwrite_original");const l=await s.exec(a,r,{writeBack:c});l.stdout&&process.stdout.write(l.stdout+`
|
|
5
5
|
`),l.stderr&&process.stderr.write(l.stderr+`
|
package/dist/cli.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync as p, statSync as u } from "fs";
|
|
3
3
|
import { resolve as d } from "path";
|
|
4
|
-
import { W as f } from "./wexiftool-
|
|
4
|
+
import { W as f } from "./wexiftool-CUKoJisL.js";
|
|
5
5
|
async function x() {
|
|
6
6
|
const t = process.argv.slice(2);
|
|
7
7
|
t.length === 0 && (h(), process.exit(1));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var Y = (e, t, n) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var O = (e, t, n) => Y(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { a as b, b as $, c as z, d as H, e as D, f as I, g as L } from "./wexiftool-
|
|
4
|
+
import { a as b, b as $, c as z, d as H, e as D, f as I, g as L } from "./wexiftool-CUKoJisL.js";
|
|
5
5
|
function q(e) {
|
|
6
6
|
if (!e.startsWith("/") || e === "/" || e.endsWith("/"))
|
|
7
7
|
throw new b(`mountpoint must be an absolute path other than "/", without a trailing slash: ${e}`);
|
|
@@ -646,7 +646,7 @@ async function bt(e, t, n = {}) {
|
|
|
646
646
|
if (l === "memfs")
|
|
647
647
|
return P(e, t, s);
|
|
648
648
|
if (l === "node") {
|
|
649
|
-
const { openNodeBackend: f } = await import("./node-
|
|
649
|
+
const { openNodeBackend: f } = await import("./node-WHSUCdKF.js");
|
|
650
650
|
return v(e, t, await f(s));
|
|
651
651
|
}
|
|
652
652
|
if (l !== "opfs")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var B=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var O=(e,t,n)=>B(e,typeof t!="symbol"?t+"":t,n);const p=require("./wexiftool-DICKi0_a.cjs");function L(e){if(!e.startsWith("/")||e==="/"||e.endsWith("/"))throw new p.WopfsInputError(`mountpoint must be an absolute path other than "/", without a trailing slash: ${e}`)}function q(e){if(e.split("/").some(n=>n===""||n==="."||n===".."))throw new p.WopfsInputError(`input path must be relative and normalized: ${JSON.stringify(e)}`)}function P(e,t){const n=e.analyzePath(t);if(n.exists){if(!n.object||!e.isDir(n.object.mode))throw new p.WopfsInputError(`${t} exists and is not a directory`);return[]}const r=t.split("/").slice(1),a=r.map((f,l)=>"/"+r.slice(0,l+1).join("/")).filter(f=>!e.analyzePath(f).exists);return e.mkdirTree(t),a}function k(e,t){for(const n of[...t].reverse())e.rmdir(n)}function I(e,t){for(const n of e.streams)if(n&&n.node.mount===t)try{e.close(n)}catch{}}function U(e,t){return(t==null?void 0:t.name)==="ErrnoError"?new p.WopfsInputError(`cannot mount at ${e} (errno ${t.errno}); is it already a mount point?`,{cause:t}):t}function v(e,t,n,r){I(e,n);const a=r[0]??t,f=e.cwd();(f===a||f.startsWith(`${a}/`))&&e.chdir(a.slice(0,a.lastIndexOf("/"))||"/");try{e.unmount(t)}catch(l){const h=l==null?void 0:l.errno;throw new p.WopfsStateError(`cannot unmount ${t} (errno ${h}); release() can be retried`,{cause:l})}k(e,r)}function H(){var r,a;const e=globalThis;if((a=(r=e.process)==null?void 0:r.versions)!=null&&a.node&&typeof e.window>"u")return"node";const t=e.DedicatedWorkerGlobalScope,n=e.FileSystemFileHandle;return typeof t=="function"&&globalThis instanceof t&&n&&"createSyncAccessHandle"in n.prototype?"opfs":"memfs"}const J=["ErrnoError","createNode","hashRemoveNode","isDir","isFile","mount","unmount","lookupPath","analyzePath","mkdirTree","rmdir","readdir","writeFile","readFile","chmod","close","cwd","chdir"];function V(e){var r;const t=e==null?void 0:e.FS;if(!t)throw new p.WopfsRuntimeError("module has no FS export; build it with -sEXPORTED_RUNTIME_METHODS=FS");const n=J.filter(a=>typeof t[a]!="function");if(Array.isArray(t.streams)||n.push("streams"),(r=t.filesystems)!=null&&r.MEMFS||n.push("filesystems.MEMFS"),n.length)throw new p.WopfsRuntimeError(`module.FS is missing ${n.join(", ")}: this Emscripten's FS internals differ from the ones wopfs supports (emsdk 5.0.5, 5.0.6)`)}const b={EACCES:2,EINVAL:28,EIO:29,ENODEV:43,ENOENT:44,ENOSPC:51,ENOTEMPTY:55,EPERM:63,EROFS:69},Y=0,K=1,Q=2,G=61440,x=16384,X=32768,N=x|511,Z=X|292,g=e=>(e.mode&G)===x;function tt(e){const t=e._malloc;return typeof t!="function"||!e.HEAPU8?()=>null:n=>{const r=t(n);return r?{ptr:r,heap:e.HEAPU8,free:()=>{var a;return(a=e._free)==null?void 0:a.call(e,r)}}:null}}function et(e,t){const n=o=>new e.ErrnoError(o);function r(o){try{return o()}catch(s){const{name:i,code:c}=s??{};throw i==="ErrnoError"?s:n(i==="QuotaExceededError"||c==="ENOSPC"||c==="EDQUOT"?b.ENOSPC:b.EIO)}}const a=o=>o.wopfs;function f(o,s,i,c){const u=e.createNode(o,s,i,0);return u.node_ops=E,u.stream_ops=d,u.atime=u.mtime=u.ctime=Date.now(),g(u)?u.contents=Object.create(null):u.wopfs=c,o&&(o.contents[s]=u,o.mtime=o.ctime=u.mtime),u}function l(o){const s=o.wopfs;!s||s.input||(s.unlinked=!0,s.openCount===0&&t.discardFile(s.file))}function h(o){const s=a(o);if(s.input)throw n(b.EACCES);return s}const m=o=>{o.mtime=o.ctime=Date.now()},E={getattr(o){const s=g(o)?4096:a(o).size;return{dev:1,ino:o.id,mode:o.mode,nlink:1,uid:0,gid:0,rdev:0,size:s,atime:new Date(o.atime),mtime:new Date(o.mtime),ctime:new Date(o.ctime),blksize:4096,blocks:Math.ceil(s/4096)}},setattr(o,s){for(const i of["mode","atime","mtime","ctime"])s[i]!=null&&(o[i]=s[i]);if(s.size!==void 0){const i=h(o),c=s.size;r(()=>i.file.truncate(c)),i.size=c,m(o)}},lookup(o,s){const i=o.contents[s];if(i)return i;throw n(b.ENOENT)},mknod(o,s,i){if(t.readOnly)throw n(b.EROFS);if(e.isDir(i))return f(o,s,i);if(!e.isFile(i))throw n(b.EPERM);const c=r(()=>t.createFile());if(!c)throw n(b.ENOSPC);return f(o,s,i,{file:c,size:0,input:!1,openCount:0,unlinked:!1})},rename(o,s,i){const c=s.contents[i];if(c){if(g(c)&&Object.keys(c.contents).length)throw n(b.ENOTEMPTY);e.hashRemoveNode(c),l(c)}delete o.parent.contents[o.name],s.contents[i]=o,o.name=i,m(s),m(o.parent)},unlink(o,s){const i=o.contents[s];delete o.contents[s],m(o),l(i)},rmdir(o,s){const i=o.contents[s];if(Object.keys(i.contents).length)throw n(b.ENOTEMPTY);delete o.contents[s],m(o)},readdir(o){return[".","..",...Object.keys(o.contents)]},symlink(){throw n(b.EPERM)}},d={open(o){if(g(o.node))return;const s=(o.flags&3)===Y?a(o.node):h(o.node);s.openCount++},dup(o){g(o.node)||a(o.node).openCount++},close(o){if(g(o.node))return;const s=a(o.node);s.openCount--,s.unlinked?s.openCount===0&&t.discardFile(s.file):s.input||r(()=>s.file.flush())},read(o,s,i,c,u){const w=a(o.node);if(u>=w.size)return 0;const y=Math.min(c,w.size-u);return r(()=>w.file.read(new Uint8Array(s.buffer,s.byteOffset+i,y),u))},write(o,s,i,c,u){if(!c)return 0;const w=h(o.node),y=r(()=>w.file.write(new Uint8Array(s.buffer,s.byteOffset+i,c),u));return w.size=Math.max(w.size,u+y),m(o.node),y},llseek(o,s,i){let c=s;if(i===K?c+=o.position:i===Q&&!g(o.node)&&(c+=a(o.node).size),c<0)throw n(b.EINVAL);return c},mmap(o,s,i){if(g(o.node))throw n(b.ENODEV);const c=t.mmapAlloc(s);if(!c)throw n(b.ENODEV);const u=c.heap.subarray(c.ptr,c.ptr+s),w=a(o.node),y=i<w.size?Math.min(s,w.size-i):0;if(y)try{r(()=>w.file.read(u.subarray(0,y),i))}catch(W){throw c.free(),W}return u.fill(0,y),{ptr:c.ptr,allocated:!0}},msync(o,s,i,c){return d.write(o,s,0,c,i),0},fsync(o){return g(o.node)||r(()=>a(o.node).file.flush()),0}};return{mount(o){const s=f(null,"/",N);s.mount=o;for(const{path:i,file:c}of o.opts.inputs??[]){const u=i.split("/");let w=s;for(const y of u.slice(0,-1))w=w.contents[y]??f(w,y,N);f(w,u[u.length-1],Z,{file:c,size:c.getSize(),input:!0,openCount:0,unlinked:!1})}return s},node_ops:E,stream_ops:d}}function nt(e){const t=[],n=(r,a)=>{for(const[f,l]of Object.entries(r.contents)){const h=a?`${a}/${f}`:f;g(l)?n(l,h):l.wopfs&&!l.wopfs.input&&t.push({path:h,backing:l.wopfs})}};return n(e,""),t.sort((r,a)=>r.path<a.path?-1:r.path>a.path?1:0)}class M{constructor(t){O(this,"data");O(this,"size");this.data=t??new Uint8Array(0),this.size=this.data.length}read(t,n){const r=Math.max(0,Math.min(t.length,this.size-n));return t.set(this.data.subarray(n,n+r)),r}write(t,n){const r=n+t.length;return this.reserve(r),n>this.size&&this.data.fill(0,this.size,n),this.data.set(t,n),this.size=Math.max(this.size,r),t.length}truncate(t){t>this.size&&(this.reserve(t),this.data.fill(0,this.size,t)),this.size=t}getSize(){return this.size}flush(){}close(){}bytes(){return this.data.subarray(0,this.size)}reserve(t){if(t<=this.data.length)return;const n=new Uint8Array(Math.max(t,this.data.length*2,4096));n.set(this.data.subarray(0,this.size)),this.data=n}}function rt(e){let t=!1;return{read:(n,r)=>e.read(n,{at:r}),write:(n,r)=>e.write(n,{at:r}),truncate:n=>e.truncate(n),getSize:()=>e.getSize(),flush:()=>e.flush(),close:()=>{t||(t=!0,e.close())}}}const ot=1<<20;function st(e,t,n){const r=new Uint8Array(Math.min(ot,Math.max(n,1)));t.truncate(0);for(let a=0;a<n;){const f=e.read(r.subarray(0,Math.min(r.length,n-a)),a);if(f<=0)break;t.write(r.subarray(0,f),a),a+=f}}class D{constructor(t){O(this,"options");O(this,"slots");O(this,"free");O(this,"byFile",new Map);O(this,"warned",!1);this.options=t,this.slots=[...t.preopened??[]],this.free=[...this.slots].reverse();for(const n of this.slots)this.byFile.set(n.file,n)}acquire(){let t=this.free.pop();return!t&&this.options.open&&this.slots.length<this.options.capacity&&(t=this.options.open(this.slots.length),this.slots.push(t),this.byFile.set(t.file,t)),t?t.file:this.options.onExhausted==="strict"?null:(this.warned||(this.warned=!0,this.options.warn(`wopfs: scratch pool of ${this.options.capacity} exhausted; holding further new files in memory until commit()`)),new M)}discard(t){const n=this.byFile.get(t);if(n){try{t.truncate(0)}catch{return}this.free.push(n)}}slotOf(t){return this.byFile.get(t)}}function it(e,t,n){const r=e.FS,a=P(r,t),f=et(r,{createFile:()=>n.pool.acquire(),discardFile:m=>n.pool.discard(m),mmapAlloc:tt(e),readOnly:n.readOnly});let l;try{l=r.mount(f,{inputs:n.inputs},t)}catch(m){throw k(r,a),U(t,m)}let h="mounted";return{backend:n.kind,mountpoint:t,async commit(){if(h!=="mounted")throw new p.WopfsStateError(`commit() on a mount that is ${h}`);h="committing",I(r,l.mount);for(const{file:E}of n.inputs)E.close();const m=[];try{for(const{path:E,backing:d}of nt(l))m.push(await n.commitFile(E,d.file,d.size))}catch(E){throw new p.WopfsCommitError(m,E)}return h="committed",m},async release(){if(h!=="released"){h="releasing";try{v(r,t,l.mount,a)}finally{await n.release()}h="released"}}}}function T(e,t,n){return{kind:e,inputs:t,readOnly:!0,pool:new D({capacity:0,onExhausted:"strict",warn:()=>{}}),async commitFile(r){throw new p.WopfsStateError(`an input-only mount (no outputDir) cannot commit ${r}`)},release:n}}function _(e){return typeof e=="object"&&e!==null&&e.kind==="file"&&typeof e.getFile=="function"}function at(e){return typeof e=="object"&&e!==null&&e.kind==="directory"&&typeof e.getFileHandle=="function"}const ct={opfs:"a FileSystemFileHandle, Uint8Array or Blob",node:"a host path string, Uint8Array or Blob",memfs:"a Uint8Array, Blob or FileSystemFileHandle"};async function z(e,t,n){if(e instanceof Uint8Array)return e;if(typeof Blob<"u"&&e instanceof Blob)return new Uint8Array(await e.arrayBuffer());if(n==="memfs"&&_(e))return new Uint8Array(await(await e.getFile()).arrayBuffer());throw new p.WopfsInputError(`input ${t}: the ${n} backend takes ${ct[n]}`)}function R(){return globalThis.crypto.randomUUID().slice(0,8)}async function $(e,t){let n;try{n=await e.createSyncAccessHandle()}catch(r){const a=r==null?void 0:r.name;throw a==="NoModificationAllowedError"||a==="InvalidStateError"?new p.WopfsLockedError(t,r):r}if(typeof n.getSize()!="number")throw await n.close(),new p.WopfsUnsupportedError("this browser's FileSystemSyncAccessHandle methods are asynchronous; wopfs needs the synchronous ones");return rt(n)}async function ft(e,t,n){try{await e.move(t,n)}catch(r){if((r==null?void 0:r.name)!=="InvalidModificationError")throw r;await t.removeEntry(n),await e.move(t,n)}}async function lt(e,t,n,r,a){const f=await $(t,n);try{st(e,f,r),f.flush()}catch(l){throw f.close(),await a().catch(()=>{}),l}f.close()}async function ut(e){const t=e.outputDir;if(t!==void 0&&!at(t))throw new p.WopfsInputError("the opfs backend needs outputDir to be a FileSystemDirectoryHandle");if(t===void 0&&e.scratch>0)throw new p.WopfsInputError(`scratch (${e.scratch}) needs outputDir: without it the mount is input-only`);const n=[],r=`.wopfs-scratch-${R()}`;let a,f=0;const l=async()=>{for(const h of n)try{h.close()}catch{}a&&await t.removeEntry(r,{recursive:!0}).catch(()=>{})};try{const h=[],m=[];for(const[s,i]of e.inputs)if(_(i)){for(const[u,w]of m)if(await w.isSameEntry(i))throw new p.WopfsInputError(`inputs ${JSON.stringify(u)} and ${JSON.stringify(s)} are the same file`);m.push([s,i]);const c=await $(i,s);n.push(c),h.push({path:s,file:c})}else h.push({path:s,file:new M(await z(i,s,"opfs"))});if(t===void 0)return T("opfs",h,l);if(a=await t.getDirectoryHandle(r,{create:!0}),typeof(await a.getFileHandle("probe",{create:!0})).move!="function")throw new p.WopfsUnsupportedError("this browser's FileSystemFileHandle has no move(); wopfs needs it to commit outputs safely");const d=[];for(let s=0;s<e.scratch;s++){const i=`s${s}`,c=await a.getFileHandle(i,{create:!0}),u=await $(c,`${r}/${i}`);n.push(u),d.push({name:i,file:u,handle:c})}const o=new D({capacity:e.scratch,onExhausted:e.onExhausted,preopened:d,warn:e.warn});return{kind:"opfs",inputs:h,pool:o,async commitFile(s,i,c){const u=s.split("/"),w=u.pop();let y=t;for(const F of u)y=await y.getDirectoryHandle(F,{create:!0});const W=o.slotOf(i);let S;if(W)i.flush(),i.close(),S=W.handle;else{const F=`spill${f++}`;S=await a.getFileHandle(F,{create:!0}),await lt(i,S,`${r}/${F}`,c,()=>a.removeEntry(F)),i.close()}return await ft(S,y,w),{path:s,size:c,handle:S}},release:l}}catch(h){throw await l(),h}}async function A(e,t,n){const r=e.FS,a=[];for(const[d,o]of n.inputs)a.push([d,await z(o,d,"memfs")]);const f=P(r,t);let l;try{l=r.mount(r.filesystems.MEMFS,{},t)}catch(d){throw k(r,f),U(t,d)}const h=new Set;try{for(const[d,o]of a){const s=`${t}/${d}`;r.mkdirTree(s.slice(0,s.lastIndexOf("/"))),r.writeFile(s,o),r.chmod(s,292),h.add(r.lookupPath(s).node)}}catch(d){throw r.unmount(t),k(r,f),d}const m=(d,o,s)=>{for(const i of r.readdir(d)){if(i==="."||i==="..")continue;const c=`${d}/${i}`,u=o?`${o}/${i}`:i,w=r.lookupPath(c).node;if(r.isDir(w.mode))m(c,u,s);else if(r.isFile(w.mode)&&!h.has(w)){const y=r.readFile(c);s.push({path:u,size:y.length,bytes:y})}}};let E="mounted";return{backend:"memfs",mountpoint:t,async commit(){if(E!=="mounted")throw new p.WopfsStateError(`commit() on a mount that is ${E}`);I(r,l.mount);const d=[];return m(t,"",d),E="committed",d.sort((o,s)=>o.path<s.path?-1:o.path>s.path?1:0)},async release(){E!=="released"&&(E="releasing",v(r,t,l.mount,f),E="released")}}}function ht(e){const t=Object.entries(e.inputs??{});for(const[f]of t)q(f);const n=new Set(t.map(([f])=>f));for(const[f]of t){const l=f.split("/");for(let h=1;h<l.length;h++){const m=l.slice(0,h).join("/");if(n.has(m))throw new p.WopfsInputError(`input ${JSON.stringify(m)} is a file, but ${JSON.stringify(f)} needs it to be a directory`)}}const r=e.scratch??(e.outputDir===void 0?0:16);if(!Number.isInteger(r)||r<0)throw new p.WopfsInputError(`scratch must be a non-negative integer: ${r}`);const a=e.onExhausted??"spill";if(a!=="spill"&&a!=="strict")throw new p.WopfsInputError(`onExhausted must be "spill" or "strict": ${a}`);return{inputs:t,outputDir:e.outputDir,scratch:r,onExhausted:a,warn:e.onWarning??(f=>console.warn(f))}}async function C(e,t,n){try{return it(e,t,n)}catch(r){throw await n.release(),r}}async function pt(e,t,n={}){V(e),L(t);const r=ht(n),a=n.backend??"auto",f=a==="auto"?H():a;if(f==="memfs")return A(e,t,r);if(f==="node"){const{openNodeBackend:l}=await Promise.resolve().then(()=>require("./node-CRF3Yhkk.cjs"));return C(e,t,await l(r))}if(f!=="opfs")throw new p.WopfsInputError(`unknown backend: ${String(f)}`);try{return await C(e,t,await ut(r))}catch(l){if(a==="auto"&&l instanceof p.WopfsUnsupportedError)return r.warn(`wopfs: ${l.message}; falling back to memfs`),A(e,t,r);throw l}}const dt=Object.freeze(Object.defineProperty({__proto__:null,WopfsCommitError:p.WopfsCommitError,WopfsError:p.WopfsError,WopfsInputError:p.WopfsInputError,WopfsLockedError:p.WopfsLockedError,WopfsRuntimeError:p.WopfsRuntimeError,WopfsStateError:p.WopfsStateError,WopfsUnsupportedError:p.WopfsUnsupportedError,detectBackend:H,mountFiles:pt},Symbol.toStringTag,{value:"Module"}));exports.MemoryFile=M;exports.ScratchPool=D;exports.bytesOf=z;exports.index=dt;exports.inputOnlyBackend=T;exports.randomId=R;
|
|
1
|
+
"use strict";var j=Object.defineProperty;var B=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var O=(e,t,n)=>B(e,typeof t!="symbol"?t+"":t,n);const p=require("./wexiftool-Dt9AnMsh.cjs");function L(e){if(!e.startsWith("/")||e==="/"||e.endsWith("/"))throw new p.WopfsInputError(`mountpoint must be an absolute path other than "/", without a trailing slash: ${e}`)}function q(e){if(e.split("/").some(n=>n===""||n==="."||n===".."))throw new p.WopfsInputError(`input path must be relative and normalized: ${JSON.stringify(e)}`)}function P(e,t){const n=e.analyzePath(t);if(n.exists){if(!n.object||!e.isDir(n.object.mode))throw new p.WopfsInputError(`${t} exists and is not a directory`);return[]}const r=t.split("/").slice(1),a=r.map((f,l)=>"/"+r.slice(0,l+1).join("/")).filter(f=>!e.analyzePath(f).exists);return e.mkdirTree(t),a}function k(e,t){for(const n of[...t].reverse())e.rmdir(n)}function I(e,t){for(const n of e.streams)if(n&&n.node.mount===t)try{e.close(n)}catch{}}function U(e,t){return(t==null?void 0:t.name)==="ErrnoError"?new p.WopfsInputError(`cannot mount at ${e} (errno ${t.errno}); is it already a mount point?`,{cause:t}):t}function v(e,t,n,r){I(e,n);const a=r[0]??t,f=e.cwd();(f===a||f.startsWith(`${a}/`))&&e.chdir(a.slice(0,a.lastIndexOf("/"))||"/");try{e.unmount(t)}catch(l){const h=l==null?void 0:l.errno;throw new p.WopfsStateError(`cannot unmount ${t} (errno ${h}); release() can be retried`,{cause:l})}k(e,r)}function H(){var r,a;const e=globalThis;if((a=(r=e.process)==null?void 0:r.versions)!=null&&a.node&&typeof e.window>"u")return"node";const t=e.DedicatedWorkerGlobalScope,n=e.FileSystemFileHandle;return typeof t=="function"&&globalThis instanceof t&&n&&"createSyncAccessHandle"in n.prototype?"opfs":"memfs"}const J=["ErrnoError","createNode","hashRemoveNode","isDir","isFile","mount","unmount","lookupPath","analyzePath","mkdirTree","rmdir","readdir","writeFile","readFile","chmod","close","cwd","chdir"];function V(e){var r;const t=e==null?void 0:e.FS;if(!t)throw new p.WopfsRuntimeError("module has no FS export; build it with -sEXPORTED_RUNTIME_METHODS=FS");const n=J.filter(a=>typeof t[a]!="function");if(Array.isArray(t.streams)||n.push("streams"),(r=t.filesystems)!=null&&r.MEMFS||n.push("filesystems.MEMFS"),n.length)throw new p.WopfsRuntimeError(`module.FS is missing ${n.join(", ")}: this Emscripten's FS internals differ from the ones wopfs supports (emsdk 5.0.5, 5.0.6)`)}const b={EACCES:2,EINVAL:28,EIO:29,ENODEV:43,ENOENT:44,ENOSPC:51,ENOTEMPTY:55,EPERM:63,EROFS:69},Y=0,K=1,Q=2,G=61440,x=16384,X=32768,N=x|511,Z=X|292,g=e=>(e.mode&G)===x;function tt(e){const t=e._malloc;return typeof t!="function"||!e.HEAPU8?()=>null:n=>{const r=t(n);return r?{ptr:r,heap:e.HEAPU8,free:()=>{var a;return(a=e._free)==null?void 0:a.call(e,r)}}:null}}function et(e,t){const n=o=>new e.ErrnoError(o);function r(o){try{return o()}catch(s){const{name:i,code:c}=s??{};throw i==="ErrnoError"?s:n(i==="QuotaExceededError"||c==="ENOSPC"||c==="EDQUOT"?b.ENOSPC:b.EIO)}}const a=o=>o.wopfs;function f(o,s,i,c){const u=e.createNode(o,s,i,0);return u.node_ops=E,u.stream_ops=d,u.atime=u.mtime=u.ctime=Date.now(),g(u)?u.contents=Object.create(null):u.wopfs=c,o&&(o.contents[s]=u,o.mtime=o.ctime=u.mtime),u}function l(o){const s=o.wopfs;!s||s.input||(s.unlinked=!0,s.openCount===0&&t.discardFile(s.file))}function h(o){const s=a(o);if(s.input)throw n(b.EACCES);return s}const m=o=>{o.mtime=o.ctime=Date.now()},E={getattr(o){const s=g(o)?4096:a(o).size;return{dev:1,ino:o.id,mode:o.mode,nlink:1,uid:0,gid:0,rdev:0,size:s,atime:new Date(o.atime),mtime:new Date(o.mtime),ctime:new Date(o.ctime),blksize:4096,blocks:Math.ceil(s/4096)}},setattr(o,s){for(const i of["mode","atime","mtime","ctime"])s[i]!=null&&(o[i]=s[i]);if(s.size!==void 0){const i=h(o),c=s.size;r(()=>i.file.truncate(c)),i.size=c,m(o)}},lookup(o,s){const i=o.contents[s];if(i)return i;throw n(b.ENOENT)},mknod(o,s,i){if(t.readOnly)throw n(b.EROFS);if(e.isDir(i))return f(o,s,i);if(!e.isFile(i))throw n(b.EPERM);const c=r(()=>t.createFile());if(!c)throw n(b.ENOSPC);return f(o,s,i,{file:c,size:0,input:!1,openCount:0,unlinked:!1})},rename(o,s,i){const c=s.contents[i];if(c){if(g(c)&&Object.keys(c.contents).length)throw n(b.ENOTEMPTY);e.hashRemoveNode(c),l(c)}delete o.parent.contents[o.name],s.contents[i]=o,o.name=i,m(s),m(o.parent)},unlink(o,s){const i=o.contents[s];delete o.contents[s],m(o),l(i)},rmdir(o,s){const i=o.contents[s];if(Object.keys(i.contents).length)throw n(b.ENOTEMPTY);delete o.contents[s],m(o)},readdir(o){return[".","..",...Object.keys(o.contents)]},symlink(){throw n(b.EPERM)}},d={open(o){if(g(o.node))return;const s=(o.flags&3)===Y?a(o.node):h(o.node);s.openCount++},dup(o){g(o.node)||a(o.node).openCount++},close(o){if(g(o.node))return;const s=a(o.node);s.openCount--,s.unlinked?s.openCount===0&&t.discardFile(s.file):s.input||r(()=>s.file.flush())},read(o,s,i,c,u){const w=a(o.node);if(u>=w.size)return 0;const y=Math.min(c,w.size-u);return r(()=>w.file.read(new Uint8Array(s.buffer,s.byteOffset+i,y),u))},write(o,s,i,c,u){if(!c)return 0;const w=h(o.node),y=r(()=>w.file.write(new Uint8Array(s.buffer,s.byteOffset+i,c),u));return w.size=Math.max(w.size,u+y),m(o.node),y},llseek(o,s,i){let c=s;if(i===K?c+=o.position:i===Q&&!g(o.node)&&(c+=a(o.node).size),c<0)throw n(b.EINVAL);return c},mmap(o,s,i){if(g(o.node))throw n(b.ENODEV);const c=t.mmapAlloc(s);if(!c)throw n(b.ENODEV);const u=c.heap.subarray(c.ptr,c.ptr+s),w=a(o.node),y=i<w.size?Math.min(s,w.size-i):0;if(y)try{r(()=>w.file.read(u.subarray(0,y),i))}catch(W){throw c.free(),W}return u.fill(0,y),{ptr:c.ptr,allocated:!0}},msync(o,s,i,c){return d.write(o,s,0,c,i),0},fsync(o){return g(o.node)||r(()=>a(o.node).file.flush()),0}};return{mount(o){const s=f(null,"/",N);s.mount=o;for(const{path:i,file:c}of o.opts.inputs??[]){const u=i.split("/");let w=s;for(const y of u.slice(0,-1))w=w.contents[y]??f(w,y,N);f(w,u[u.length-1],Z,{file:c,size:c.getSize(),input:!0,openCount:0,unlinked:!1})}return s},node_ops:E,stream_ops:d}}function nt(e){const t=[],n=(r,a)=>{for(const[f,l]of Object.entries(r.contents)){const h=a?`${a}/${f}`:f;g(l)?n(l,h):l.wopfs&&!l.wopfs.input&&t.push({path:h,backing:l.wopfs})}};return n(e,""),t.sort((r,a)=>r.path<a.path?-1:r.path>a.path?1:0)}class M{constructor(t){O(this,"data");O(this,"size");this.data=t??new Uint8Array(0),this.size=this.data.length}read(t,n){const r=Math.max(0,Math.min(t.length,this.size-n));return t.set(this.data.subarray(n,n+r)),r}write(t,n){const r=n+t.length;return this.reserve(r),n>this.size&&this.data.fill(0,this.size,n),this.data.set(t,n),this.size=Math.max(this.size,r),t.length}truncate(t){t>this.size&&(this.reserve(t),this.data.fill(0,this.size,t)),this.size=t}getSize(){return this.size}flush(){}close(){}bytes(){return this.data.subarray(0,this.size)}reserve(t){if(t<=this.data.length)return;const n=new Uint8Array(Math.max(t,this.data.length*2,4096));n.set(this.data.subarray(0,this.size)),this.data=n}}function rt(e){let t=!1;return{read:(n,r)=>e.read(n,{at:r}),write:(n,r)=>e.write(n,{at:r}),truncate:n=>e.truncate(n),getSize:()=>e.getSize(),flush:()=>e.flush(),close:()=>{t||(t=!0,e.close())}}}const ot=1<<20;function st(e,t,n){const r=new Uint8Array(Math.min(ot,Math.max(n,1)));t.truncate(0);for(let a=0;a<n;){const f=e.read(r.subarray(0,Math.min(r.length,n-a)),a);if(f<=0)break;t.write(r.subarray(0,f),a),a+=f}}class D{constructor(t){O(this,"options");O(this,"slots");O(this,"free");O(this,"byFile",new Map);O(this,"warned",!1);this.options=t,this.slots=[...t.preopened??[]],this.free=[...this.slots].reverse();for(const n of this.slots)this.byFile.set(n.file,n)}acquire(){let t=this.free.pop();return!t&&this.options.open&&this.slots.length<this.options.capacity&&(t=this.options.open(this.slots.length),this.slots.push(t),this.byFile.set(t.file,t)),t?t.file:this.options.onExhausted==="strict"?null:(this.warned||(this.warned=!0,this.options.warn(`wopfs: scratch pool of ${this.options.capacity} exhausted; holding further new files in memory until commit()`)),new M)}discard(t){const n=this.byFile.get(t);if(n){try{t.truncate(0)}catch{return}this.free.push(n)}}slotOf(t){return this.byFile.get(t)}}function it(e,t,n){const r=e.FS,a=P(r,t),f=et(r,{createFile:()=>n.pool.acquire(),discardFile:m=>n.pool.discard(m),mmapAlloc:tt(e),readOnly:n.readOnly});let l;try{l=r.mount(f,{inputs:n.inputs},t)}catch(m){throw k(r,a),U(t,m)}let h="mounted";return{backend:n.kind,mountpoint:t,async commit(){if(h!=="mounted")throw new p.WopfsStateError(`commit() on a mount that is ${h}`);h="committing",I(r,l.mount);for(const{file:E}of n.inputs)E.close();const m=[];try{for(const{path:E,backing:d}of nt(l))m.push(await n.commitFile(E,d.file,d.size))}catch(E){throw new p.WopfsCommitError(m,E)}return h="committed",m},async release(){if(h!=="released"){h="releasing";try{v(r,t,l.mount,a)}finally{await n.release()}h="released"}}}}function T(e,t,n){return{kind:e,inputs:t,readOnly:!0,pool:new D({capacity:0,onExhausted:"strict",warn:()=>{}}),async commitFile(r){throw new p.WopfsStateError(`an input-only mount (no outputDir) cannot commit ${r}`)},release:n}}function _(e){return typeof e=="object"&&e!==null&&e.kind==="file"&&typeof e.getFile=="function"}function at(e){return typeof e=="object"&&e!==null&&e.kind==="directory"&&typeof e.getFileHandle=="function"}const ct={opfs:"a FileSystemFileHandle, Uint8Array or Blob",node:"a host path string, Uint8Array or Blob",memfs:"a Uint8Array, Blob or FileSystemFileHandle"};async function z(e,t,n){if(e instanceof Uint8Array)return e;if(typeof Blob<"u"&&e instanceof Blob)return new Uint8Array(await e.arrayBuffer());if(n==="memfs"&&_(e))return new Uint8Array(await(await e.getFile()).arrayBuffer());throw new p.WopfsInputError(`input ${t}: the ${n} backend takes ${ct[n]}`)}function R(){return globalThis.crypto.randomUUID().slice(0,8)}async function $(e,t){let n;try{n=await e.createSyncAccessHandle()}catch(r){const a=r==null?void 0:r.name;throw a==="NoModificationAllowedError"||a==="InvalidStateError"?new p.WopfsLockedError(t,r):r}if(typeof n.getSize()!="number")throw await n.close(),new p.WopfsUnsupportedError("this browser's FileSystemSyncAccessHandle methods are asynchronous; wopfs needs the synchronous ones");return rt(n)}async function ft(e,t,n){try{await e.move(t,n)}catch(r){if((r==null?void 0:r.name)!=="InvalidModificationError")throw r;await t.removeEntry(n),await e.move(t,n)}}async function lt(e,t,n,r,a){const f=await $(t,n);try{st(e,f,r),f.flush()}catch(l){throw f.close(),await a().catch(()=>{}),l}f.close()}async function ut(e){const t=e.outputDir;if(t!==void 0&&!at(t))throw new p.WopfsInputError("the opfs backend needs outputDir to be a FileSystemDirectoryHandle");if(t===void 0&&e.scratch>0)throw new p.WopfsInputError(`scratch (${e.scratch}) needs outputDir: without it the mount is input-only`);const n=[],r=`.wopfs-scratch-${R()}`;let a,f=0;const l=async()=>{for(const h of n)try{h.close()}catch{}a&&await t.removeEntry(r,{recursive:!0}).catch(()=>{})};try{const h=[],m=[];for(const[s,i]of e.inputs)if(_(i)){for(const[u,w]of m)if(await w.isSameEntry(i))throw new p.WopfsInputError(`inputs ${JSON.stringify(u)} and ${JSON.stringify(s)} are the same file`);m.push([s,i]);const c=await $(i,s);n.push(c),h.push({path:s,file:c})}else h.push({path:s,file:new M(await z(i,s,"opfs"))});if(t===void 0)return T("opfs",h,l);if(a=await t.getDirectoryHandle(r,{create:!0}),typeof(await a.getFileHandle("probe",{create:!0})).move!="function")throw new p.WopfsUnsupportedError("this browser's FileSystemFileHandle has no move(); wopfs needs it to commit outputs safely");const d=[];for(let s=0;s<e.scratch;s++){const i=`s${s}`,c=await a.getFileHandle(i,{create:!0}),u=await $(c,`${r}/${i}`);n.push(u),d.push({name:i,file:u,handle:c})}const o=new D({capacity:e.scratch,onExhausted:e.onExhausted,preopened:d,warn:e.warn});return{kind:"opfs",inputs:h,pool:o,async commitFile(s,i,c){const u=s.split("/"),w=u.pop();let y=t;for(const F of u)y=await y.getDirectoryHandle(F,{create:!0});const W=o.slotOf(i);let S;if(W)i.flush(),i.close(),S=W.handle;else{const F=`spill${f++}`;S=await a.getFileHandle(F,{create:!0}),await lt(i,S,`${r}/${F}`,c,()=>a.removeEntry(F)),i.close()}return await ft(S,y,w),{path:s,size:c,handle:S}},release:l}}catch(h){throw await l(),h}}async function A(e,t,n){const r=e.FS,a=[];for(const[d,o]of n.inputs)a.push([d,await z(o,d,"memfs")]);const f=P(r,t);let l;try{l=r.mount(r.filesystems.MEMFS,{},t)}catch(d){throw k(r,f),U(t,d)}const h=new Set;try{for(const[d,o]of a){const s=`${t}/${d}`;r.mkdirTree(s.slice(0,s.lastIndexOf("/"))),r.writeFile(s,o),r.chmod(s,292),h.add(r.lookupPath(s).node)}}catch(d){throw r.unmount(t),k(r,f),d}const m=(d,o,s)=>{for(const i of r.readdir(d)){if(i==="."||i==="..")continue;const c=`${d}/${i}`,u=o?`${o}/${i}`:i,w=r.lookupPath(c).node;if(r.isDir(w.mode))m(c,u,s);else if(r.isFile(w.mode)&&!h.has(w)){const y=r.readFile(c);s.push({path:u,size:y.length,bytes:y})}}};let E="mounted";return{backend:"memfs",mountpoint:t,async commit(){if(E!=="mounted")throw new p.WopfsStateError(`commit() on a mount that is ${E}`);I(r,l.mount);const d=[];return m(t,"",d),E="committed",d.sort((o,s)=>o.path<s.path?-1:o.path>s.path?1:0)},async release(){E!=="released"&&(E="releasing",v(r,t,l.mount,f),E="released")}}}function ht(e){const t=Object.entries(e.inputs??{});for(const[f]of t)q(f);const n=new Set(t.map(([f])=>f));for(const[f]of t){const l=f.split("/");for(let h=1;h<l.length;h++){const m=l.slice(0,h).join("/");if(n.has(m))throw new p.WopfsInputError(`input ${JSON.stringify(m)} is a file, but ${JSON.stringify(f)} needs it to be a directory`)}}const r=e.scratch??(e.outputDir===void 0?0:16);if(!Number.isInteger(r)||r<0)throw new p.WopfsInputError(`scratch must be a non-negative integer: ${r}`);const a=e.onExhausted??"spill";if(a!=="spill"&&a!=="strict")throw new p.WopfsInputError(`onExhausted must be "spill" or "strict": ${a}`);return{inputs:t,outputDir:e.outputDir,scratch:r,onExhausted:a,warn:e.onWarning??(f=>console.warn(f))}}async function C(e,t,n){try{return it(e,t,n)}catch(r){throw await n.release(),r}}async function pt(e,t,n={}){V(e),L(t);const r=ht(n),a=n.backend??"auto",f=a==="auto"?H():a;if(f==="memfs")return A(e,t,r);if(f==="node"){const{openNodeBackend:l}=await Promise.resolve().then(()=>require("./node-6KJNNt7l.cjs"));return C(e,t,await l(r))}if(f!=="opfs")throw new p.WopfsInputError(`unknown backend: ${String(f)}`);try{return await C(e,t,await ut(r))}catch(l){if(a==="auto"&&l instanceof p.WopfsUnsupportedError)return r.warn(`wopfs: ${l.message}; falling back to memfs`),A(e,t,r);throw l}}const dt=Object.freeze(Object.defineProperty({__proto__:null,WopfsCommitError:p.WopfsCommitError,WopfsError:p.WopfsError,WopfsInputError:p.WopfsInputError,WopfsLockedError:p.WopfsLockedError,WopfsRuntimeError:p.WopfsRuntimeError,WopfsStateError:p.WopfsStateError,WopfsUnsupportedError:p.WopfsUnsupportedError,detectBackend:H,mountFiles:pt},Symbol.toStringTag,{value:"Module"}));exports.MemoryFile=M;exports.ScratchPool=D;exports.bytesOf=z;exports.index=dt;exports.inputOnlyBackend=T;exports.randomId=R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("node:fs"),I=require("node:path"),d=require("./wexiftool-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("node:fs"),I=require("node:path"),d=require("./wexiftool-Dt9AnMsh.cjs"),f=require("./index-Czh_jOH1.cjs");function k(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const W=k(x),F=k(I),{closeSync:_,existsSync:q,fstatSync:E,ftruncateSync:N,mkdirSync:g,openSync:b,readSync:z,realpathSync:$,renameSync:O,rmSync:B,writeFileSync:M,writeSync:T}=W,{dirname:y,isAbsolute:A,join:p,relative:J,resolve:P,sep:C}=F;function v(e){let n=!1;return{read:(t,r)=>z(e,t,0,t.length,r),write:(t,r)=>{let o=0;for(;o<t.length;)o+=T(e,t,o,t.length-o,r+o);return o},truncate:t=>N(e,t),getSize:()=>E(e).size,flush:()=>{},close:()=>{n||(n=!0,_(e))}}}function D(e,n,t,r=!1){const o=J(P(e),n);if(!o&&!r||o===".."||o.startsWith(`..${C}`)||A(o))throw new d.WopfsError(`refusing to commit ${JSON.stringify(t)}: it resolves outside outputDir`)}async function G(e){const n=e.outputDir;if(n!==void 0&&typeof n!="string")throw new d.WopfsInputError("the node backend needs outputDir to be a host directory path");if(n===void 0&&e.scratch>0)throw new d.WopfsInputError(`scratch (${e.scratch}) needs outputDir: without it the mount is input-only`);const t=[],r=n===void 0?"":p(n,`.wopfs-scratch-${f.randomId()}`);let o=!1,j=0;const h=async()=>{for(const u of t)try{u.close()}catch{}o&&B(r,{recursive:!0,force:!0})};try{const u=[];for(const[s,c]of e.inputs)if(typeof c=="string"){let a;try{a=b(c,"r")}catch(l){throw new d.WopfsInputError(`input ${s}: cannot open ${c}: ${l.message}`,{cause:l})}const i=v(a);if(t.push(i),!E(a).isFile())throw new d.WopfsInputError(`input ${s}: ${c} is not a regular file`);u.push({path:s,file:i})}else u.push({path:s,file:new f.MemoryFile(await f.bytesOf(c,s,"node"))});if(n===void 0)return f.inputOnlyBackend("node",u,h);g(r,{recursive:!0}),o=!0;const w=new f.ScratchPool({capacity:e.scratch,onExhausted:e.onExhausted,warn:e.warn,open:s=>{const c=`s${s}`,a=v(b(p(r,c),"w+"));return t.push(a),{name:c,file:a}}});return{kind:"node",inputs:u,pool:w,async commitFile(s,c,a){const i=P(n,...s.split("/"));D(n,i,s);let l=y(i);for(;!q(l);)l=y(l);D($(n),$(l),s,!0),g(y(i),{recursive:!0});const S=w.slotOf(c);if(S)c.close(),O(p(r,S.name),i);else{const m=p(r,`spill${j++}`);M(m,c.bytes()),O(m,i)}return{path:s,size:a,hostPath:i}},release:h}}catch(u){throw await h(),u}}exports.openNodeBackend=G;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as E from "node:fs";
|
|
2
2
|
import * as O from "node:path";
|
|
3
|
-
import { a as f, g as I } from "./wexiftool-
|
|
4
|
-
import { r as P, M as W, b as z, i as B, S as M } from "./index-
|
|
3
|
+
import { a as f, g as I } from "./wexiftool-CUKoJisL.js";
|
|
4
|
+
import { r as P, M as W, b as z, i as B, S as M } from "./index-BUUKaFua.js";
|
|
5
5
|
const { closeSync: N, existsSync: j, fstatSync: k, ftruncateSync: A, mkdirSync: S, openSync: g, readSync: J, realpathSync: $, renameSync: b, rmSync: q, writeFileSync: C, writeSync: G } = E, { dirname: p, isAbsolute: H, join: h, relative: K, resolve: x, sep: L } = O;
|
|
6
6
|
function v(e) {
|
|
7
7
|
let t = !1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
var L = (n, t, e) => t in n ?
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var L = (n, t, e) => t in n ? _(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var A = (n, t, e) => L(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
class b extends Error {
|
|
5
5
|
constructor(t, e) {
|
|
@@ -28,11 +28,11 @@ class ut extends b {
|
|
|
28
28
|
this.committed = e;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
const g = "/wexiftool",
|
|
32
|
-
function
|
|
31
|
+
const g = "/wexiftool", B = "/opt/perlwasm/bin/exiftool";
|
|
32
|
+
function C(n) {
|
|
33
33
|
n.ENV && (n.ENV.LC_ALL = "C");
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class j {
|
|
36
36
|
constructor(t, e) {
|
|
37
37
|
this.wasmUrl = t, this.onWasmProgress = e, this.module = null, this.modulePromise = null, this.tail = Promise.resolve(), this.createModule = null, this.stdoutSink = null, this.stderrSink = null;
|
|
38
38
|
}
|
|
@@ -63,7 +63,7 @@ class C {
|
|
|
63
63
|
var s;
|
|
64
64
|
(s = this.stderrSink) == null || s.call(this, i);
|
|
65
65
|
},
|
|
66
|
-
preRun: [
|
|
66
|
+
preRun: [C]
|
|
67
67
|
}, e = this.wasmUrl ?? this.defaultWasmUrl(), r = await this.importModuleFactory(e);
|
|
68
68
|
this.createModule = r;
|
|
69
69
|
const o = e.substring(0, e.lastIndexOf("/") + 1);
|
|
@@ -119,7 +119,7 @@ return createPerlModule;`
|
|
|
119
119
|
)(void 0, void 0, void 0);
|
|
120
120
|
}
|
|
121
121
|
defaultWasmUrl() {
|
|
122
|
-
return
|
|
122
|
+
return new URL(
|
|
123
123
|
/* @vite-ignore */
|
|
124
124
|
"../wasm/perl.js",
|
|
125
125
|
import.meta.url
|
|
@@ -167,7 +167,7 @@ return createPerlModule;`
|
|
|
167
167
|
}
|
|
168
168
|
async runMounted(t, e, r) {
|
|
169
169
|
var a;
|
|
170
|
-
const { mountFiles: o } = await import("./index-
|
|
170
|
+
const { mountFiles: o } = await import("./index-BUUKaFua.js").then((l) => l.a), i = this.module, s = e.map((l, d) => `${g}/${d}/${v(l)}`), c = [];
|
|
171
171
|
try {
|
|
172
172
|
for (const [u, h] of e.entries()) {
|
|
173
173
|
const w = ((a = h.commitTo) == null ? void 0 : a.dir) ?? (r.readOnly ? void 0 : r.privateDir);
|
|
@@ -207,7 +207,7 @@ return createPerlModule;`
|
|
|
207
207
|
* already be in place.
|
|
208
208
|
*/
|
|
209
209
|
callExiftool(t, e, r) {
|
|
210
|
-
const o = this.module, i = new Map(e.map((u, h) => [u.name, r[h]])), s = [
|
|
210
|
+
const o = this.module, i = new Map(e.map((u, h) => [u.name, r[h]])), s = [B];
|
|
211
211
|
for (const u of t)
|
|
212
212
|
s.push(
|
|
213
213
|
u.toLowerCase() === "-overwrite_original_in_place" ? "-overwrite_original" : i.get(u) ?? u
|
|
@@ -455,7 +455,7 @@ async function Y(n) {
|
|
|
455
455
|
for (const r of t.slice(0, -1)) e = await e.getDirectoryHandle(r);
|
|
456
456
|
return e;
|
|
457
457
|
}
|
|
458
|
-
async function
|
|
458
|
+
async function D(n, t) {
|
|
459
459
|
const e = globalThis.crypto.randomUUID().slice(0, 8);
|
|
460
460
|
if (n.node) {
|
|
461
461
|
const { mkdtemp: s, rm: c } = await import(
|
|
@@ -500,14 +500,14 @@ const Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
500
500
|
planInput: P,
|
|
501
501
|
registerHint: J,
|
|
502
502
|
resolveOnCallerSide: K,
|
|
503
|
-
withPrivateDir:
|
|
503
|
+
withPrivateDir: D,
|
|
504
504
|
writeRef: W
|
|
505
505
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
506
506
|
function tt(n) {
|
|
507
507
|
const t = n, e = [];
|
|
508
508
|
return "input" in t && e.push(t.input), t.inputs && e.push(...t.inputs), t.files && e.push(...t.files.values()), t.options && "output" in t.options && e.push(t.options.output), e.filter(p);
|
|
509
509
|
}
|
|
510
|
-
class
|
|
510
|
+
class I {
|
|
511
511
|
constructor(t, e) {
|
|
512
512
|
this.port = t, this.onWasmProgress = e, this.nextId = 1, this.pending = /* @__PURE__ */ new Map(), this.destroyed = !1, t.addEventListener("message", (r) => this.receive(r.data)), t.addEventListener("error", (r) => this.failAll(rt(r, "Worker error"))), t.addEventListener(
|
|
513
513
|
"messageerror",
|
|
@@ -518,7 +518,7 @@ class D {
|
|
|
518
518
|
* Load the WASM module inside `worker` and resolve once it's ready.
|
|
519
519
|
*/
|
|
520
520
|
static async create(t, e) {
|
|
521
|
-
const r = new
|
|
521
|
+
const r = new I(t, e == null ? void 0 : e.onWasmProgress);
|
|
522
522
|
return await r.call({
|
|
523
523
|
op: "init",
|
|
524
524
|
options: { wasmUrl: e == null ? void 0 : e.wasmUrl, progress: !!(e != null && e.onWasmProgress) }
|
|
@@ -590,7 +590,7 @@ function rt(n, t) {
|
|
|
590
590
|
const e = n == null ? void 0 : n.message;
|
|
591
591
|
return typeof e == "string" && e ? `${t}: ${e}` : t;
|
|
592
592
|
}
|
|
593
|
-
class
|
|
593
|
+
class H {
|
|
594
594
|
constructor(t) {
|
|
595
595
|
this.glue = t;
|
|
596
596
|
}
|
|
@@ -599,8 +599,8 @@ class I {
|
|
|
599
599
|
* The WASM module is lazy-loaded on first use.
|
|
600
600
|
*/
|
|
601
601
|
static async create(t) {
|
|
602
|
-
const e = new
|
|
603
|
-
return await e.init(), new
|
|
602
|
+
const e = new j(t == null ? void 0 : t.wasmUrl, t == null ? void 0 : t.onWasmProgress);
|
|
603
|
+
return await e.init(), new H(e);
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* Read all metadata from a file.
|
|
@@ -709,7 +709,7 @@ class I {
|
|
|
709
709
|
d = await this.glue.exec(t, new Map(l.map((f) => [f.name, f.source])));
|
|
710
710
|
else {
|
|
711
711
|
const f = s.node ? "node" : "opfs";
|
|
712
|
-
d = !i && l.some((y) => !y.commitTo) ? await
|
|
712
|
+
d = !i && l.some((y) => !y.commitTo) ? await D(s, (y) => this.glue.run(t, l, { privateDir: y, backend: f, scratch: o })) : await this.glue.run(t, l, { backend: f, scratch: o, readOnly: i });
|
|
713
713
|
}
|
|
714
714
|
const u = [...((m = d.committed) == null ? void 0 : m.keys()) ?? []];
|
|
715
715
|
for (const { input: f, writeAfter: y } of c) {
|
|
@@ -746,7 +746,7 @@ async function ot(n, t) {
|
|
|
746
746
|
return !1;
|
|
747
747
|
}
|
|
748
748
|
export {
|
|
749
|
-
|
|
749
|
+
H as W,
|
|
750
750
|
it as a,
|
|
751
751
|
lt as b,
|
|
752
752
|
ct as c,
|
|
@@ -756,6 +756,6 @@ export {
|
|
|
756
756
|
b as g,
|
|
757
757
|
tt as h,
|
|
758
758
|
p as i,
|
|
759
|
-
|
|
759
|
+
I as j,
|
|
760
760
|
Z as m
|
|
761
761
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var N=Object.create;var P=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var J=(n,t,e)=>t in n?P(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var K=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of z(t))!V.call(n,o)&&o!==e&&P(n,o,{get:()=>t[o],enumerable:!(r=q(t,o))||r.enumerable});return n};var g=(n,t,e)=>(e=n!=null?N(G(n)):{},K(t||!n||!n.__esModule?P(e,"default",{value:n,enumerable:!0}):e,n));var A=(n,t,e)=>J(n,typeof t!="symbol"?t+"":t,e);var S=typeof document<"u"?document.currentScript:null;class b extends Error{constructor(t,e){super(t,e),this.name=new.target.name}}class X extends b{}class Q extends b{constructor(e,r){super(`${e} is locked by another sync access handle (another tab or worker may be using it)`,{cause:r});A(this,"path");this.path=e}}class
|
|
2
|
-
return createPerlModule;`)(void 0,void 0,void 0)}defaultWasmUrl(){return
|
|
1
|
+
"use strict";var N=Object.create;var P=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var J=(n,t,e)=>t in n?P(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var K=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of z(t))!V.call(n,o)&&o!==e&&P(n,o,{get:()=>t[o],enumerable:!(r=q(t,o))||r.enumerable});return n};var g=(n,t,e)=>(e=n!=null?N(G(n)):{},K(t||!n||!n.__esModule?P(e,"default",{value:n,enumerable:!0}):e,n));var A=(n,t,e)=>J(n,typeof t!="symbol"?t+"":t,e);var S=typeof document<"u"?document.currentScript:null;class b extends Error{constructor(t,e){super(t,e),this.name=new.target.name}}class X extends b{}class Q extends b{constructor(e,r){super(`${e} is locked by another sync access handle (another tab or worker may be using it)`,{cause:r});A(this,"path");this.path=e}}class _ extends b{}class Y extends b{}class Z extends b{}class tt extends b{constructor(e,r){super(`commit() failed after ${e.length} file(s): ${(r==null?void 0:r.message)??String(r)}`,{cause:r});A(this,"committed");this.committed=e}}const E="/wexiftool",et="/opt/perlwasm/bin/exiftool";function rt(n){n.ENV&&(n.ENV.LC_ALL="C")}class nt{constructor(t,e){this.wasmUrl=t,this.onWasmProgress=e,this.module=null,this.modulePromise=null,this.tail=Promise.resolve(),this.createModule=null,this.stdoutSink=null,this.stderrSink=null}async init(){if(!this.module){if(this.modulePromise){await this.modulePromise;return}this.modulePromise=this.loadModule(),this.module=await this.modulePromise;try{this.module.FS.mkdir(E)}catch{}}}async loadModule(){const t={noInitialRun:!0,print:i=>{var s;(s=this.stdoutSink)==null||s.call(this,i)},printErr:i=>{var s;(s=this.stderrSink)==null||s.call(this,i)},preRun:[rt]},e=this.wasmUrl??this.defaultWasmUrl(),r=await this.importModuleFactory(e);this.createModule=r;const o=e.substring(0,e.lastIndexOf("/")+1);if(this.onWasmProgress&&typeof fetch<"u"){const i=await this.fetchWithProgress(o+"perl.wasm");return await r({...t,locateFile:s=>o+s,wasmBinary:i})}return await r({...t,locateFile:i=>o+i})}async fetchWithProgress(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch ${t}: ${e.status} ${e.statusText}`);const r=e.headers.get("content-length"),o=r?parseInt(r,10):null,i=e.body.getReader(),s=[];let c=0;for(;;){const{done:d,value:u}=await i.read();if(d)break;s.push(u),c+=u.byteLength,this.onWasmProgress(c,o)}const a=new Uint8Array(c);let l=0;for(const d of s)a.set(d,l),l+=d.byteLength;return a}async importModuleFactory(t){var i;if(typeof process<"u"&&((i=process.versions)!=null&&i.node)){const s=await import(t);return s.default??s}const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch ${t}: ${e.status} ${e.statusText}`);const r=await e.text();return new Function("exports","module","define",`${r}
|
|
2
|
+
return createPerlModule;`)(void 0,void 0,void 0)}defaultWasmUrl(){return new URL("../wasm/perl.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:S&&S.tagName.toUpperCase()==="SCRIPT"&&S.src||new URL("wexiftool-Dt9AnMsh.cjs",document.baseURI).href).href}async exec(t,e){const r=[...e].map(([s,c])=>({name:s,source:c})),{committed:o,...i}=await this.run(t,r);return i}async run(t,e,r={}){return await this.init(),this.enqueue(()=>e.some(o=>!(o.source instanceof Uint8Array))?this.runMounted(t,e,r):this.runStaged(t,e))}runStaged(t,e){const r=this.module.FS,o=e.map((s,c)=>`${E}/${c}/${x(s)}`),i=new Map;try{e.forEach((c,a)=>{r.mkdir(`${E}/${a}`),r.writeFile(o[a],c.source),r.chmod(o[a],292),i.set(o[a],O(r,o[a]))});const s=this.callExiftool(t,e,o);return e.forEach((c,a)=>{if(O(r,o[a])!==i.get(o[a]))try{s.files.set(c.name,r.readFile(o[a]))}catch{}}),{...s,committed:new Map}}finally{e.forEach((s,c)=>D(r,`${E}/${c}`))}}async runMounted(t,e,r){var a;const{mountFiles:o}=await Promise.resolve().then(()=>require("./index-Czh_jOH1.cjs")).then(l=>l.index),i=this.module,s=e.map((l,d)=>`${E}/${d}/${x(l)}`),c=[];try{for(const[u,h]of e.entries()){const w=((a=h.commitTo)==null?void 0:a.dir)??(r.readOnly?void 0:r.privateDir);if(w===void 0&&!r.readOnly)throw new Error(`Input "${h.name}" is mounted, so the run needs a privateDir, a commitTo or readOnly`);c.push(await o(i,`${E}/${u}`,{inputs:{[x(h)]:h.source},outputDir:w,scratch:w===void 0?0:r.scratch??1,onExhausted:"spill",backend:r.backend}))}const l=this.callExiftool(t,e,s),d=new Map;for(const[u,h]of e.entries()){const w=await c[u].commit(),m=w.find(f=>f.path===x(h));if(h.commitTo)m&&d.set(h.name,m);else for(const f of w)f===m&&l.files.set(h.name,await ot(f)),await st(f,r.privateDir)}return{...l,committed:d}}finally{for(const l of c)await l.release()}}callExiftool(t,e,r){const o=this.module,i=new Map(e.map((u,h)=>[u.name,r[h]])),s=[et];for(const u of t)s.push(u.toLowerCase()==="-overwrite_original_in_place"?"-overwrite_original":i.get(u)??u);const c=new Set(t);for(const u of e)c.has(u.name)||s.push(i.get(u.name));let a="",l="";this.stdoutSink=u=>{a+=u+`
|
|
3
3
|
`},this.stderrSink=u=>{l+=u+`
|
|
4
|
-
`};let d;try{d=o.callMain(s)}catch(u){if(u.status!==void 0)d=u.status;else throw u}finally{this.stdoutSink=null,this.stderrSink=null}for(const[u,h]of i)a=a.replaceAll(h,u),l=l.replaceAll(h,u);return e.forEach((u,h)=>{const w=new RegExp(`${E}/${h}(?![0-9])`,"g"),m=u.name.lastIndexOf("/"),f=m>0?u.name.slice(0,m):m===0?"/":".";a=a.replace(w,()=>f),l=l.replace(w,()=>f)}),{stdout:a.trimEnd(),stderr:l.trimEnd(),exitCode:d,files:new Map}}enqueue(t){const e=this.tail.then(t,t);return this.tail=e.catch(()=>{}),e}destroy(){this.module=null,this.modulePromise=null,this.createModule=null,this.tail=Promise.resolve()}}function x(n){var e;const t=(((e=n.commitTo)==null?void 0:e.as)??n.name).split("/").pop();return t&&t!=="."&&t!==".."?t:"input.bin"}function I(n,t){try{const e=n.stat(t);return`${e.ino}:${e.size}:${+e.mtime}`}catch{return"missing"}}function D(n,t){let e;try{e=n.readdir(t)}catch{return}for(const r of e){if(r==="."||r==="..")continue;const o=`${t}/${r}`;try{n.unlink(o)}catch{D(n,o)}}try{n.rmdir(t)}catch{}}async function ot(n){if(n.handle)return new Uint8Array(await(await n.handle.getFile()).arrayBuffer());if(n.hostPath){const{readFile:t}=await import("node:fs/promises");return new Uint8Array(await t(n.hostPath))}return n.bytes??new Uint8Array}async function st(n,t){if(n.hostPath){const{rm:e}=await import("node:fs/promises");await e(n.hostPath,{force:!0});return}if(typeof t!="string"){const e=n.path.split("/"),r=e.pop();let o=t;for(const i of e)o=await o.getDirectoryHandle(i);await o.removeEntry(r).catch(()=>{})}}function p(n){return typeof n=="object"&&n!==null&&n.kind==="file"&&typeof n.getFile=="function"}async function W(n){if(n instanceof Uint8Array)return{name:"input.bin",data:n};if(n instanceof ArrayBuffer)return{name:"input.bin",data:new Uint8Array(n)};if(p(n)){const t=await n.getFile();return{name:n.name||"input.bin",data:new Uint8Array(await t.arrayBuffer())}}if(typeof File<"u"&&n instanceof File){const t=await n.arrayBuffer();return{name:n.name||"input.bin",data:new Uint8Array(t)}}if(typeof Blob<"u"&&n instanceof Blob){const t=await n.arrayBuffer();return{name:"input.bin",data:new Uint8Array(t)}}throw new Error("Unsupported input type")}async function it(n,t){const e=at(t);if(typeof n.createSyncAccessHandle=="function"){const r=await n.createSyncAccessHandle();try{r.truncate(0);let o=0;for(;o<e.byteLength;){const i=o===0?e:e.slice(o),s=r.write(i,{at:o});if(s<=0)throw new Error(`Short write to ${n.name} at byte ${o} of ${e.byteLength}`);o+=s}r.flush()}finally{r.close()}return}if(typeof n.createWritable=="function"){const r=await n.createWritable();try{await r.write(e),await r.close()}catch(o){throw await r.abort(o).catch(()=>{}),o}return}throw new Error(`Cannot write to file handle "${n.name}": it has neither createSyncAccessHandle() (dedicated workers only) nor createWritable().`)}function at(n){const{buffer:t,byteOffset:e,byteLength:r}=n;return t instanceof ArrayBuffer&&e===0&&r===t.byteLength?t:n.slice().buffer}const ct=Object.freeze(Object.defineProperty({__proto__:null,isFileHandle:p,resolveInput:W,writeToHandle:it},Symbol.toStringTag,{value:"Module"})),H=".wexiftool";function L(){var i,s;const n=globalThis,t=!!((s=(i=n.process)==null?void 0:i.versions)!=null&&s.node)&&typeof n.window>"u",e=n.DedicatedWorkerGlobalScope,r=n.FileSystemFileHandle,o=!t&&typeof e=="function"&&globalThis instanceof e&&!!(r&&"createSyncAccessHandle"in r.prototype);return{node:t,opfs:o}}async function F(n,t,e,r){if(typeof t=="string"){if(!e.node)throw new Error(`"${t}": file paths are only supported under Node`);const{resolve:i,dirname:s,basename:c}=await import("node:path"),a=i(t);if(r===void 0)return{input:{name:n,source:a}};if(typeof r!="string")return{input:{name:n,source:a},writeAfter:r};const l=i(r);return{input:{name:n,source:a,commitTo:{dir:s(l),as:c(l)}}}}if(p(t)&&e.opfs&&await R(t)){const i=t;if(r===void 0)return{input:{name:n,source:i}};const s=p(r)?await ht(r):null;return s?{input:{name:n,source:i,commitTo:{dir:s,as:r.name}}}:{input:{name:n,source:i},writeAfter:r}}const{data:o}=await W(t);return{input:{name:n,source:o},writeAfter:r}}const T=new WeakMap;async function lt(n,t){try{const e=await ft(t);e&&await e.isSameEntry(n)&&T.set(n,t)}catch{}}async function ut(n){return(await navigator.storage.getDirectory()).resolve(n)}async function ft(n){if(n.length===0)return null;let t=await navigator.storage.getDirectory();for(const e of n.slice(0,-1))t=await t.getDirectoryHandle(e);return t.getFileHandle(n[n.length-1])}const dt=5e3;async function R(n){const t=T.get(n);if(t)return t;const r=[[await navigator.storage.getDirectory(),[]]];let o=0;for(;r.length>0;){const[i,s]=r.shift();for await(const[c,a]of i.entries()){if(++o>dt)return null;if(a.kind==="file"){if(c===n.name&&await a.isSameEntry(n)){const l=[...s,c];return T.set(n,l),l}}else s.length===0&&c===H||r.push([a,[...s,c]])}}return null}async function ht(n){const t=await R(n);if(!t)return null;let e=await navigator.storage.getDirectory();for(const r of t.slice(0,-1))e=await e.getDirectoryHandle(r);return e}async function C(n,t){const e=globalThis.crypto.randomUUID().slice(0,8);if(n.node){const{mkdtemp:s,rm:c}=await import("node:fs/promises"),{tmpdir:a}=await import("node:os"),{join:l}=await import("node:path"),d=await s(l(a(),`wexiftool-${e}-`));try{return await t(d)}finally{await c(d,{recursive:!0,force:!0})}}const o=await(await navigator.storage.getDirectory()).getDirectoryHandle(H,{create:!0}),i=await o.getDirectoryHandle(e,{create:!0});try{return await t(i)}finally{await o.removeEntry(e,{recursive:!0}).catch(()=>{})}}async function M(n,t){if(typeof n=="string"){const{writeFile:r}=await import("node:fs/promises");await r(n,t);return}const{writeToHandle:e}=await Promise.resolve().then(()=>ct);await e(n,t)}const j=Object.freeze(Object.defineProperty({__proto__:null,detectEnvironment:L,planInput:F,registerHint:lt,resolveOnCallerSide:ut,withPrivateDir:C,writeRef:M},Symbol.toStringTag,{value:"Module"}));function B(n){const t=n,e=[];return"input"in t&&e.push(t.input),t.inputs&&e.push(...t.inputs),t.files&&e.push(...t.files.values()),t.options&&"output"in t.options&&e.push(t.options.output),e.filter(p)}class U{constructor(t,e){this.port=t,this.onWasmProgress=e,this.nextId=1,this.pending=new Map,this.destroyed=!1,t.addEventListener("message",r=>this.receive(r.data)),t.addEventListener("error",r=>this.failAll(mt(r,"Worker error"))),t.addEventListener("messageerror",()=>this.failAll("Worker sent a message that could not be deserialized"))}static async create(t,e){const r=new U(t,e==null?void 0:e.onWasmProgress);return await r.call({op:"init",options:{wasmUrl:e==null?void 0:e.wasmUrl,progress:!!(e!=null&&e.onWasmProgress)}}),r}read(t){return this.call({op:"read",input:t})}readMany(t){return this.call({op:"readMany",inputs:t})}readRaw(t,e){return this.call({op:"readRaw",input:t,args:e})}write(t,e,r){return this.call({op:"write",input:t,tags:e,options:r})}exec(t,e,r){return this.call({op:"exec",args:t,files:e,options:r})}async destroy(){if(this.destroyed=!0,typeof this.port.terminate=="function"){this.port.terminate(),this.failAll("WExifToolWorker was destroyed");return}await this.call({op:"destroy"})}async call(t){const e=this.nextId++,r=await wt(t);if(this.destroyed&&t.op!=="destroy")throw new Error("WExifToolWorker was destroyed");return new Promise((o,i)=>{this.pending.set(e,{resolve:o,reject:i});try{this.port.postMessage({...t,id:e,hints:r})}catch(s){this.pending.delete(e),i(s instanceof Error?s:new Error(String(s)))}})}receive(t){var r;if(t.kind==="progress"){(r=this.onWasmProgress)==null||r.call(this,t.loaded,t.total);return}const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),t.ok?e.resolve(t.value):e.reject(new Error(t.error)))}failAll(t){const e=new Error(t);for(const r of this.pending.values())r.reject(e);this.pending.clear()}}async function wt(n){var o,i;const t=globalThis;if(typeof t.window>"u"||typeof((i=(o=t.navigator)==null?void 0:o.storage)==null?void 0:i.getDirectory)!="function")return;const e=B(n);if(e.length===0)return;const{resolveOnCallerSide:r}=await Promise.resolve().then(()=>j);return Promise.all(e.map(s=>r(s).catch(()=>null)))}function mt(n,t){const e=n==null?void 0:n.message;return typeof e=="string"&&e?`${t}: ${e}`:t}class _{constructor(t){this.glue=t}static async create(t){const e=new nt(t==null?void 0:t.wasmUrl,t==null?void 0:t.onWasmProgress);return await e.init(),new _(e)}async read(t){const e=k(t),r=await this.runFiles(["-json","-G",e],[[e,t]],{readOnly:!0});if(r.exitCode!==0&&r.stderr)throw new Error(`ExifTool error: ${r.stderr}`);try{const o=JSON.parse(r.stdout);return Array.isArray(o)?o[0]:o}catch{throw new Error(`Failed to parse ExifTool output: ${r.stdout}`)}}async readMany(t){if(t.length===0)return[];const e=yt(t.map(k)),r=await this.runFiles(["-json","-G",...e],t.map((i,s)=>[e[s],i]),{readOnly:!0});let o;try{o=JSON.parse(r.stdout)}catch{throw new Error(`ExifTool error: ${r.stderr||`unparseable output: ${r.stdout}`}`)}if(!Array.isArray(o)||o.length!==t.length)throw new Error(`ExifTool error: ${r.stderr||`expected ${t.length} results`}`);return o}async write(t,e,r){const o=k(t),i=Object.entries(e).map(([l,d])=>`-${l}=${d}`),s=typeof t=="string"||p(t),c=s?(r==null?void 0:r.output)??t:void 0,a=await this.runFiles(["-overwrite_original",...i,o],[[o,t]],{targets:c===void 0?void 0:new Map([[o,c]])});if(a.exitCode!==0&&a.stderr)throw new Error(`ExifTool error: ${a.stderr}`);return s?(!a.written.includes(o)&&c!==t&&await M(c,(await W(t)).data),c):a.files.get(o)??(await W(t)).data}async readRaw(t,e){const r=k(t),o=await this.runFiles([...e,r],[[r,t]],{scratch:0});if(o.exitCode!==0&&o.stderr)throw new Error(`ExifTool error: ${o.stderr}`);return o.stdout}async exec(t,e,r){const o=[...e??[]],i=r!=null&&r.writeBack?new Map(o.filter(([,s])=>typeof s=="string"||p(s))):void 0;return this.runFiles(t,o,{targets:i})}async runFiles(t,e,r){const o=L();try{return await this.runPlanned(t,e,r,o)}catch(i){if(o.opfs&&i instanceof O)return this.runPlanned(t,e,r,{...o,opfs:!1});throw i}}async runPlanned(t,e,{targets:r,scratch:o,readOnly:i},s){var m;const c=[],a=[];for(const[f,y]of e){let $=await F(f,y,s,r==null?void 0:r.get(f));const v=$.input.source;typeof v=="object"&&!(v instanceof Uint8Array)&&(await pt(v,a)?$=await F(f,y,{...s,opfs:!1},r==null?void 0:r.get(f)):a.push(v)),c.push($)}const l=c.map(f=>f.input);let d;if(l.every(f=>f.source instanceof Uint8Array))d=await this.glue.exec(t,new Map(l.map(f=>[f.name,f.source])));else{const f=s.node?"node":"opfs";d=!i&&l.some(y=>!y.commitTo)?await C(s,y=>this.glue.run(t,l,{privateDir:y,backend:f,scratch:o})):await this.glue.run(t,l,{backend:f,scratch:o,readOnly:i})}const u=[...((m=d.committed)==null?void 0:m.keys())??[]];for(const{input:f,writeAfter:y}of c){const $=d.files.get(f.name);y&&$&&(await M(y,$),d.files.delete(f.name),u.push(f.name))}const{committed:h,...w}=d;return{...w,written:u}}destroy(){this.glue.destroy()}}function k(n){return typeof n=="string"?n:(p(n)||typeof File<"u"&&n instanceof File)&&n.name||"input.bin"}function yt(n){const t=new Set(n),e=new Map;return n.map(r=>{const o=(e.get(r)??0)+1;if(e.set(r,o),o===1)return r;const i=r.lastIndexOf("/"),s=r.lastIndexOf("."),c=s>i+1?s:r.length;let a=o,l=`${r.slice(0,c)} (${a})${r.slice(c)}`;for(;t.has(l);)l=`${r.slice(0,c)} (${++a})${r.slice(c)}`;return t.add(l),l})}async function pt(n,t){for(const e of t)if(e===n||await e.isSameEntry(n))return!0;return!1}exports.WExifTool=_;exports.WExifToolWorker=U;exports.WopfsCommitError=tt;exports.WopfsError=b;exports.WopfsInputError=X;exports.WopfsLockedError=Q;exports.WopfsRuntimeError=Y;exports.WopfsStateError=Z;exports.WopfsUnsupportedError=O;exports.handlesIn=B;exports.isFileHandle=p;exports.mounts=j;
|
|
4
|
+
`};let d;try{d=o.callMain(s)}catch(u){if(u.status!==void 0)d=u.status;else throw u}finally{this.stdoutSink=null,this.stderrSink=null}for(const[u,h]of i)a=a.replaceAll(h,u),l=l.replaceAll(h,u);return e.forEach((u,h)=>{const w=new RegExp(`${E}/${h}(?![0-9])`,"g"),m=u.name.lastIndexOf("/"),f=m>0?u.name.slice(0,m):m===0?"/":".";a=a.replace(w,()=>f),l=l.replace(w,()=>f)}),{stdout:a.trimEnd(),stderr:l.trimEnd(),exitCode:d,files:new Map}}enqueue(t){const e=this.tail.then(t,t);return this.tail=e.catch(()=>{}),e}destroy(){this.module=null,this.modulePromise=null,this.createModule=null,this.tail=Promise.resolve()}}function x(n){var e;const t=(((e=n.commitTo)==null?void 0:e.as)??n.name).split("/").pop();return t&&t!=="."&&t!==".."?t:"input.bin"}function O(n,t){try{const e=n.stat(t);return`${e.ino}:${e.size}:${+e.mtime}`}catch{return"missing"}}function D(n,t){let e;try{e=n.readdir(t)}catch{return}for(const r of e){if(r==="."||r==="..")continue;const o=`${t}/${r}`;try{n.unlink(o)}catch{D(n,o)}}try{n.rmdir(t)}catch{}}async function ot(n){if(n.handle)return new Uint8Array(await(await n.handle.getFile()).arrayBuffer());if(n.hostPath){const{readFile:t}=await import("node:fs/promises");return new Uint8Array(await t(n.hostPath))}return n.bytes??new Uint8Array}async function st(n,t){if(n.hostPath){const{rm:e}=await import("node:fs/promises");await e(n.hostPath,{force:!0});return}if(typeof t!="string"){const e=n.path.split("/"),r=e.pop();let o=t;for(const i of e)o=await o.getDirectoryHandle(i);await o.removeEntry(r).catch(()=>{})}}function p(n){return typeof n=="object"&&n!==null&&n.kind==="file"&&typeof n.getFile=="function"}async function W(n){if(n instanceof Uint8Array)return{name:"input.bin",data:n};if(n instanceof ArrayBuffer)return{name:"input.bin",data:new Uint8Array(n)};if(p(n)){const t=await n.getFile();return{name:n.name||"input.bin",data:new Uint8Array(await t.arrayBuffer())}}if(typeof File<"u"&&n instanceof File){const t=await n.arrayBuffer();return{name:n.name||"input.bin",data:new Uint8Array(t)}}if(typeof Blob<"u"&&n instanceof Blob){const t=await n.arrayBuffer();return{name:"input.bin",data:new Uint8Array(t)}}throw new Error("Unsupported input type")}async function it(n,t){const e=at(t);if(typeof n.createSyncAccessHandle=="function"){const r=await n.createSyncAccessHandle();try{r.truncate(0);let o=0;for(;o<e.byteLength;){const i=o===0?e:e.slice(o),s=r.write(i,{at:o});if(s<=0)throw new Error(`Short write to ${n.name} at byte ${o} of ${e.byteLength}`);o+=s}r.flush()}finally{r.close()}return}if(typeof n.createWritable=="function"){const r=await n.createWritable();try{await r.write(e),await r.close()}catch(o){throw await r.abort(o).catch(()=>{}),o}return}throw new Error(`Cannot write to file handle "${n.name}": it has neither createSyncAccessHandle() (dedicated workers only) nor createWritable().`)}function at(n){const{buffer:t,byteOffset:e,byteLength:r}=n;return t instanceof ArrayBuffer&&e===0&&r===t.byteLength?t:n.slice().buffer}const ct=Object.freeze(Object.defineProperty({__proto__:null,isFileHandle:p,resolveInput:W,writeToHandle:it},Symbol.toStringTag,{value:"Module"})),H=".wexiftool";function L(){var i,s;const n=globalThis,t=!!((s=(i=n.process)==null?void 0:i.versions)!=null&&s.node)&&typeof n.window>"u",e=n.DedicatedWorkerGlobalScope,r=n.FileSystemFileHandle,o=!t&&typeof e=="function"&&globalThis instanceof e&&!!(r&&"createSyncAccessHandle"in r.prototype);return{node:t,opfs:o}}async function F(n,t,e,r){if(typeof t=="string"){if(!e.node)throw new Error(`"${t}": file paths are only supported under Node`);const{resolve:i,dirname:s,basename:c}=await import("node:path"),a=i(t);if(r===void 0)return{input:{name:n,source:a}};if(typeof r!="string")return{input:{name:n,source:a},writeAfter:r};const l=i(r);return{input:{name:n,source:a,commitTo:{dir:s(l),as:c(l)}}}}if(p(t)&&e.opfs&&await R(t)){const i=t;if(r===void 0)return{input:{name:n,source:i}};const s=p(r)?await ht(r):null;return s?{input:{name:n,source:i,commitTo:{dir:s,as:r.name}}}:{input:{name:n,source:i},writeAfter:r}}const{data:o}=await W(t);return{input:{name:n,source:o},writeAfter:r}}const T=new WeakMap;async function lt(n,t){try{const e=await ft(t);e&&await e.isSameEntry(n)&&T.set(n,t)}catch{}}async function ut(n){return(await navigator.storage.getDirectory()).resolve(n)}async function ft(n){if(n.length===0)return null;let t=await navigator.storage.getDirectory();for(const e of n.slice(0,-1))t=await t.getDirectoryHandle(e);return t.getFileHandle(n[n.length-1])}const dt=5e3;async function R(n){const t=T.get(n);if(t)return t;const r=[[await navigator.storage.getDirectory(),[]]];let o=0;for(;r.length>0;){const[i,s]=r.shift();for await(const[c,a]of i.entries()){if(++o>dt)return null;if(a.kind==="file"){if(c===n.name&&await a.isSameEntry(n)){const l=[...s,c];return T.set(n,l),l}}else s.length===0&&c===H||r.push([a,[...s,c]])}}return null}async function ht(n){const t=await R(n);if(!t)return null;let e=await navigator.storage.getDirectory();for(const r of t.slice(0,-1))e=await e.getDirectoryHandle(r);return e}async function C(n,t){const e=globalThis.crypto.randomUUID().slice(0,8);if(n.node){const{mkdtemp:s,rm:c}=await import("node:fs/promises"),{tmpdir:a}=await import("node:os"),{join:l}=await import("node:path"),d=await s(l(a(),`wexiftool-${e}-`));try{return await t(d)}finally{await c(d,{recursive:!0,force:!0})}}const o=await(await navigator.storage.getDirectory()).getDirectoryHandle(H,{create:!0}),i=await o.getDirectoryHandle(e,{create:!0});try{return await t(i)}finally{await o.removeEntry(e,{recursive:!0}).catch(()=>{})}}async function M(n,t){if(typeof n=="string"){const{writeFile:r}=await import("node:fs/promises");await r(n,t);return}const{writeToHandle:e}=await Promise.resolve().then(()=>ct);await e(n,t)}const B=Object.freeze(Object.defineProperty({__proto__:null,detectEnvironment:L,planInput:F,registerHint:lt,resolveOnCallerSide:ut,withPrivateDir:C,writeRef:M},Symbol.toStringTag,{value:"Module"}));function j(n){const t=n,e=[];return"input"in t&&e.push(t.input),t.inputs&&e.push(...t.inputs),t.files&&e.push(...t.files.values()),t.options&&"output"in t.options&&e.push(t.options.output),e.filter(p)}class U{constructor(t,e){this.port=t,this.onWasmProgress=e,this.nextId=1,this.pending=new Map,this.destroyed=!1,t.addEventListener("message",r=>this.receive(r.data)),t.addEventListener("error",r=>this.failAll(mt(r,"Worker error"))),t.addEventListener("messageerror",()=>this.failAll("Worker sent a message that could not be deserialized"))}static async create(t,e){const r=new U(t,e==null?void 0:e.onWasmProgress);return await r.call({op:"init",options:{wasmUrl:e==null?void 0:e.wasmUrl,progress:!!(e!=null&&e.onWasmProgress)}}),r}read(t){return this.call({op:"read",input:t})}readMany(t){return this.call({op:"readMany",inputs:t})}readRaw(t,e){return this.call({op:"readRaw",input:t,args:e})}write(t,e,r){return this.call({op:"write",input:t,tags:e,options:r})}exec(t,e,r){return this.call({op:"exec",args:t,files:e,options:r})}async destroy(){if(this.destroyed=!0,typeof this.port.terminate=="function"){this.port.terminate(),this.failAll("WExifToolWorker was destroyed");return}await this.call({op:"destroy"})}async call(t){const e=this.nextId++,r=await wt(t);if(this.destroyed&&t.op!=="destroy")throw new Error("WExifToolWorker was destroyed");return new Promise((o,i)=>{this.pending.set(e,{resolve:o,reject:i});try{this.port.postMessage({...t,id:e,hints:r})}catch(s){this.pending.delete(e),i(s instanceof Error?s:new Error(String(s)))}})}receive(t){var r;if(t.kind==="progress"){(r=this.onWasmProgress)==null||r.call(this,t.loaded,t.total);return}const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),t.ok?e.resolve(t.value):e.reject(new Error(t.error)))}failAll(t){const e=new Error(t);for(const r of this.pending.values())r.reject(e);this.pending.clear()}}async function wt(n){var o,i;const t=globalThis;if(typeof t.window>"u"||typeof((i=(o=t.navigator)==null?void 0:o.storage)==null?void 0:i.getDirectory)!="function")return;const e=j(n);if(e.length===0)return;const{resolveOnCallerSide:r}=await Promise.resolve().then(()=>B);return Promise.all(e.map(s=>r(s).catch(()=>null)))}function mt(n,t){const e=n==null?void 0:n.message;return typeof e=="string"&&e?`${t}: ${e}`:t}class I{constructor(t){this.glue=t}static async create(t){const e=new nt(t==null?void 0:t.wasmUrl,t==null?void 0:t.onWasmProgress);return await e.init(),new I(e)}async read(t){const e=k(t),r=await this.runFiles(["-json","-G",e],[[e,t]],{readOnly:!0});if(r.exitCode!==0&&r.stderr)throw new Error(`ExifTool error: ${r.stderr}`);try{const o=JSON.parse(r.stdout);return Array.isArray(o)?o[0]:o}catch{throw new Error(`Failed to parse ExifTool output: ${r.stdout}`)}}async readMany(t){if(t.length===0)return[];const e=yt(t.map(k)),r=await this.runFiles(["-json","-G",...e],t.map((i,s)=>[e[s],i]),{readOnly:!0});let o;try{o=JSON.parse(r.stdout)}catch{throw new Error(`ExifTool error: ${r.stderr||`unparseable output: ${r.stdout}`}`)}if(!Array.isArray(o)||o.length!==t.length)throw new Error(`ExifTool error: ${r.stderr||`expected ${t.length} results`}`);return o}async write(t,e,r){const o=k(t),i=Object.entries(e).map(([l,d])=>`-${l}=${d}`),s=typeof t=="string"||p(t),c=s?(r==null?void 0:r.output)??t:void 0,a=await this.runFiles(["-overwrite_original",...i,o],[[o,t]],{targets:c===void 0?void 0:new Map([[o,c]])});if(a.exitCode!==0&&a.stderr)throw new Error(`ExifTool error: ${a.stderr}`);return s?(!a.written.includes(o)&&c!==t&&await M(c,(await W(t)).data),c):a.files.get(o)??(await W(t)).data}async readRaw(t,e){const r=k(t),o=await this.runFiles([...e,r],[[r,t]],{scratch:0});if(o.exitCode!==0&&o.stderr)throw new Error(`ExifTool error: ${o.stderr}`);return o.stdout}async exec(t,e,r){const o=[...e??[]],i=r!=null&&r.writeBack?new Map(o.filter(([,s])=>typeof s=="string"||p(s))):void 0;return this.runFiles(t,o,{targets:i})}async runFiles(t,e,r){const o=L();try{return await this.runPlanned(t,e,r,o)}catch(i){if(o.opfs&&i instanceof _)return this.runPlanned(t,e,r,{...o,opfs:!1});throw i}}async runPlanned(t,e,{targets:r,scratch:o,readOnly:i},s){var m;const c=[],a=[];for(const[f,y]of e){let $=await F(f,y,s,r==null?void 0:r.get(f));const v=$.input.source;typeof v=="object"&&!(v instanceof Uint8Array)&&(await pt(v,a)?$=await F(f,y,{...s,opfs:!1},r==null?void 0:r.get(f)):a.push(v)),c.push($)}const l=c.map(f=>f.input);let d;if(l.every(f=>f.source instanceof Uint8Array))d=await this.glue.exec(t,new Map(l.map(f=>[f.name,f.source])));else{const f=s.node?"node":"opfs";d=!i&&l.some(y=>!y.commitTo)?await C(s,y=>this.glue.run(t,l,{privateDir:y,backend:f,scratch:o})):await this.glue.run(t,l,{backend:f,scratch:o,readOnly:i})}const u=[...((m=d.committed)==null?void 0:m.keys())??[]];for(const{input:f,writeAfter:y}of c){const $=d.files.get(f.name);y&&$&&(await M(y,$),d.files.delete(f.name),u.push(f.name))}const{committed:h,...w}=d;return{...w,written:u}}destroy(){this.glue.destroy()}}function k(n){return typeof n=="string"?n:(p(n)||typeof File<"u"&&n instanceof File)&&n.name||"input.bin"}function yt(n){const t=new Set(n),e=new Map;return n.map(r=>{const o=(e.get(r)??0)+1;if(e.set(r,o),o===1)return r;const i=r.lastIndexOf("/"),s=r.lastIndexOf("."),c=s>i+1?s:r.length;let a=o,l=`${r.slice(0,c)} (${a})${r.slice(c)}`;for(;t.has(l);)l=`${r.slice(0,c)} (${++a})${r.slice(c)}`;return t.add(l),l})}async function pt(n,t){for(const e of t)if(e===n||await e.isSameEntry(n))return!0;return!1}exports.WExifTool=I;exports.WExifToolWorker=U;exports.WopfsCommitError=tt;exports.WopfsError=b;exports.WopfsInputError=X;exports.WopfsLockedError=Q;exports.WopfsRuntimeError=Y;exports.WopfsStateError=Z;exports.WopfsUnsupportedError=_;exports.handlesIn=j;exports.isFileHandle=p;exports.mounts=B;
|
package/dist/wexiftool.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./wexiftool-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./wexiftool-Dt9AnMsh.cjs");exports.WExifTool=o.WExifTool;exports.WExifToolWorker=o.WExifToolWorker;
|
package/dist/wexiftool.es.js
CHANGED
package/dist/worker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const c=require("./wexiftool-
|
|
1
|
+
"use strict";const c=require("./wexiftool-Dt9AnMsh.cjs");function p(l,r=c.WExifTool.create){let i=null;const f=(a,n=[])=>l.postMessage(a,n),o=()=>(i||(i=r()),i);l.addEventListener("message",a=>{const n=a.data,e=t=>f({kind:"result",id:n.id,ok:!1,error:t instanceof Error?t.message:String(t)});d(n).then(({value:t,transfer:s})=>{try{f({kind:"result",id:n.id,ok:!0,value:t},s)}catch(w){e(w)}},e)});async function d(a){if(a.hints){const{registerHint:n}=await Promise.resolve().then(()=>require("./wexiftool-Dt9AnMsh.cjs")).then(t=>t.mounts),e=c.handlesIn(a);for(const[t,s]of a.hints.entries())s&&e[t]&&await n(e[t],s)}switch(a.op){case"init":{const{wasmUrl:n,progress:e}=a.options;return i=r({wasmUrl:n,onWasmProgress:e?(t,s)=>f({kind:"progress",loaded:t,total:s}):void 0}),await i,{value:null}}case"read":return{value:await(await o()).read(a.input)};case"readMany":return{value:await(await o()).readMany(a.inputs)};case"readRaw":return{value:await(await o()).readRaw(a.input,a.args)};case"write":{const n=await o();if(c.isFileHandle(a.input))return{value:await n.write(a.input,a.tags,a.options)};if(typeof a.input=="string")return{value:await n.write(a.input,a.tags)};const e=await n.write(a.input,a.tags);return{value:e,transfer:u([e])}}case"exec":{const n=await(await o()).exec(a.args,a.files,a.options);return{value:n,transfer:u(n.files.values())}}case"destroy":return i&&(await i).destroy(),i=null,{value:null}}}}function u(l){const r=new Set;for(const i of l)i.buffer instanceof ArrayBuffer&&r.add(i.buffer);return[...r]}p(self);
|
package/dist/worker.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as u, h as p, i as v } from "./wexiftool-
|
|
1
|
+
import { W as u, h as p, i as v } from "./wexiftool-CUKoJisL.js";
|
|
2
2
|
function g(l, r = u.create) {
|
|
3
3
|
let i = null;
|
|
4
4
|
const f = (a, n = []) => l.postMessage(a, n), o = () => (i || (i = r()), i);
|
|
@@ -19,7 +19,7 @@ function g(l, r = u.create) {
|
|
|
19
19
|
});
|
|
20
20
|
async function d(a) {
|
|
21
21
|
if (a.hints) {
|
|
22
|
-
const { registerHint: n } = await import("./wexiftool-
|
|
22
|
+
const { registerHint: n } = await import("./wexiftool-CUKoJisL.js").then((t) => t.m), s = p(a);
|
|
23
23
|
for (const [t, e] of a.hints.entries())
|
|
24
24
|
e && s[t] && await n(s[t], e);
|
|
25
25
|
}
|