Skip to content

Commit 025de35

Browse files
committed
Add TypeScript defs and ES6 module generation
1 parent 4bdda9a commit 025de35

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

7z-Src/CPP/7zip/7zip_gcc.mak

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ ifdef WASM_EXCEPTION_CATCHING
200200
LIB2 += -sDISABLE_EXCEPTION_CATCHING=0
201201
endif # WASM_EXCEPTION_CATCHING
202202

203+
ifdef EXPORT_ES6
204+
LIB2 += -sEXPORT_ES6=1
205+
endif # EXPORT_ES6
206+
207+
ifdef EMIT_TSD
208+
LIB2 += --emit-tsd js7z.d.ts
209+
endif # EMIT_TSD
210+
203211
else
204212
LIB2 = -lpthread -ldl
205213
endif # EMSCRIPTEN

7z-Src/CPP/7zip/Bundles/Alone2/makefile.gcc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
ifdef EMSCRIPTEN
2+
3+
ifdef EXPORT_ES6
4+
PROG = js7z.mjs
5+
else
26
PROG = js7z.js
7+
endif
8+
39
# ST_MODE = 1
410
# WASM_EXTRA_FS = 1
511
# WASM_EXCEPTION_CATCHING = 1

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ Downloading Pre-Built Distributions
1717

1818
The latest pre-built versions can be downloaded here: https://github.com/GMH-Code/JS7z/releases
1919

20-
There are four main variants available:
20+
There are several variants available with a range of features. The fastest, most stable, and recommended version is `[MT+FS+EC]`. The initialisms mean this:
2121

22-
- Multi-threaded: `[MT]`
23-
- Multi-threaded with extended file system functionality: `[MT+FS]`
24-
- Single-threaded: `[ST]`
25-
- Single-threaded with extended file system functionality: `[ST+FS]`
22+
- `MT` or `ST`: Multi-threaded or single-threaded
23+
- `FS`: Extended file system functionality
24+
- `EC`: Extra internal exception catching (essential for some scenarios)!
2625

27-
The recommended version (if you are not sure which one you need yet), is `[MT+FS]`.
26+
The recommended version is also available as an [NPM package](https://www.npmjs.com/package/js7z-tools) for *Node.js* users.
2827

2928
Usage
3029
-----
@@ -221,8 +220,8 @@ Multi-Threaded vs. Single-Threaded Builds
221220

222221
In most cases, you will want to use a multi-threaded version, but you can fall back to a single-threaded version if you like.
223222

224-
- Multi-thread mode works in nearly all modern browsers. It is extremely fast, runs in the background, and returns immediately.
225-
- Single-thread mode supports less common browsers, but is slower with certain tasks. It also can require a bit more work to use.
223+
- Multi-thread mode works in nearly all modern browsers and *Node.js*. It is extremely fast, runs in the background, and returns immediately.
224+
- Single-thread mode supports less common browsers, but is slower with certain tasks. It can also require a bit more work to use.
226225

227226
Warning: Calling `callMain()` in single-thread mode *currently* returns after the command completes, so long processes can hang the browser unless you run them in a Worker. You should still use `onExit(exitCode)` to detect a proper exit. The single-threaded version may also run in the same asynchronous way one day.
228227

@@ -269,10 +268,15 @@ You can insert extra parameters between `emmake make` and the rest of the comman
269268

270269
Usage of these compilation flags will be displayed in 7-Zip's output.
271270

272-
Selecting extra exception catching will add `+EC` to the flags. This feature allows you to see further details of failures, such as extraction security issues, corrupt archive data, and incorrect passwords. Using this increases the build size, so it is switched off by default.
271+
Selecting extra exception catching increases the build size, but it allows you to see further details of failures, such as extraction security issues, corrupt archive data, and incorrect passwords.
273272

274273
At the final stage of the build, `js7z.js` and `js7z.wasm` will be written into the `Alone2/b/g` folder.
275274

275+
There are some other parameters available that slightly alter the exported build, but they do not affect the WebAssembly side:
276+
277+
- To export a JavaScript ES6 module, add `EXPORT_ES6=1`. This will also change the name of `js7z.js` to `js7z.mjs`.
278+
- To generate a TypeScript definitions file, add `EMIT_TSD=1`. This will create `js7z.d.ts`.
279+
276280
---
277281

278-
This documentation Copyright (C) 2024 Gregory Maynard-Hoare. See the `7z-Src/DOC` folder for licence information.
282+
This documentation Copyright (C) 2025 Gregory Maynard-Hoare. See the `7z-Src/DOC` folder for licence information.

0 commit comments

Comments
 (0)