@napi-rs/snappy-wasm32-wasi 7.3.2 → 7.4.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,41 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare function compress(
4
+ input: string | Uint8Array,
5
+ options?: EncOptions | undefined | null,
6
+ signal?: AbortSignal | undefined | null,
7
+ ): Promise<Buffer>
8
+
9
+ export declare function compressSync(input: string | Uint8Array, options?: EncOptions | undefined | null): Buffer
10
+
11
+ export interface DecOptions {
12
+ asBuffer?: boolean
13
+ /**
14
+ * do not use `create_external_buffer` to create the output buffer \n
15
+ * set this option to `true` will make the API slower \n
16
+ * for compatibility with electron >= 21 \n
17
+ * see https://www.electronjs.org/blog/v8-memory-cage and https://github.com/electron/electron/issues/35801#issuecomment-1261206333
18
+ */
19
+ copyOutputData?: boolean
20
+ }
21
+
22
+ export interface EncOptions {
23
+ /**
24
+ * do not use `create_external_buffer` to create the output buffer \n
25
+ * for compatibility with electron >= 21 \n
26
+ * set this option to `true` will make the API slower \n
27
+ * see https://www.electronjs.org/blog/v8-memory-cage and https://github.com/electron/electron/issues/35801#issuecomment-1261206333
28
+ */
29
+ copyOutputData?: boolean
30
+ }
31
+
32
+ export declare function uncompress(
33
+ input: string | Uint8Array,
34
+ options?: DecOptions | undefined | null,
35
+ signal?: AbortSignal | undefined | null,
36
+ ): Promise<string | Buffer>
37
+
38
+ export declare function uncompressSync(
39
+ input: string | Uint8Array,
40
+ options?: DecOptions | undefined | null,
41
+ ): string | Buffer
Binary file
@@ -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 }) {
@@ -10,11 +16,17 @@ const handler = new MessageHandler({
10
16
  printErr: function() {
11
17
  // eslint-disable-next-line no-console
12
18
  console.error.apply(console, arguments)
19
+
13
20
  },
14
21
  })
15
22
  return instantiateNapiModuleSync(wasmModule, {
16
23
  childThread: true,
17
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],
18
30
  overwriteImports(importObject) {
19
31
  importObject.env = {
20
32
  ...importObject.env,
@@ -25,6 +37,7 @@ const handler = new MessageHandler({
25
37
  },
26
38
  })
27
39
  },
40
+
28
41
  })
29
42
 
30
43
  globalThis.onmessage = function (e) {
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,