@wasmedia/wimagemagick 0.2.0 → 0.3.0
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/CHANGELOG.md +24 -1
- package/README.md +16 -1
- package/dist/cli.d.ts +16 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/files.d.ts +80 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +142 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/licenses/README.txt +2 -2
- package/dist/licenses/aom-LICENSE.txt +1 -1
- package/dist/licenses/de265-LICENSE.txt +1 -1
- package/dist/licenses/ffi-LICENSE.txt +2 -2
- package/dist/licenses/heif-LICENSE.txt +1 -1
- package/dist/licenses/highway-LICENSE.txt +172 -2
- package/dist/licenses/jpeg-turbo-LICENSE.txt +46 -34
- package/dist/licenses/jpeg-xl-LICENSE.txt +1 -1
- package/dist/licenses/lcms-LICENSE.txt +1 -1
- package/dist/licenses/png-LICENSE.txt +1 -1
- package/dist/licenses/tiff-LICENSE.txt +1 -1
- package/dist/licenses/xml-LICENSE.txt +1 -1
- package/dist/licenses/zstd-LICENSE.txt +32 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +2 -0
- package/dist/loader.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wimagemagick.js +2 -15
- package/dist/wimagemagick.wasm +0 -0
- package/dist/wopfs.d.ts +43 -0
- package/dist/wopfs.d.ts.map +1 -0
- package/dist/wopfs.js +40 -0
- package/dist/wopfs.js.map +1 -0
- package/dist/worker-handler.d.ts +1 -1
- package/dist/worker-handler.d.ts.map +1 -1
- package/dist/worker-handler.js +26 -0
- package/dist/worker-handler.js.map +1 -1
- package/package.json +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-10-03
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- File mode: `executeFiles()` (also `wim.executeFiles()` and an
|
|
14
|
+
`executeFiles` worker message) runs a command over files instead of
|
|
15
|
+
buffers, mounting them through `@wasmedia/wopfs` 0.2.0: OPFS file handles
|
|
16
|
+
in a dedicated worker, host paths under Node. Inputs are read in place and
|
|
17
|
+
outputs written straight into `outputDir`, only when the command succeeds.
|
|
18
|
+
On a 24-megapixel TIFF it cuts peak memory from 640 to 315 MiB; the wasm
|
|
19
|
+
heap, and its 4 GiB ceiling, are unchanged. `execute()` and the buffer APIs
|
|
20
|
+
are untouched, and wopfs is loaded only on the first file-mode call.
|
|
21
|
+
- Browser tests (Playwright, Chromium, Firefox and WebKit) for file mode,
|
|
22
|
+
run in CI as `test-browser`; releases wait for them.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- Built with emsdk 6.0.6 (was 4.0.7) against ImageMagick's newest dependency
|
|
26
|
+
bundle (2026.09.26, was 2026.04.04), which is built with 6.0.6 and does not
|
|
27
|
+
link on any other major version. Delegate libraries move up with it, LibRaw
|
|
28
|
+
goes from 0.22.0 to 0.22.2, and `zstd` is now a delegate (the bundle's
|
|
29
|
+
libtiff needs it, so ZSTD-compressed TIFFs read and write). The `.wasm` grows
|
|
30
|
+
from 13.8 MB to 14.7 MB (5.1 MB gzipped).
|
|
31
|
+
|
|
10
32
|
## [0.2.0] - 2026-10-03
|
|
11
33
|
|
|
12
34
|
First release published to npm, as `@wasmedia/wimagemagick`.
|
|
@@ -226,5 +248,6 @@ First release published to npm, as `@wasmedia/wimagemagick`.
|
|
|
226
248
|
- Convenience C wrappers exported from the WASM module:
|
|
227
249
|
`wimagemagick_identify`, `wimagemagick_convert`, `wimagemagick_resize`.
|
|
228
250
|
|
|
229
|
-
[Unreleased]: https://gitlab.com/wasmedia/wimagemagick/-/compare/v0.
|
|
251
|
+
[Unreleased]: https://gitlab.com/wasmedia/wimagemagick/-/compare/v0.3.0...HEAD
|
|
252
|
+
[0.3.0]: https://gitlab.com/wasmedia/wimagemagick/-/compare/v0.2.0...v0.3.0
|
|
230
253
|
[0.2.0]: https://gitlab.com/wasmedia/wimagemagick/-/tags/v0.2.0
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ const jpeg = img.fit(1600, 1600).quality(85).toBuffer('JPEG');
|
|
|
23
23
|
img.dispose();
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
The package ships the `.wasm` (about
|
|
26
|
+
The package ships the `.wasm` (about 15 MB, 5 MB gzipped) next to its JS, and
|
|
27
27
|
loads it relative to the module, so a bundler that copies assets referenced by
|
|
28
28
|
`new URL(..., import.meta.url)` needs no configuration. [docs/api.md](docs/api.md)
|
|
29
29
|
has the full API, including the Web Worker entry
|
|
@@ -32,6 +32,21 @@ several LGPL libraries; their licences are in `dist/licenses/`.
|
|
|
32
32
|
|
|
33
33
|
Try it without installing at [magick.wasmedia.org](https://magick.wasmedia.org/).
|
|
34
34
|
|
|
35
|
+
### File mode
|
|
36
|
+
|
|
37
|
+
`executeFiles()` runs a command over files instead of buffers: OPFS file
|
|
38
|
+
handles in a Web Worker, host paths under Node. The files are mounted through
|
|
39
|
+
[wopfs](https://gitlab.com/wasmedia/wopfs) rather than copied into memory, which
|
|
40
|
+
halves peak memory on a large image (640 → 315 MiB on a 24-megapixel TIFF):
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
const r = await wim.executeFiles('shot.cr2 -resize 50% shot.jpg',
|
|
44
|
+
[{ name: 'shot.cr2', file: fileHandle }], { outputDir: dirHandle });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
See [File mode](docs/api.md#file-mode-inputs-and-outputs-that-stay-in-files).
|
|
48
|
+
wopfs (MIT) is loaded only when file mode is first used.
|
|
49
|
+
|
|
35
50
|
## Format & Feature Scope
|
|
36
51
|
|
|
37
52
|
- **Excluded:** Ghostscript-based features (PDF rendering), FFmpeg-based features (video)
|
package/dist/cli.d.ts
CHANGED
|
@@ -7,6 +7,22 @@
|
|
|
7
7
|
import type { WasmModule, CLIResult } from "./types.js";
|
|
8
8
|
/** Build the `print`/`printErr` pair the loader passes to the WASM factory. */
|
|
9
9
|
export declare function createOutputHooks(): Pick<WasmModule, "print" | "printErr">;
|
|
10
|
+
/** Run `fn` with module output redirected into strings. */
|
|
11
|
+
export declare function captureOutput<T>(fn: () => T): {
|
|
12
|
+
value: T;
|
|
13
|
+
stdout: string;
|
|
14
|
+
stderr: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Resolve one argument against the working directory, keeping any explicit
|
|
18
|
+
* `FORMAT:` prefix in place.
|
|
19
|
+
*
|
|
20
|
+
* The prefix matters for more than tidiness: the raw formats are registered
|
|
21
|
+
* with `ExplicitFormatType`, so ImageMagick will not pick LibRaw from a file's
|
|
22
|
+
* magic bytes — a DNG or CR2 is a TIFF at that level and the TIFF coder claims
|
|
23
|
+
* it. `dng:capture` is how the caller says otherwise.
|
|
24
|
+
*/
|
|
25
|
+
export declare function rewriteArg(arg: string, inputNames: Set<string>, workDir: string): string;
|
|
10
26
|
/**
|
|
11
27
|
* Parse a command string into an argv array, respecting quoted strings.
|
|
12
28
|
*
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA4BxD,+EAA+E;AAC/E,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,CAW1E;
|
|
1
|
+
{"version":3,"file":"cli.d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ks() {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
/** Run `fn` with module output redirected into strings. */
|
|
28
|
-
function captureOutput(fn) {
|
|
28
|
+
export function captureOutput(fn) {
|
|
29
29
|
const previous = activeSink;
|
|
30
30
|
const sink = { stdout: [], stderr: [] };
|
|
31
31
|
activeSink = sink;
|
|
@@ -118,7 +118,7 @@ function isWorkDirFile(arg, inputNames) {
|
|
|
118
118
|
* magic bytes — a DNG or CR2 is a TIFF at that level and the TIFF coder claims
|
|
119
119
|
* it. `dng:capture` is how the caller says otherwise.
|
|
120
120
|
*/
|
|
121
|
-
function rewriteArg(arg, inputNames, workDir) {
|
|
121
|
+
export function rewriteArg(arg, inputNames, workDir) {
|
|
122
122
|
const split = splitFormatPrefix(arg);
|
|
123
123
|
if (split !== null) {
|
|
124
124
|
const { prefix, rest } = split;
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAiB3C,IAAI,UAAU,GAAsB,IAAI,CAAC;AAEzC,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE;YACtB,IAAI,UAAU;gBAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;gBACxC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QACD,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE;YACzB,IAAI,UAAU;gBAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;gBACxC,OAAO,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AG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3E,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File mode: run a command whose inputs and outputs stay in files.
|
|
3
|
+
*
|
|
4
|
+
* {@link execute} copies every input into MEMFS and reads every output back
|
|
5
|
+
* into a Uint8Array, so a run holds each file in JS memory at least twice.
|
|
6
|
+
* {@link executeFiles} mounts the files into the module through
|
|
7
|
+
* [wopfs](https://gitlab.com/wasmedia/wopfs) instead: OPFS files in a
|
|
8
|
+
* dedicated worker, host files under Node. The wasm heap is unchanged — what
|
|
9
|
+
* ImageMagick decodes into its pixel cache still lives there — but the
|
|
10
|
+
* encoded inputs and outputs no longer sit in memory beside it.
|
|
11
|
+
*/
|
|
12
|
+
import type { WasmModule } from "./types.js";
|
|
13
|
+
/** An input for file mode: an OPFS file handle, or a host path under Node. */
|
|
14
|
+
export interface FileInput {
|
|
15
|
+
/** The name the command uses for it, e.g. `"photo.cr2"`. */
|
|
16
|
+
name: string;
|
|
17
|
+
file: FileSystemFileHandle | string;
|
|
18
|
+
}
|
|
19
|
+
/** Where outputs land: an OPFS directory handle, or a host directory path. */
|
|
20
|
+
export type OutputDir = FileSystemDirectoryHandle | string;
|
|
21
|
+
/** An output file mode wrote. */
|
|
22
|
+
export interface WrittenFile {
|
|
23
|
+
/** Its path relative to `outputDir`, as the command named it. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** The file in `outputDir`: a handle in the browser, a host path under Node. */
|
|
26
|
+
file: FileSystemFileHandle | string;
|
|
27
|
+
size: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ExecuteFilesOptions {
|
|
30
|
+
/** Required: where the files the command creates are written. */
|
|
31
|
+
outputDir: OutputDir;
|
|
32
|
+
/**
|
|
33
|
+
* How many files the command may create before wopfs holds further ones in
|
|
34
|
+
* memory. Defaults to the number of output filenames in the command plus 8,
|
|
35
|
+
* which covers `%d` frame sequences and `+adjoin` of short animations; raise
|
|
36
|
+
* it for longer ones.
|
|
37
|
+
*/
|
|
38
|
+
scratch?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Where to import wopfs from. The default, `"@wasmedia/wopfs"`, works under
|
|
41
|
+
* Node and with a bundler; a page loaded without one passes the URL of
|
|
42
|
+
* wopfs's `dist/index.js`.
|
|
43
|
+
*/
|
|
44
|
+
wopfsPath?: string;
|
|
45
|
+
/** Receives wopfs's warnings (pool exhausted, OPFS fallback). Default console.warn. */
|
|
46
|
+
onWarning?: (message: string) => void;
|
|
47
|
+
}
|
|
48
|
+
export interface CLIFileResult {
|
|
49
|
+
exitCode: number;
|
|
50
|
+
stdout: string;
|
|
51
|
+
stderr: string;
|
|
52
|
+
/** Outputs by name. Empty unless the command exited 0. */
|
|
53
|
+
written: Map<string, WrittenFile>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Run an ImageMagick command over files, without copying them into memory.
|
|
57
|
+
*
|
|
58
|
+
* Filenames in the command are resolved the way {@link execute} resolves
|
|
59
|
+
* them: input names refer to `inputs`, and any other `name.ext` argument is an
|
|
60
|
+
* output, written to `outputDir` when the command succeeds. Inputs are never
|
|
61
|
+
* modified.
|
|
62
|
+
*
|
|
63
|
+
* Where it runs:
|
|
64
|
+
* - **Dedicated worker** with OPFS: `FileSystemFileHandle` inputs are read in
|
|
65
|
+
* place, and outputs are written into a `FileSystemDirectoryHandle`.
|
|
66
|
+
* - **Node**: inputs are host paths, `outputDir` a host directory.
|
|
67
|
+
* - **Main thread**: there is no synchronous OPFS access, so wopfs falls back
|
|
68
|
+
* to copying (MEMFS) and outputs are written to `outputDir` afterwards. It
|
|
69
|
+
* works, but saves nothing.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // In a worker: an OPFS file in, an OPFS directory out.
|
|
74
|
+
* const r = await executeFiles(module, 'shot.cr2 -auto-orient -resize 50% shot.jpg',
|
|
75
|
+
* [{ name: 'shot.cr2', file: handle }], { outputDir: dir });
|
|
76
|
+
* r.written.get('shot.jpg'); // { name, file: FileSystemFileHandle, size }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function executeFiles(module: WasmModule, command: string | string[], inputs: FileInput[], options: ExecuteFilesOptions): Promise<CLIFileResult>;
|
|
80
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAAC;CACrC;AAED,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,yBAAyB,GAAG,MAAM,CAAC;AAE3D,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,SAAS,EAAE,SAAS,CAAC;IACrB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACnC;AAKD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,MAAM,EAAE,SAAS,EAAE,EACnB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAqExB"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File mode: run a command whose inputs and outputs stay in files.
|
|
3
|
+
*
|
|
4
|
+
* {@link execute} copies every input into MEMFS and reads every output back
|
|
5
|
+
* into a Uint8Array, so a run holds each file in JS memory at least twice.
|
|
6
|
+
* {@link executeFiles} mounts the files into the module through
|
|
7
|
+
* [wopfs](https://gitlab.com/wasmedia/wopfs) instead: OPFS files in a
|
|
8
|
+
* dedicated worker, host files under Node. The wasm heap is unchanged — what
|
|
9
|
+
* ImageMagick decodes into its pixel cache still lives there — but the
|
|
10
|
+
* encoded inputs and outputs no longer sit in memory beside it.
|
|
11
|
+
*/
|
|
12
|
+
import { captureOutput, parseCommand, rewriteArg } from "./cli.js";
|
|
13
|
+
import { loadWopfs } from "./wopfs.js";
|
|
14
|
+
const HEADROOM = 8;
|
|
15
|
+
let mountCounter = 0;
|
|
16
|
+
/**
|
|
17
|
+
* Run an ImageMagick command over files, without copying them into memory.
|
|
18
|
+
*
|
|
19
|
+
* Filenames in the command are resolved the way {@link execute} resolves
|
|
20
|
+
* them: input names refer to `inputs`, and any other `name.ext` argument is an
|
|
21
|
+
* output, written to `outputDir` when the command succeeds. Inputs are never
|
|
22
|
+
* modified.
|
|
23
|
+
*
|
|
24
|
+
* Where it runs:
|
|
25
|
+
* - **Dedicated worker** with OPFS: `FileSystemFileHandle` inputs are read in
|
|
26
|
+
* place, and outputs are written into a `FileSystemDirectoryHandle`.
|
|
27
|
+
* - **Node**: inputs are host paths, `outputDir` a host directory.
|
|
28
|
+
* - **Main thread**: there is no synchronous OPFS access, so wopfs falls back
|
|
29
|
+
* to copying (MEMFS) and outputs are written to `outputDir` afterwards. It
|
|
30
|
+
* works, but saves nothing.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // In a worker: an OPFS file in, an OPFS directory out.
|
|
35
|
+
* const r = await executeFiles(module, 'shot.cr2 -auto-orient -resize 50% shot.jpg',
|
|
36
|
+
* [{ name: 'shot.cr2', file: handle }], { outputDir: dir });
|
|
37
|
+
* r.written.get('shot.jpg'); // { name, file: FileSystemFileHandle, size }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export async function executeFiles(module, command, inputs, options) {
|
|
41
|
+
if (!options?.outputDir) {
|
|
42
|
+
throw new Error("executeFiles needs options.outputDir");
|
|
43
|
+
}
|
|
44
|
+
const names = new Set();
|
|
45
|
+
for (const input of inputs) {
|
|
46
|
+
if (names.has(input.name)) {
|
|
47
|
+
throw new Error(`executeFiles: input "${input.name}" is listed twice`);
|
|
48
|
+
}
|
|
49
|
+
names.add(input.name);
|
|
50
|
+
}
|
|
51
|
+
const args = typeof command === "string" ? parseCommand(command) : command;
|
|
52
|
+
const mountpoint = `/files_${++mountCounter}_${Date.now()}`;
|
|
53
|
+
const rewritten = args.map((arg) => rewriteArg(arg, names, mountpoint));
|
|
54
|
+
const outputs = args.filter((arg, i) => rewritten[i] !== arg && !names.has(stripPrefix(arg))).length;
|
|
55
|
+
const wopfs = await loadWopfs(options.wopfsPath);
|
|
56
|
+
const mount = await wopfs.mountFiles(module, mountpoint, {
|
|
57
|
+
inputs: Object.fromEntries(inputs.map((i) => [i.name, i.file])),
|
|
58
|
+
outputDir: options.outputDir,
|
|
59
|
+
scratch: options.scratch ?? outputs + HEADROOM,
|
|
60
|
+
onExhausted: "spill",
|
|
61
|
+
onWarning: options.onWarning,
|
|
62
|
+
});
|
|
63
|
+
let exitCode;
|
|
64
|
+
let stdout = "";
|
|
65
|
+
let stderr = "";
|
|
66
|
+
const written = new Map();
|
|
67
|
+
// Set when the run or the commit fails, so a release() error never hides it.
|
|
68
|
+
let failed = false;
|
|
69
|
+
try {
|
|
70
|
+
try {
|
|
71
|
+
const run = captureOutput(() => module.callMain(rewritten));
|
|
72
|
+
exitCode = run.value;
|
|
73
|
+
stdout = run.stdout;
|
|
74
|
+
stderr = run.stderr;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
exitCode = 1;
|
|
78
|
+
stderr += `Exception: ${e}\n`;
|
|
79
|
+
}
|
|
80
|
+
// A failed command may leave a truncated output behind; only a
|
|
81
|
+
// successful run is committed.
|
|
82
|
+
if (exitCode === 0) {
|
|
83
|
+
for (const file of await mount.commit()) {
|
|
84
|
+
const out = await toWrittenFile(file, options.outputDir);
|
|
85
|
+
written.set(out.name, out);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
failed = true;
|
|
91
|
+
throw e;
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
await mount.release();
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
if (!failed)
|
|
99
|
+
throw e;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
exitCode,
|
|
104
|
+
stdout: stdout.trimEnd(),
|
|
105
|
+
stderr: stderr.trimEnd(),
|
|
106
|
+
written,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** `png:out.png` → `out.png`; anything without a format prefix is unchanged. */
|
|
110
|
+
function stripPrefix(arg) {
|
|
111
|
+
const m = /^[A-Za-z][A-Za-z0-9+-]*:(.+)$/.exec(arg);
|
|
112
|
+
return m ? m[1] : arg;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Turn what wopfs committed into a {@link WrittenFile}. The opfs and node
|
|
116
|
+
* backends have already put the file in outputDir; the memfs fallback (main
|
|
117
|
+
* thread) hands back bytes, which are written there now.
|
|
118
|
+
*/
|
|
119
|
+
async function toWrittenFile(file, outputDir) {
|
|
120
|
+
if (file.handle)
|
|
121
|
+
return { name: file.path, file: file.handle, size: file.size };
|
|
122
|
+
if (file.hostPath)
|
|
123
|
+
return { name: file.path, file: file.hostPath, size: file.size };
|
|
124
|
+
if (file.bytes && typeof outputDir !== "string") {
|
|
125
|
+
const parts = file.path.split("/");
|
|
126
|
+
const leaf = parts.pop();
|
|
127
|
+
let dir = outputDir;
|
|
128
|
+
for (const part of parts)
|
|
129
|
+
dir = await dir.getDirectoryHandle(part, { create: true });
|
|
130
|
+
const handle = await dir.getFileHandle(leaf, { create: true });
|
|
131
|
+
if (typeof handle.createWritable !== "function") {
|
|
132
|
+
throw new Error("executeFiles on the main thread needs FileSystemFileHandle.createWritable " +
|
|
133
|
+
"to write outputs; run it in a dedicated worker instead");
|
|
134
|
+
}
|
|
135
|
+
const writable = await handle.createWritable();
|
|
136
|
+
await writable.write(file.bytes);
|
|
137
|
+
await writable.close();
|
|
138
|
+
return { name: file.path, file: handle, size: file.size };
|
|
139
|
+
}
|
|
140
|
+
throw new Error(`executeFiles: wopfs committed "${file.path}" with nowhere to put it`);
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,SAAS,EAA2B,MAAM,YAAY,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I,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;QAC1B,IAAI,GAAG,GAAG,SAAS,CAAC;QACpB,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,GAAG,GAAG,MAAM,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACrF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CACb,4EAA4E;gBAC1E,wDAAwD,CAC3D,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;QAC/C,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAC;QAC5D,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;QACvB,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,CAAC,IAAI,0BAA0B,CAAC,CAAC;AACzF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
export { initWImageMagick } from "./loader.js";
|
|
20
20
|
export { WMagickImage } from "./image.js";
|
|
21
21
|
export { execute, identify, parseCommand } from "./cli.js";
|
|
22
|
+
export { executeFiles } from "./files.js";
|
|
23
|
+
export type { FileInput, OutputDir, WrittenFile, ExecuteFilesOptions, CLIFileResult, } from "./files.js";
|
|
22
24
|
export { detectRawFormat } from "./raw.js";
|
|
23
25
|
export { createWorkerHandler, PROCESS_OPERATIONS } from "./worker-handler.js";
|
|
24
26
|
export type { WorkerMessage, WorkerResponse, ProcessOperation, ProcessOperationName, ProcessPayload, ProcessResult, } from "./worker-handler.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG3D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EACV,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,MAAM,EACN,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EACV,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,MAAM,EACN,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,8 @@ export { initWImageMagick } from "./loader.js";
|
|
|
22
22
|
export { WMagickImage } from "./image.js";
|
|
23
23
|
// CLI interface
|
|
24
24
|
export { execute, identify, parseCommand } from "./cli.js";
|
|
25
|
+
// File mode: inputs and outputs that stay in files (through wopfs)
|
|
26
|
+
export { executeFiles } from "./files.js";
|
|
25
27
|
// Camera raw detection
|
|
26
28
|
export { detectRawFormat } from "./raw.js";
|
|
27
29
|
// Web Worker protocol (the worker itself is the "@wasmedia/wimagemagick/worker" entry)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,yBAAyB;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,gBAAgB;AAChB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE3D,uBAAuB;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,uFAAuF;AACvF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAU9E,yBAAyB;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,qBAAqB;AACrB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,MAAM,EACN,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAazB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,yBAAyB;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,gBAAgB;AAChB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE3D,mEAAmE;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS1C,uBAAuB;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,uFAAuF;AACvF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAU9E,yBAAyB;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,qBAAqB;AACrB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,MAAM,EACN,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAazB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/dist/licenses/README.txt
CHANGED
|
@@ -3,8 +3,8 @@ directory holds each one's licence. The wimagemagick wrapper itself is
|
|
|
3
3
|
Apache-2.0 (see LICENSE in the package root).
|
|
4
4
|
|
|
5
5
|
ImageMagick (df347d975045aab2f5e3104cfc35c94cc29a4ac6): imagemagick-LICENSE.txt, imagemagick-NOTICE.txt
|
|
6
|
-
LibRaw 0.22.
|
|
7
|
-
From ImageMagick/Dependencies 2026.
|
|
6
|
+
LibRaw 0.22.2 (LGPL-2.1 or CDDL-1.0): libraw-*.txt
|
|
7
|
+
From ImageMagick/Dependencies 2026.09.26.1516: aom brotli de265 ffi freetype glib heif highway jpeg-turbo jpeg-xl lcms lqr openjpeg png tiff webp xml zlib zstd
|
|
8
8
|
|
|
9
9
|
Several of these are LGPL and linked statically. Everything needed to rebuild
|
|
10
10
|
wimagemagick.wasm against modified versions of them is in the source
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[ ffi 3.
|
|
1
|
+
[ ffi 3.8.0 (2026-08-09) ]
|
|
2
2
|
|
|
3
|
-
libffi - Copyright (c) 1996-
|
|
3
|
+
libffi - Copyright (c) 1996-2026 Anthony Green, Red Hat, Inc and others.
|
|
4
4
|
See source files for details.
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining
|