@oxc-minify/binding-wasm32-wasi 0.141.0 → 0.143.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.
@@ -0,0 +1,286 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export interface CodegenOptions {
4
+ /**
5
+ * Remove whitespace.
6
+ *
7
+ * @default true
8
+ */
9
+ removeWhitespace?: boolean
10
+ /**
11
+ * How to handle legal comments (comments containing `@license`, `@preserve`, or starting with `//!`/`/*!`).
12
+ *
13
+ * * `"none"` - Do not preserve any legal comments.
14
+ * * `"inline"` - Preserve all legal comments inline.
15
+ * * `"eof"` - Move all legal comments to the end of the file.
16
+ * * `"external"` - Extract legal comments without linking.
17
+ * * `{ linked: "path/to/legal.txt" }` - Extract legal comments and add a link comment to the given path.
18
+ *
19
+ * @default "none" (when minifying)
20
+ */
21
+ legalComments?: 'none' | 'inline' | 'eof' | 'external' | { linked: string }
22
+ }
23
+
24
+ export interface CompressOptions {
25
+ /**
26
+ * Set desired EcmaScript standard version for output.
27
+ *
28
+ * Set `esnext` to enable all target highering.
29
+ *
30
+ * Example:
31
+ *
32
+ * * `'es2015'`
33
+ * * `['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']`
34
+ *
35
+ * @default 'esnext'
36
+ *
37
+ * @see [oxc#target](https://oxc.rs/docs/guide/usage/transformer/lowering#target)
38
+ */
39
+ target?: string | Array<string>
40
+ /**
41
+ * Pass true to discard calls to `console.*`.
42
+ *
43
+ * @default false
44
+ */
45
+ dropConsole?: boolean
46
+ /**
47
+ * Remove `debugger;` statements.
48
+ *
49
+ * @default true
50
+ */
51
+ dropDebugger?: boolean
52
+ /**
53
+ * Pass `true` to drop unreferenced functions and variables.
54
+ *
55
+ * Simple direct variable assignments do not count as references unless set to `keep_assign`.
56
+ * @default true
57
+ */
58
+ unused?: boolean | 'keep_assign'
59
+ /** Keep function / class names. */
60
+ keepNames?: CompressOptionsKeepNames
61
+ /**
62
+ * Join consecutive var, let and const statements.
63
+ *
64
+ * @default true
65
+ */
66
+ joinVars?: boolean
67
+ /**
68
+ * Join consecutive simple statements using the comma operator.
69
+ *
70
+ * `a; b` -> `a, b`
71
+ *
72
+ * @default true
73
+ */
74
+ sequences?: boolean
75
+ /**
76
+ * Set of label names to drop from the code.
77
+ *
78
+ * Labeled statements matching these names will be removed during minification.
79
+ *
80
+ * @default []
81
+ */
82
+ dropLabels?: Array<string>
83
+ /** Limit the maximum number of iterations for debugging purpose. */
84
+ maxIterations?: number
85
+ /** Treeshake options. */
86
+ treeshake?: TreeShakeOptions
87
+ }
88
+
89
+ export interface CompressOptionsKeepNames {
90
+ /**
91
+ * Keep function names so that `Function.prototype.name` is preserved.
92
+ *
93
+ * This does not guarantee that the `undefined` name is preserved.
94
+ *
95
+ * @default false
96
+ */
97
+ function: boolean
98
+ /**
99
+ * Keep class names so that `Class.prototype.name` is preserved.
100
+ *
101
+ * This does not guarantee that the `undefined` name is preserved.
102
+ *
103
+ * @default false
104
+ */
105
+ class: boolean
106
+ }
107
+
108
+ export interface LegalCommentsLinked {
109
+ /**
110
+ * Extract legal comments and write them to the given path, with a link
111
+ * comment appended to the generated code.
112
+ */
113
+ linked: string
114
+ }
115
+
116
+ export declare const enum LegalCommentsMode {
117
+ /** Do not preserve any legal comments. */
118
+ None = 'none',
119
+ /** Preserve all legal comments inline. */
120
+ Inline = 'inline',
121
+ /** Move all legal comments to the end of the file. */
122
+ Eof = 'eof',
123
+ /** Extract legal comments without linking. */
124
+ External = 'external'
125
+ }
126
+
127
+ export interface MangleOptions {
128
+ /**
129
+ * Pass `true` to mangle names declared in the top level scope.
130
+ *
131
+ * @default true for modules and commonjs, otherwise false
132
+ */
133
+ toplevel?: boolean
134
+ /**
135
+ * Preserve `name` property for functions and classes.
136
+ *
137
+ * @default false
138
+ */
139
+ keepNames?: boolean | MangleOptionsKeepNames
140
+ /**
141
+ * Names that bindings must not be renamed to, and that bindings already
142
+ * carrying them keep. Equivalent to terser's `mangle.reserved`.
143
+ *
144
+ * Pass `['exports', 'module']` when minifying prebuilt CommonJS / UMD files
145
+ * that Node consumers `import` directly, so Node's cjs-module-lexer can still
146
+ * detect the mangled module's named exports.
147
+ *
148
+ * @default []
149
+ */
150
+ reserved?: Array<string>
151
+ /** Debug mangled names. */
152
+ debug?: boolean
153
+ }
154
+
155
+ export interface MangleOptionsKeepNames {
156
+ /**
157
+ * Preserve `name` property for functions.
158
+ *
159
+ * @default false
160
+ */
161
+ function: boolean
162
+ /**
163
+ * Preserve `name` property for classes.
164
+ *
165
+ * @default false
166
+ */
167
+ class: boolean
168
+ }
169
+
170
+ /**
171
+ * Minify asynchronously.
172
+ *
173
+ * Note: This function can be slower than `minifySync` due to the overhead of spawning a thread.
174
+ */
175
+ export declare function minify(filename: string, sourceText: string, options?: MinifyOptions | undefined | null): Promise<MinifyResult>
176
+
177
+ export interface MinifyOptions {
178
+ /** Use when minifying an ES module. */
179
+ module?: boolean
180
+ compress?: boolean | CompressOptions
181
+ mangle?: boolean | MangleOptions
182
+ codegen?: boolean | CodegenOptions
183
+ sourcemap?: boolean
184
+ }
185
+
186
+ export interface MinifyResult {
187
+ code: string
188
+ map?: SourceMap
189
+ errors: Array<OxcError>
190
+ /**
191
+ * Legal comments extracted from the source code.
192
+ * Only populated when `codegen.legalComments` is `"linked"` or `"external"`.
193
+ */
194
+ legalComments: Array<string>
195
+ }
196
+
197
+ /** Minify synchronously. */
198
+ export declare function minifySync(filename: string, sourceText: string, options?: MinifyOptions | undefined | null): MinifyResult
199
+
200
+ export interface TreeShakeOptions {
201
+ /**
202
+ * Whether to respect the pure annotations.
203
+ *
204
+ * Pure annotations are comments that mark an expression as pure.
205
+ * For example: @__PURE__ or #__NO_SIDE_EFFECTS__.
206
+ *
207
+ * @default true
208
+ */
209
+ annotations?: boolean
210
+ /**
211
+ * Whether to treat this function call as pure.
212
+ *
213
+ * This function is called for normal function calls, new calls, and
214
+ * tagged template calls.
215
+ */
216
+ manualPureFunctions?: Array<string>
217
+ /**
218
+ * Whether property read accesses have side effects.
219
+ *
220
+ * @default 'always'
221
+ */
222
+ propertyReadSideEffects?: boolean | 'always'
223
+ /**
224
+ * Whether property write accesses (assignments to member expressions) have side effects.
225
+ *
226
+ * When false, assignments like `obj.prop = value` are considered side-effect-free
227
+ * (assuming the object and value expressions themselves are side-effect-free).
228
+ *
229
+ * @default true
230
+ */
231
+ propertyWriteSideEffects?: boolean
232
+ /**
233
+ * Whether accessing a global variable has side effects.
234
+ *
235
+ * Accessing a non-existing global variable will throw an error.
236
+ * Global variable may be a getter that has side effects.
237
+ *
238
+ * @default true
239
+ */
240
+ unknownGlobalSideEffects?: boolean
241
+ /**
242
+ * Whether invalid import statements have side effects.
243
+ *
244
+ * Accessing a non-existing import name will throw an error.
245
+ * Also import statements that cannot be resolved will throw an error.
246
+ *
247
+ * @default true
248
+ */
249
+ invalidImportSideEffects?: boolean
250
+ }
251
+ export interface Comment {
252
+ type: 'Line' | 'Block'
253
+ value: string
254
+ start: number
255
+ end: number
256
+ }
257
+
258
+ export interface ErrorLabel {
259
+ message: string | null
260
+ start: number
261
+ end: number
262
+ }
263
+
264
+ export interface OxcError {
265
+ severity: Severity
266
+ message: string
267
+ labels: Array<ErrorLabel>
268
+ helpMessage: string | null
269
+ codeframe: string | null
270
+ }
271
+
272
+ export declare const enum Severity {
273
+ Error = 'Error',
274
+ Warning = 'Warning',
275
+ Advice = 'Advice'
276
+ }
277
+ export interface SourceMap {
278
+ file?: string
279
+ mappings: string
280
+ names: Array<string>
281
+ sourceRoot?: string
282
+ sources: Array<string>
283
+ sourcesContent?: Array<string>
284
+ version: number
285
+ x_google_ignoreList?: Array<number>
286
+ }
Binary file
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "@oxc-minify/binding-wasm32-wasi",
3
- "version": "0.141.0",
4
- "cpu": [
5
- "wasm32"
6
- ],
3
+ "version": "0.143.0",
7
4
  "main": "minify.wasi.cjs",
8
5
  "files": [
9
6
  "minify.wasm32-wasi.wasm",
10
7
  "minify.wasi.cjs",
8
+ "minify.wasi.d.cts",
11
9
  "minify.wasi-browser.js",
12
10
  "wasi-worker.mjs",
13
11
  "wasi-worker-browser.mjs"
@@ -26,7 +24,7 @@
26
24
  "homepage": "https://oxc.rs/docs/guide/usage/minifier",
27
25
  "license": "MIT",
28
26
  "engines": {
29
- "node": "^20.19.0 || >=22.12.0"
27
+ "node": "^20.19.0 || ^22.13.0 || >=23.5.0"
30
28
  },
31
29
  "repository": {
32
30
  "type": "git",
@@ -38,10 +36,12 @@
38
36
  "registry": "https://registry.npmjs.org/",
39
37
  "access": "public"
40
38
  },
39
+ "types": "minify.wasi.d.cts",
41
40
  "browser": "minify.wasi-browser.js",
41
+ "type": "module",
42
42
  "dependencies": {
43
- "@napi-rs/wasm-runtime": "^1.1.6",
44
- "@emnapi/core": "1.11.2",
45
- "@emnapi/runtime": "1.11.2"
43
+ "@napi-rs/wasm-runtime": "~1.2.2",
44
+ "@emnapi/core": "2.0.0-alpha.3",
45
+ "@emnapi/runtime": "2.0.0-alpha.3"
46
46
  }
47
47
  }
@@ -1,4 +1,10 @@
1
- import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
1
+ import {
2
+ instantiateNapiModuleSync,
3
+ MessageHandler,
4
+ WASI,
5
+ emnapiAsyncWorkPlugin,
6
+ emnapiTSFNPlugin,
7
+ } from '@napi-rs/wasm-runtime'
2
8
 
3
9
  const handler = new MessageHandler({
4
10
  onLoad({ wasmModule, wasmMemory }) {
@@ -16,6 +22,11 @@ const handler = new MessageHandler({
16
22
  return instantiateNapiModuleSync(wasmModule, {
17
23
  childThread: true,
18
24
  wasi,
25
+ // The wasm links a "basic" emnapi archive (no C async-work /
26
+ // threadsafe-function implementations), so every thread that
27
+ // instantiates it must provide the JavaScript implementations
28
+ // through the emnapi plugins.
29
+ plugins: [emnapiAsyncWorkPlugin, emnapiTSFNPlugin],
19
30
  overwriteImports(importObject) {
20
31
  importObject.env = {
21
32
  ...importObject.env,
package/wasi-worker.mjs CHANGED
@@ -6,7 +6,13 @@ import { parentPort, Worker } from "node:worker_threads";
6
6
 
7
7
  const require = createRequire(import.meta.url);
8
8
 
9
- const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime");
9
+ const {
10
+ instantiateNapiModuleSync,
11
+ MessageHandler,
12
+ getDefaultContext,
13
+ emnapiAsyncWorkPlugin,
14
+ emnapiTSFNPlugin,
15
+ } = require("@napi-rs/wasm-runtime");
10
16
 
11
17
  if (parentPort) {
12
18
  parentPort.on("message", (data) => {
@@ -46,6 +52,11 @@ const handler = new MessageHandler({
46
52
  childThread: true,
47
53
  wasi,
48
54
  context: emnapiContext,
55
+ // The wasm links a "basic" emnapi archive (no C async-work /
56
+ // threadsafe-function implementations), so every thread that
57
+ // instantiates it must provide the JavaScript implementations
58
+ // through the emnapi plugins.
59
+ plugins: [emnapiAsyncWorkPlugin, emnapiTSFNPlugin],
49
60
  overwriteImports(importObject) {
50
61
  importObject.env = {
51
62
  ...importObject.env,