@aztec/foundation 0.83.1 → 0.84.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.
Files changed (115) hide show
  1. package/dest/config/env_var.d.ts +1 -1
  2. package/dest/config/env_var.d.ts.map +1 -1
  3. package/dest/index.d.ts +0 -2
  4. package/dest/index.d.ts.map +1 -1
  5. package/dest/index.js +0 -2
  6. package/dest/log/index.d.ts +3 -4
  7. package/dest/log/index.d.ts.map +1 -1
  8. package/dest/log/index.js +3 -4
  9. package/dest/log/noir_debug_log_util.d.ts +14 -0
  10. package/dest/log/noir_debug_log_util.d.ts.map +1 -0
  11. package/dest/log/noir_debug_log_util.js +14 -0
  12. package/dest/transport/index.d.ts +0 -1
  13. package/dest/transport/index.d.ts.map +1 -1
  14. package/dest/transport/index.js +0 -1
  15. package/package.json +2 -4
  16. package/src/config/env_var.ts +1 -1
  17. package/src/index.ts +0 -2
  18. package/src/log/index.ts +3 -4
  19. package/src/log/noir_debug_log_util.ts +21 -0
  20. package/src/transport/index.ts +0 -1
  21. package/dest/log/debug.d.ts +0 -56
  22. package/dest/log/debug.d.ts.map +0 -1
  23. package/dest/log/debug.js +0 -75
  24. package/dest/log/log_history.d.ts +0 -31
  25. package/dest/log/log_history.d.ts.map +0 -1
  26. package/dest/log/log_history.js +0 -38
  27. package/dest/transport/browser/index.d.ts +0 -5
  28. package/dest/transport/browser/index.d.ts.map +0 -1
  29. package/dest/transport/browser/index.js +0 -4
  30. package/dest/transport/browser/message_port_socket.d.ts +0 -37
  31. package/dest/transport/browser/message_port_socket.d.ts.map +0 -1
  32. package/dest/transport/browser/message_port_socket.js +0 -42
  33. package/dest/transport/browser/shared_worker_connector.d.ts +0 -19
  34. package/dest/transport/browser/shared_worker_connector.d.ts.map +0 -1
  35. package/dest/transport/browser/shared_worker_connector.js +0 -19
  36. package/dest/transport/browser/shared_worker_listener.d.ts +0 -38
  37. package/dest/transport/browser/shared_worker_listener.d.ts.map +0 -1
  38. package/dest/transport/browser/shared_worker_listener.js +0 -33
  39. package/dest/transport/browser/worker_connector.d.ts +0 -26
  40. package/dest/transport/browser/worker_connector.d.ts.map +0 -1
  41. package/dest/transport/browser/worker_connector.js +0 -30
  42. package/dest/transport/browser/worker_listener.d.ts +0 -39
  43. package/dest/transport/browser/worker_listener.d.ts.map +0 -1
  44. package/dest/transport/browser/worker_listener.js +0 -35
  45. package/dest/wasm/empty_wasi_sdk.d.ts +0 -130
  46. package/dest/wasm/empty_wasi_sdk.d.ts.map +0 -1
  47. package/dest/wasm/empty_wasi_sdk.js +0 -148
  48. package/dest/wasm/index.d.ts +0 -2
  49. package/dest/wasm/index.d.ts.map +0 -1
  50. package/dest/wasm/index.js +0 -1
  51. package/dest/wasm/wasm_module.d.ts +0 -136
  52. package/dest/wasm/wasm_module.d.ts.map +0 -1
  53. package/dest/wasm/wasm_module.js +0 -196
  54. package/dest/worker/browser/index.d.ts +0 -3
  55. package/dest/worker/browser/index.d.ts.map +0 -1
  56. package/dest/worker/browser/index.js +0 -2
  57. package/dest/worker/browser/start_web_module.d.ts +0 -7
  58. package/dest/worker/browser/start_web_module.d.ts.map +0 -1
  59. package/dest/worker/browser/start_web_module.js +0 -27
  60. package/dest/worker/browser/web_data_store.d.ts +0 -24
  61. package/dest/worker/browser/web_data_store.d.ts.map +0 -1
  62. package/dest/worker/browser/web_data_store.js +0 -29
  63. package/dest/worker/browser/web_worker.d.ts +0 -10
  64. package/dest/worker/browser/web_worker.d.ts.map +0 -1
  65. package/dest/worker/browser/web_worker.js +0 -25
  66. package/dest/worker/data_store.d.ts +0 -21
  67. package/dest/worker/data_store.d.ts.map +0 -1
  68. package/dest/worker/data_store.js +0 -3
  69. package/dest/worker/index.d.ts +0 -3
  70. package/dest/worker/index.d.ts.map +0 -1
  71. package/dest/worker/index.js +0 -1
  72. package/dest/worker/node/index.d.ts +0 -3
  73. package/dest/worker/node/index.d.ts.map +0 -1
  74. package/dest/worker/node/index.js +0 -2
  75. package/dest/worker/node/node_data_store.d.ts +0 -13
  76. package/dest/worker/node/node_data_store.d.ts.map +0 -1
  77. package/dest/worker/node/node_data_store.js +0 -20
  78. package/dest/worker/node/node_worker.d.ts +0 -6
  79. package/dest/worker/node/node_worker.d.ts.map +0 -1
  80. package/dest/worker/node/node_worker.js +0 -22
  81. package/dest/worker/node/start_node_module.d.ts +0 -7
  82. package/dest/worker/node/start_node_module.d.ts.map +0 -1
  83. package/dest/worker/node/start_node_module.js +0 -31
  84. package/dest/worker/wasm_worker.d.ts +0 -9
  85. package/dest/worker/wasm_worker.d.ts.map +0 -1
  86. package/dest/worker/wasm_worker.js +0 -3
  87. package/dest/worker/worker_pool.d.ts +0 -40
  88. package/dest/worker/worker_pool.d.ts.map +0 -1
  89. package/dest/worker/worker_pool.js +0 -51
  90. package/src/log/debug.ts +0 -104
  91. package/src/log/log_history.ts +0 -44
  92. package/src/transport/browser/index.ts +0 -4
  93. package/src/transport/browser/message_port_socket.ts +0 -48
  94. package/src/transport/browser/shared_worker_connector.ts +0 -21
  95. package/src/transport/browser/shared_worker_listener.ts +0 -53
  96. package/src/transport/browser/worker_connector.ts +0 -30
  97. package/src/transport/browser/worker_listener.ts +0 -54
  98. package/src/wasm/README.md +0 -6
  99. package/src/wasm/empty_wasi_sdk.ts +0 -166
  100. package/src/wasm/fixtures/gcd.wasm +0 -0
  101. package/src/wasm/fixtures/gcd.wat +0 -27
  102. package/src/wasm/index.ts +0 -1
  103. package/src/wasm/wasm_module.ts +0 -260
  104. package/src/worker/browser/index.ts +0 -2
  105. package/src/worker/browser/start_web_module.ts +0 -24
  106. package/src/worker/browser/web_data_store.ts +0 -38
  107. package/src/worker/browser/web_worker.ts +0 -25
  108. package/src/worker/data_store.ts +0 -19
  109. package/src/worker/index.ts +0 -2
  110. package/src/worker/node/index.ts +0 -2
  111. package/src/worker/node/node_data_store.ts +0 -27
  112. package/src/worker/node/node_worker.ts +0 -23
  113. package/src/worker/node/start_node_module.ts +0 -30
  114. package/src/worker/wasm_worker.ts +0 -7
  115. package/src/worker/worker_pool.ts +0 -73
@@ -1,38 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import EventEmitter from 'events';
3
- import type { Listener } from '../interface/listener.js';
4
- /**
5
- * Represents the global scope of a Shared Worker.
6
- * Provides functionality to handle incoming connections and manage communication with other scripts
7
- * running in a shared context, enabling concurrent access and efficient resource sharing among those scripts.
8
- */
9
- declare interface SharedWorkerGlobalScope {
10
- /**
11
- * Event handler for new connections to the Shared Worker.
12
- */
13
- onconnect: (...args: any) => any;
14
- }
15
- /**
16
- * SharedWorkerListener is an extension of the EventEmitter class that implements the Listener interface.
17
- * It provides functionality to handle incoming messages from a shared worker and emit events for new sockets
18
- * created in response to these incoming connections. This class is meant to be used in the context of managing
19
- * MessagePort connections within the SharedWorkerGlobalScope.
20
- */
21
- export declare class SharedWorkerListener extends EventEmitter implements Listener {
22
- private worker;
23
- constructor(worker: SharedWorkerGlobalScope);
24
- /**
25
- * Initializes the shared worker listener by assigning the 'handleMessageEvent' method as the event handler
26
- * for the 'onconnect' event of the SharedWorkerGlobalScope. The 'handleMessageEvent' function will be called
27
- * whenever a new connection is established with the shared worker.
28
- */
29
- open(): void;
30
- /**
31
- * Closes the SharedWorkerListener by detaching the 'onconnect' event handler.
32
- * This stops the listener from emitting new sockets on incoming connections.
33
- */
34
- close(): void;
35
- private handleMessageEvent;
36
- }
37
- export {};
38
- //# sourceMappingURL=shared_worker_listener.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared_worker_listener.d.ts","sourceRoot":"","sources":["../../../src/transport/browser/shared_worker_listener.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD;;;;GAIG;AACH,OAAO,WAAW,uBAAuB;IACvC;;OAEG;IACH,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC;CAClC;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,YAAa,YAAW,QAAQ;IAC5D,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,uBAAuB;IAInD;;;;OAIG;IACH,IAAI;IAIJ;;;OAGG;IACH,KAAK;IAIL,OAAO,CAAC,kBAAkB,CAMxB;CACH"}
@@ -1,33 +0,0 @@
1
- import EventEmitter from 'events';
2
- import { MessagePortSocket } from './message_port_socket.js';
3
- /**
4
- * SharedWorkerListener is an extension of the EventEmitter class that implements the Listener interface.
5
- * It provides functionality to handle incoming messages from a shared worker and emit events for new sockets
6
- * created in response to these incoming connections. This class is meant to be used in the context of managing
7
- * MessagePort connections within the SharedWorkerGlobalScope.
8
- */ export class SharedWorkerListener extends EventEmitter {
9
- worker;
10
- constructor(worker){
11
- super(), this.worker = worker, this.handleMessageEvent = (event)=>{
12
- const [port] = event.ports;
13
- if (!port) {
14
- return;
15
- }
16
- this.emit('new_socket', new MessagePortSocket(port));
17
- };
18
- }
19
- /**
20
- * Initializes the shared worker listener by assigning the 'handleMessageEvent' method as the event handler
21
- * for the 'onconnect' event of the SharedWorkerGlobalScope. The 'handleMessageEvent' function will be called
22
- * whenever a new connection is established with the shared worker.
23
- */ open() {
24
- this.worker.onconnect = this.handleMessageEvent;
25
- }
26
- /**
27
- * Closes the SharedWorkerListener by detaching the 'onconnect' event handler.
28
- * This stops the listener from emitting new sockets on incoming connections.
29
- */ close() {
30
- this.worker.onconnect = ()=>{};
31
- }
32
- handleMessageEvent;
33
- }
@@ -1,26 +0,0 @@
1
- import type { Connector } from '../interface/connector.js';
2
- import { MessagePortSocket } from './message_port_socket.js';
3
- /**
4
- * WorkerConnector is a class implementing the Connector interface for creating communication sockets
5
- * with Web Workers. It allows to establish a connection with the worker and create MessagePortSockets
6
- * using MessageChannels, enabling seamless communication between the main thread and worker threads.
7
- *
8
- * @example
9
- * const worker = new Worker('./myWorker.js');
10
- * const connector = new WorkerConnector(worker);
11
- * const socket = await connector.createSocket();
12
- * socket.send('Hello, worker!');
13
- */
14
- export declare class WorkerConnector implements Connector {
15
- private worker;
16
- constructor(worker: Worker);
17
- /**
18
- * Creates a new MessagePortSocket instance by establishing a connection between the Worker and the main thread.
19
- * A MessageChannel is created, and one of its ports is sent to the Worker using postMessage.
20
- * The other port is used to create a new MessagePortSocket which is then returned as a Promise.
21
- *
22
- * @returns A Promise that resolves to a new MessagePortSocket instance.
23
- */
24
- createSocket(): Promise<MessagePortSocket>;
25
- }
26
- //# sourceMappingURL=worker_connector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker_connector.d.ts","sourceRoot":"","sources":["../../../src/transport/browser/worker_connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,YAAW,SAAS;IACnC,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAElC;;;;;;OAMG;IACH,YAAY;CAKb"}
@@ -1,30 +0,0 @@
1
- import { MessagePortSocket } from './message_port_socket.js';
2
- /**
3
- * WorkerConnector is a class implementing the Connector interface for creating communication sockets
4
- * with Web Workers. It allows to establish a connection with the worker and create MessagePortSockets
5
- * using MessageChannels, enabling seamless communication between the main thread and worker threads.
6
- *
7
- * @example
8
- * const worker = new Worker('./myWorker.js');
9
- * const connector = new WorkerConnector(worker);
10
- * const socket = await connector.createSocket();
11
- * socket.send('Hello, worker!');
12
- */ export class WorkerConnector {
13
- worker;
14
- constructor(worker){
15
- this.worker = worker;
16
- }
17
- /**
18
- * Creates a new MessagePortSocket instance by establishing a connection between the Worker and the main thread.
19
- * A MessageChannel is created, and one of its ports is sent to the Worker using postMessage.
20
- * The other port is used to create a new MessagePortSocket which is then returned as a Promise.
21
- *
22
- * @returns A Promise that resolves to a new MessagePortSocket instance.
23
- */ createSocket() {
24
- const channel = new MessageChannel();
25
- this.worker.postMessage('', [
26
- channel.port2
27
- ]);
28
- return Promise.resolve(new MessagePortSocket(channel.port1));
29
- }
30
- }
@@ -1,39 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import EventEmitter from 'events';
3
- import type { Listener } from '../interface/listener.js';
4
- /**
5
- * Represents a DedicatedWorkerGlobalScope, which is the global execution context for a dedicated worker.
6
- * Provides properties and methods to manage the worker's lifecycle and communication with other threads or workers.
7
- */
8
- declare interface DedicatedWorkerGlobalScope {
9
- /**
10
- * Handler for incoming messages from other threads or workers.
11
- */
12
- onmessage: any;
13
- }
14
- /**
15
- * WorkerListener is a class that extends EventEmitter and implements the Listener interface.
16
- * It listens for incoming connections on a dedicated worker global scope, and emits a 'new_socket' event
17
- * with a MessagePortSocket instance for each new connection. This allows applications to communicate
18
- * with other workers or main thread through the MessagePortSocket abstraction.
19
- *
20
- * The open() method starts listening for incoming connections, while the close() method stops it.
21
- */
22
- export declare class WorkerListener extends EventEmitter implements Listener {
23
- private worker;
24
- constructor(worker: DedicatedWorkerGlobalScope);
25
- /**
26
- * Initializes the WorkerListener by setting the 'onmessage' event handler of the worker.
27
- * The 'onmessage' event will be triggered when the worker receives a message, and it will then
28
- * call the handleMessageEvent method to handle incoming connections.
29
- */
30
- open(): void;
31
- /**
32
- * Close the worker listener by removing the 'onmessage' event handler.
33
- * This method effectively stops the WorkerListener from reacting to new incoming messages.
34
- */
35
- close(): void;
36
- private handleMessageEvent;
37
- }
38
- export {};
39
- //# sourceMappingURL=worker_listener.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker_listener.d.ts","sourceRoot":"","sources":["../../../src/transport/browser/worker_listener.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD;;;GAGG;AACH,OAAO,WAAW,0BAA0B;IAC1C;;OAEG;IACH,SAAS,EAAE,GAAG,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,YAAa,YAAW,QAAQ;IACtD,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,0BAA0B;IAItD;;;;OAIG;IACH,IAAI;IAIJ;;;OAGG;IACH,KAAK;IAIL,OAAO,CAAC,kBAAkB,CAMxB;CACH"}
@@ -1,35 +0,0 @@
1
- import EventEmitter from 'events';
2
- import { MessagePortSocket } from './message_port_socket.js';
3
- /**
4
- * WorkerListener is a class that extends EventEmitter and implements the Listener interface.
5
- * It listens for incoming connections on a dedicated worker global scope, and emits a 'new_socket' event
6
- * with a MessagePortSocket instance for each new connection. This allows applications to communicate
7
- * with other workers or main thread through the MessagePortSocket abstraction.
8
- *
9
- * The open() method starts listening for incoming connections, while the close() method stops it.
10
- */ export class WorkerListener extends EventEmitter {
11
- worker;
12
- constructor(worker){
13
- super(), this.worker = worker, this.handleMessageEvent = (event)=>{
14
- const [port] = event.ports;
15
- if (!port) {
16
- return;
17
- }
18
- this.emit('new_socket', new MessagePortSocket(port));
19
- };
20
- }
21
- /**
22
- * Initializes the WorkerListener by setting the 'onmessage' event handler of the worker.
23
- * The 'onmessage' event will be triggered when the worker receives a message, and it will then
24
- * call the handleMessageEvent method to handle incoming connections.
25
- */ open() {
26
- this.worker.onmessage = this.handleMessageEvent;
27
- }
28
- /**
29
- * Close the worker listener by removing the 'onmessage' event handler.
30
- * This method effectively stops the WorkerListener from reacting to new incoming messages.
31
- */ close() {
32
- this.worker.onmessage = ()=>{};
33
- }
34
- handleMessageEvent;
35
- }
@@ -1,130 +0,0 @@
1
- /**
2
- * Dummy implementation of a necessary part of the wasi api:
3
- * https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md
4
- * We don't use these functions, but the environment expects them.
5
- * TODO find a way to update off of wasi 12.
6
- */
7
- export declare const getEmptyWasiSdk: (debug?: import("../log/log_fn.js").LogFn) => {
8
- /**
9
- * Retrieves the current time from the system clock.
10
- * This function is a dummy implementation of the WASI API's `clock_time_get` method,
11
- * which is expected by the environment but not used in this context.
12
- *
13
- * No input parameters or return values are required, as the purpose of this function
14
- * is solely to satisfy the environment expectations and provide debugging information.
15
- */
16
- clock_time_get(): void;
17
- /**
18
- * Dummy implementation of WASI's environ_get function.
19
- * This function is used to obtain a snapshot of the current environment variables.
20
- * In this dummy implementation, no actual actions are performed, but the debug logger logs 'environ_get' when called.
21
- * Environment variables are not used in this context, so the real implementation is not required.
22
- *
23
- * @see https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#environ_get
24
- */
25
- environ_get(): void;
26
- /**
27
- * Retrieves the environment variable sizes from the WebAssembly environment.
28
- * This function is part of the WASI API and provides a dummy implementation to fulfill the expected APIs.
29
- * It does not have any actual functionality, but serves as a placeholder in the environment.
30
- */
31
- environ_sizes_get(): void;
32
- /**
33
- * Closes a file descriptor, releasing any resources associated with it.
34
- * This function does not perform any actual closing operation, but exists to
35
- * satisfy the requirements of the WebAssembly System Interface (WASI) API,
36
- * which expects certain functions to be present for compatibility purposes.
37
- *
38
- * @see https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md
39
- */
40
- fd_close(): void;
41
- /**
42
- * A dummy implementation of the 'fd_read' function from the WASI API.
43
- * This function is required by the environment, but not used in this context.
44
- * It would normally read data from a file descriptor into an array buffer,
45
- * but here it simply logs the invocation for debugging purposes.
46
- */
47
- fd_read(): void;
48
- /**
49
- * Handles the file descriptor write operation.
50
- * This dummy implementation of the WASI 'fd_write' function is part of the wasi API:
51
- * https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md
52
- * The environment expects this function, but it is not used in the current implementation.
53
- * It is used to write data from WebAssembly memory to a file descriptor.
54
- */
55
- fd_write(): void;
56
- /**
57
- * Perform a file seek operation on the given file descriptor to change its current position.
58
- * The new position is calculated using the provided offset and whence values.
59
- * Throws an error if the file descriptor is invalid or the operation cannot be performed.
60
- *
61
- * @param fd - The file descriptor of the file to perform the seek operation on.
62
- * @param offset - The relative offset to apply, based on the whence value.
63
- * @param whence - The reference point from which the offset should be calculated. One of SEEK_SET (start), SEEK_CUR (current), or SEEK_END (end).
64
- * @returns The new position in the file after the seek operation has been performed.
65
- */
66
- fd_seek(): void;
67
- /**
68
- * This function is a dummy implementation of the 'fd_fdstat_get' function in the WebAssembly System Interface (WASI) API.
69
- * Although not actually used in this context, it is present due to the environment's expectation of its existence.
70
- * The 'fd_fdstat_get' function is typically responsible for obtaining file descriptor status information.
71
- */
72
- fd_fdstat_get(): void;
73
- /**
74
- * Sets the file descriptor flags for a given file descriptor.
75
- * This function is a dummy implementation of the WASI API function 'fd_fdstat_set_flags'.
76
- * It currently does not perform any operation but logs the function call with a debug instance.
77
- * This is provided since the environment expects this function to be present.
78
- */
79
- fd_fdstat_set_flags(): void;
80
- /**
81
- * Handles the `fd_prestat_get` function call for the dummy WebAssembly System Interface (WASI) implementation.
82
- * This function is expected by the WASI environment, although it is not used in this implementation.
83
- * The `fd_prestat_get` function retrieves pre-opened file descriptor properties.
84
- *
85
- * @returns A constant integer value indicating successful completion of the function call.
86
- */
87
- fd_prestat_get(): number;
88
- /**
89
- * Provides a dummy implementation for the `fd_prestat_dir_name` function, which is expected to be called by the WASI environment.
90
- * This function is intended to retrieve the pre-opened directory's path associated with the given file descriptor. However, since it's a dummy implementation,
91
- * it doesn't perform any actual operation and only logs the function call with the provided debug logger.
92
- *
93
- * @returns A constant number representing a dummy return value for the function call.
94
- */
95
- fd_prestat_dir_name(): number;
96
- /**
97
- * Handles the opening of a file path within the WASI environment.
98
- * This function is a dummy implementation required for compatibility with
99
- * the WebAssembly System Interface (WASI) API, but it does not perform any
100
- * actual file opening operation. It is mainly used for debugging purposes.
101
- */
102
- path_open(): void;
103
- /**
104
- * Retrieve file system information of the specified path.
105
- * This function retrieves statistics, such as size and permissions, associated with the file or directory
106
- * identified by the given path. In case of an error or non-existing path, appropriate debug logs will be generated.
107
- *
108
- * @returns An object containing file statistics like size, permissions, etc.
109
- */
110
- path_filestat_get(): void;
111
- /**
112
- * Terminate the process normally, performing the regular cleanup for terminating programs.
113
- * The input 'status' represents the exit code and is used to indicate success or failure
114
- * of the program execution. A zero value typically indicates successful execution,
115
- * while non-zero values are treated as errors by the operating system.
116
- *
117
- * @param status - The exit code representing the success or failure of the program execution.
118
- * @returns The exit status code.
119
- */
120
- proc_exit(): number;
121
- /**
122
- * Generates a random number and returns it.
123
- * This dummy implementation of 'random_get' method in the wasi API is expected by the environment.
124
- * In this case, the function always returns 1 to maintain consistency with the environment's expectations.
125
- *
126
- * @returns A random number. In this implementation, always returns 1.
127
- */
128
- random_get(): number;
129
- };
130
- //# sourceMappingURL=empty_wasi_sdk.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"empty_wasi_sdk.d.ts","sourceRoot":"","sources":["../../src/wasm/empty_wasi_sdk.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,eAAO,MAAM,eAAe;IAC1B;;;;;;;OAOG;;IAIH;;;;;;;OAOG;;IAIH;;;;OAIG;;IAIH;;;;;;;OAOG;;IAIH;;;;;OAKG;;IAIH;;;;;;OAMG;;IAIH;;;;;;;;;OASG;;IAIH;;;;OAIG;;IAIH;;;;;OAKG;;IAIH;;;;;;OAMG;;IAKH;;;;;;OAMG;;IAKH;;;;;OAKG;;IAIH;;;;;;OAMG;;IAIH;;;;;;;;OAQG;;IAKH;;;;;;OAMG;;CAKH,CAAC"}
@@ -1,148 +0,0 @@
1
- import { createDebugOnlyLogger } from '../log/index.js';
2
- /**
3
- * Dummy implementation of a necessary part of the wasi api:
4
- * https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md
5
- * We don't use these functions, but the environment expects them.
6
- * TODO find a way to update off of wasi 12.
7
- */ /* eslint-disable camelcase */ export const getEmptyWasiSdk = (debug = createDebugOnlyLogger('wasm:empty_wasi_sdk'))=>({
8
- /**
9
- * Retrieves the current time from the system clock.
10
- * This function is a dummy implementation of the WASI API's `clock_time_get` method,
11
- * which is expected by the environment but not used in this context.
12
- *
13
- * No input parameters or return values are required, as the purpose of this function
14
- * is solely to satisfy the environment expectations and provide debugging information.
15
- */ clock_time_get () {
16
- debug('clock_time_get');
17
- },
18
- /**
19
- * Dummy implementation of WASI's environ_get function.
20
- * This function is used to obtain a snapshot of the current environment variables.
21
- * In this dummy implementation, no actual actions are performed, but the debug logger logs 'environ_get' when called.
22
- * Environment variables are not used in this context, so the real implementation is not required.
23
- *
24
- * @see https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#environ_get
25
- */ environ_get () {
26
- debug('environ_get');
27
- },
28
- /**
29
- * Retrieves the environment variable sizes from the WebAssembly environment.
30
- * This function is part of the WASI API and provides a dummy implementation to fulfill the expected APIs.
31
- * It does not have any actual functionality, but serves as a placeholder in the environment.
32
- */ environ_sizes_get () {
33
- debug('environ_sizes_get');
34
- },
35
- /**
36
- * Closes a file descriptor, releasing any resources associated with it.
37
- * This function does not perform any actual closing operation, but exists to
38
- * satisfy the requirements of the WebAssembly System Interface (WASI) API,
39
- * which expects certain functions to be present for compatibility purposes.
40
- *
41
- * @see https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md
42
- */ fd_close () {
43
- debug('fd_close');
44
- },
45
- /**
46
- * A dummy implementation of the 'fd_read' function from the WASI API.
47
- * This function is required by the environment, but not used in this context.
48
- * It would normally read data from a file descriptor into an array buffer,
49
- * but here it simply logs the invocation for debugging purposes.
50
- */ fd_read () {
51
- debug('fd_read');
52
- },
53
- /**
54
- * Handles the file descriptor write operation.
55
- * This dummy implementation of the WASI 'fd_write' function is part of the wasi API:
56
- * https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md
57
- * The environment expects this function, but it is not used in the current implementation.
58
- * It is used to write data from WebAssembly memory to a file descriptor.
59
- */ fd_write () {
60
- debug('fd_write');
61
- },
62
- /**
63
- * Perform a file seek operation on the given file descriptor to change its current position.
64
- * The new position is calculated using the provided offset and whence values.
65
- * Throws an error if the file descriptor is invalid or the operation cannot be performed.
66
- *
67
- * @param fd - The file descriptor of the file to perform the seek operation on.
68
- * @param offset - The relative offset to apply, based on the whence value.
69
- * @param whence - The reference point from which the offset should be calculated. One of SEEK_SET (start), SEEK_CUR (current), or SEEK_END (end).
70
- * @returns The new position in the file after the seek operation has been performed.
71
- */ fd_seek () {
72
- debug('fd_seek');
73
- },
74
- /**
75
- * This function is a dummy implementation of the 'fd_fdstat_get' function in the WebAssembly System Interface (WASI) API.
76
- * Although not actually used in this context, it is present due to the environment's expectation of its existence.
77
- * The 'fd_fdstat_get' function is typically responsible for obtaining file descriptor status information.
78
- */ fd_fdstat_get () {
79
- debug('fd_fdstat_get');
80
- },
81
- /**
82
- * Sets the file descriptor flags for a given file descriptor.
83
- * This function is a dummy implementation of the WASI API function 'fd_fdstat_set_flags'.
84
- * It currently does not perform any operation but logs the function call with a debug instance.
85
- * This is provided since the environment expects this function to be present.
86
- */ fd_fdstat_set_flags () {
87
- debug('fd_fdstat_set_flags');
88
- },
89
- /**
90
- * Handles the `fd_prestat_get` function call for the dummy WebAssembly System Interface (WASI) implementation.
91
- * This function is expected by the WASI environment, although it is not used in this implementation.
92
- * The `fd_prestat_get` function retrieves pre-opened file descriptor properties.
93
- *
94
- * @returns A constant integer value indicating successful completion of the function call.
95
- */ fd_prestat_get () {
96
- debug('fd_prestat_get');
97
- return 8;
98
- },
99
- /**
100
- * Provides a dummy implementation for the `fd_prestat_dir_name` function, which is expected to be called by the WASI environment.
101
- * This function is intended to retrieve the pre-opened directory's path associated with the given file descriptor. However, since it's a dummy implementation,
102
- * it doesn't perform any actual operation and only logs the function call with the provided debug logger.
103
- *
104
- * @returns A constant number representing a dummy return value for the function call.
105
- */ fd_prestat_dir_name () {
106
- debug('fd_prestat_dir_name');
107
- return 28;
108
- },
109
- /**
110
- * Handles the opening of a file path within the WASI environment.
111
- * This function is a dummy implementation required for compatibility with
112
- * the WebAssembly System Interface (WASI) API, but it does not perform any
113
- * actual file opening operation. It is mainly used for debugging purposes.
114
- */ path_open () {
115
- debug('path_open');
116
- },
117
- /**
118
- * Retrieve file system information of the specified path.
119
- * This function retrieves statistics, such as size and permissions, associated with the file or directory
120
- * identified by the given path. In case of an error or non-existing path, appropriate debug logs will be generated.
121
- *
122
- * @returns An object containing file statistics like size, permissions, etc.
123
- */ path_filestat_get () {
124
- debug('path_filestat_get');
125
- },
126
- /**
127
- * Terminate the process normally, performing the regular cleanup for terminating programs.
128
- * The input 'status' represents the exit code and is used to indicate success or failure
129
- * of the program execution. A zero value typically indicates successful execution,
130
- * while non-zero values are treated as errors by the operating system.
131
- *
132
- * @param status - The exit code representing the success or failure of the program execution.
133
- * @returns The exit status code.
134
- */ proc_exit () {
135
- debug('proc_exit');
136
- return 52;
137
- },
138
- /**
139
- * Generates a random number and returns it.
140
- * This dummy implementation of 'random_get' method in the wasi API is expected by the environment.
141
- * In this case, the function always returns 1 to maintain consistency with the environment's expectations.
142
- *
143
- * @returns A random number. In this implementation, always returns 1.
144
- */ random_get () {
145
- debug('random_get');
146
- return 1;
147
- }
148
- });
@@ -1,2 +0,0 @@
1
- export { WasmModule, type IWasmModule } from './wasm_module.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wasm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1 +0,0 @@
1
- export { WasmModule } from './wasm_module.js';
@@ -1,136 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { Buffer } from 'buffer';
4
- import { type LogFn } from '../log/index.js';
5
- /**
6
- * The base shape of a WASM module providing low level memory and synchronous call access.
7
- * Note that the Aztec codebase used to support asyncify but has fully moved away,
8
- * using web workers if needed.
9
- */
10
- export interface IWasmModule {
11
- /**
12
- * Low level call function, returns result as number.
13
- * @param name - The function name.
14
- * @param args - The function args.
15
- * @returns The value as an integer (could be pointer).
16
- */
17
- call(name: string, ...args: any): number;
18
- /**
19
- * Get a slice of memory between two addresses.
20
- * @param start - The start address.
21
- * @param end - The end address.
22
- * @returns A Uint8Array view of memory.
23
- */
24
- getMemorySlice(start: number, end: number): Uint8Array;
25
- /**
26
- * Write data into the heap.
27
- * @param offset - The address to write data at.
28
- * @param arr - The data to write.
29
- */
30
- writeMemory(offset: number, arr: Uint8Array): void;
31
- }
32
- /**
33
- * WasmModule:
34
- * Helper over a webassembly module.
35
- * Assumes a few quirks.
36
- * 1) the module expects wasi_snapshot_preview1 with the methods from getEmptyWasiSdk
37
- * 2) of which the webassembly
38
- * we instantiate only uses random_get (update this if more WASI sdk methods are needed).
39
- */
40
- export declare class WasmModule implements IWasmModule {
41
- private module;
42
- private importFn;
43
- private memory;
44
- private heap;
45
- private instance?;
46
- private mutexQ;
47
- private debug;
48
- /**
49
- * Create a wasm module. Should be followed by await init();.
50
- * @param module - The module as a WebAssembly.Module or a Buffer.
51
- * @param importFn - Imports expected by the WASM.
52
- * @param loggerName - Optional, for debug logging.
53
- */
54
- constructor(module: WebAssembly.Module | Buffer, importFn: (module: WasmModule) => any, loggerName?: string);
55
- /**
56
- * Return the wasm source.
57
- * @returns The source.
58
- */
59
- getModule(): WebAssembly.Module | Buffer;
60
- /**
61
- * Initialize this wasm module.
62
- * @param wasmImportEnv - Linked to a module called "env". Functions implementations referenced from e.g. C++.
63
- * @param initial - 30 pages by default. 30*2**16 \> 1mb stack size plus other overheads.
64
- * @param initMethod - Defaults to calling '_initialize'.
65
- * @param maximum - 8192 maximum by default. 512mb.
66
- */
67
- init(initial?: number, maximum?: number, initMethod?: string | null): Promise<void>;
68
- /**
69
- * The methods or objects exported by the WASM module.
70
- * @returns An indexable object.
71
- */
72
- exports(): any;
73
- /**
74
- * Get the current logger.
75
- * @returns Logging function.
76
- */
77
- getLogger(): LogFn;
78
- /**
79
- * Add a logger.
80
- * @param logger - Function to call when logging.
81
- */
82
- addLogger(logger: LogFn): void;
83
- /**
84
- * Calls into the WebAssembly.
85
- * @param name - The method name.
86
- * @param args - The arguments to the method.
87
- * @returns The numeric method result.
88
- */
89
- call(name: string, ...args: any): number;
90
- /**
91
- * Get the memory used by the WASM module.
92
- * @returns A WebAssembly memory object.
93
- */
94
- getRawMemory(): WebAssembly.Memory;
95
- /**
96
- * Get the memory used by the WASM module, as a byte array.
97
- * @returns A Uint8Array view of the WASM module memory.
98
- */
99
- getMemory(): Uint8Array;
100
- /**
101
- * The memory size in bytes.
102
- * @returns Number of bytes.
103
- */
104
- memSize(): number;
105
- /**
106
- * Get a slice of memory between two addresses.
107
- * @param start - The start address.
108
- * @param end - The end address.
109
- * @returns A Uint8Array view of memory.
110
- */
111
- getMemorySlice(start: number, end: number): Uint8Array;
112
- /**
113
- * Write data into the heap.
114
- * @param offset - The address to write data at.
115
- * @param arr - The data to write.
116
- */
117
- writeMemory(offset: number, arr: Uint8Array): void;
118
- /**
119
- * Read WASM memory as a JS string.
120
- * @param addr - The memory address.
121
- * @returns A JS string.
122
- */
123
- getMemoryAsString(addr: number): string;
124
- /**
125
- * When calling the wasm, sometimes a caller will require exclusive access over a series of calls.
126
- * E.g. When a result is written to address 0, one cannot have another caller writing to the same address via
127
- * writeMemory before the result is read via sliceMemory.
128
- * Acquire() gets a single token from a fifo. The caller must call release() to add the token back.
129
- */
130
- acquire(): Promise<void>;
131
- /**
132
- * Release the mutex, letting another promise call acquire().
133
- */
134
- release(): void;
135
- }
136
- //# sourceMappingURL=wasm_module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wasm_module.d.ts","sourceRoot":"","sources":["../../src/wasm/wasm_module.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,KAAK,KAAK,EAAyB,MAAM,iBAAiB,CAAC;AAIpE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC;IAEzC;;;;;OAKG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEvD;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;CACpD;AAED;;;;;;;GAOG;AACH,qBAAa,UAAW,YAAW,WAAW;IAc1C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;IAdlB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAuB;IACxC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,KAAK,CAAQ;IAErB;;;;;OAKG;gBAEO,MAAM,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,EACnC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,GAAG,EAC7C,UAAU,SAAS;IAMrB;;;OAGG;IACI,SAAS,IAAI,WAAW,CAAC,MAAM,GAAG,MAAM;IAG/C;;;;;;OAMG;IACU,IAAI,CAAC,OAAO,SAAK,EAAE,OAAO,SAAO,EAAE,UAAU,GAAE,MAAM,GAAG,IAAoB;IA6CzF;;;OAGG;IACI,OAAO,IAAI,GAAG;IAOrB;;;OAGG;IACI,SAAS;IAIhB;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,KAAK;IAQ9B;;;;;OAKG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,MAAM;IAa/C;;;OAGG;IACI,YAAY,IAAI,WAAW,CAAC,MAAM;IAGzC;;;OAGG;IACI,SAAS,IAAI,UAAU;IAQ9B;;;OAGG;IACI,OAAO,IAAI,MAAM;IAIxB;;;;;OAKG;IACI,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAI7D;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU;IAOlD;;;;OAIG;IACI,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAUrC;;;;;OAKG;IACU,OAAO;IAIpB;;OAEG;IACI,OAAO;CAMf"}