@aztec/foundation 5.0.0-nightly.20260701 → 5.0.0-nightly.20260702
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.
|
@@ -7,7 +7,7 @@ export declare function makeLoggingErrorHandler(logger: Logger, ...ignoredErrors
|
|
|
7
7
|
* at a specified polling interval. It allows starting, stopping, and checking the status of the
|
|
8
8
|
* internally managed promise. The class also supports interrupting the polling process when stopped.
|
|
9
9
|
*/
|
|
10
|
-
export declare class RunningPromise {
|
|
10
|
+
export declare class RunningPromise<T = void> {
|
|
11
11
|
private fn;
|
|
12
12
|
private logger;
|
|
13
13
|
private pollingIntervalMS;
|
|
@@ -16,8 +16,9 @@ export declare class RunningPromise {
|
|
|
16
16
|
private runningPromise;
|
|
17
17
|
private interruptibleSleep;
|
|
18
18
|
private requested;
|
|
19
|
+
private requestedArg;
|
|
19
20
|
static readonly EXIT: typeof EXIT;
|
|
20
|
-
constructor(fn: () => void | Promise<void>, logger?: Logger, pollingIntervalMS?: number, handleError?: ErrorHandler);
|
|
21
|
+
constructor(fn: (arg?: T) => void | Promise<void>, logger?: Logger, pollingIntervalMS?: number, handleError?: ErrorHandler);
|
|
21
22
|
/**
|
|
22
23
|
* Starts the running promise.
|
|
23
24
|
*/
|
|
@@ -36,7 +37,7 @@ export declare class RunningPromise {
|
|
|
36
37
|
* Triggers an immediate run of the function, bypassing the polling interval.
|
|
37
38
|
* If the function is currently running, it will be allowed to continue and then called again immediately.
|
|
38
39
|
*/
|
|
39
|
-
trigger(): Promise<void>;
|
|
40
|
+
trigger(arg?: T): Promise<void>;
|
|
40
41
|
/**
|
|
41
42
|
* Updates the polling interval. The new interval will take effect after the next poll.
|
|
42
43
|
* @param pollingIntervalMS The polling interval in milliseconds.
|
|
@@ -44,4 +45,4 @@ export declare class RunningPromise {
|
|
|
44
45
|
setPollingIntervalMS(pollingIntervalMS: number): void;
|
|
45
46
|
}
|
|
46
47
|
export {};
|
|
47
|
-
//#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T0FBTyxJQUFJLENBQVE7SUFFaEQsWUFDVSxFQUFFLEVBQUUsQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEtBQUssSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsRUFDckMsTUFBTSxTQUFrQyxFQUN4QyxpQkFBaUIsU0FBUSxFQUN6QixXQUFXLEdBQUUsWUFBOEMsRUFDakU7SUFFSjs7T0FFRztJQUNJLEtBQUssU0FtQ1g7SUFFRDs7O09BR0c7SUFDRyxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQU8xQjtJQUVEOzs7T0FHRztJQUNJLFNBQVMsWUFFZjtJQUVEOzs7T0FHRztJQUNVLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWEzQztJQUVEOzs7T0FHRztJQUNILG9CQUFvQixDQUFDLGlCQUFpQixFQUFFLE1BQU0sUUFFN0M7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"running-promise.d.ts","sourceRoot":"","sources":["../../src/promise/running-promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,QAAA,MAAM,IAAI,eAAoC,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,IAAI,CAAC,CAAC;AAE9F,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,GAAG,aAAa,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,EAAE,GAClD,YAAY,CAMd;AAED;;;;GAIG;AACH,qBAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"running-promise.d.ts","sourceRoot":"","sources":["../../src/promise/running-promise.ts"],"names":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 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
22
22
|
runningPromise;
|
|
23
23
|
interruptibleSleep;
|
|
24
24
|
requested;
|
|
25
|
+
requestedArg;
|
|
25
26
|
static EXIT = EXIT;
|
|
26
27
|
constructor(fn, logger = createLogger('running-promise'), pollingIntervalMS = 10000, handleError = makeLoggingErrorHandler(logger)){
|
|
27
28
|
this.fn = fn;
|
|
@@ -32,6 +33,7 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
32
33
|
this.runningPromise = Promise.resolve();
|
|
33
34
|
this.interruptibleSleep = new InterruptibleSleep();
|
|
34
35
|
this.requested = undefined;
|
|
36
|
+
this.requestedArg = undefined;
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Starts the running promise.
|
|
@@ -45,7 +47,7 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
45
47
|
while(this.running){
|
|
46
48
|
const hasRequested = this.requested !== undefined;
|
|
47
49
|
try {
|
|
48
|
-
await this.fn();
|
|
50
|
+
await this.fn(this.requestedArg);
|
|
49
51
|
} catch (err) {
|
|
50
52
|
const code = await this.handleError(err);
|
|
51
53
|
if (code === RunningPromise.EXIT) {
|
|
@@ -59,6 +61,7 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
59
61
|
if (hasRequested) {
|
|
60
62
|
this.requested.resolve();
|
|
61
63
|
this.requested = undefined;
|
|
64
|
+
this.requestedArg = undefined;
|
|
62
65
|
}
|
|
63
66
|
// If no immediate run was requested, sleep for the polling interval.
|
|
64
67
|
if (this.requested === undefined && this.running) {
|
|
@@ -89,14 +92,15 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
89
92
|
/**
|
|
90
93
|
* Triggers an immediate run of the function, bypassing the polling interval.
|
|
91
94
|
* If the function is currently running, it will be allowed to continue and then called again immediately.
|
|
92
|
-
*/ async trigger() {
|
|
95
|
+
*/ async trigger(arg) {
|
|
93
96
|
if (!this.running) {
|
|
94
|
-
return this.fn();
|
|
97
|
+
return this.fn(arg);
|
|
95
98
|
}
|
|
96
99
|
let requested = this.requested;
|
|
97
100
|
if (!requested) {
|
|
98
101
|
requested = promiseWithResolvers();
|
|
99
102
|
this.requested = requested;
|
|
103
|
+
this.requestedArg = arg;
|
|
100
104
|
this.interruptibleSleep.interrupt();
|
|
101
105
|
}
|
|
102
106
|
await requested.promise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/foundation",
|
|
3
|
-
"version": "5.0.0-nightly.
|
|
3
|
+
"version": "5.0.0-nightly.20260702",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dest/index.js",
|
|
6
6
|
"types": "./dest/index.d.ts",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"testEnvironment": "../../foundation/src/jest/env.mjs"
|
|
147
147
|
},
|
|
148
148
|
"dependencies": {
|
|
149
|
-
"@aztec/bb.js": "5.0.0-nightly.
|
|
149
|
+
"@aztec/bb.js": "5.0.0-nightly.20260702",
|
|
150
150
|
"@koa/cors": "^5.0.0",
|
|
151
151
|
"@noble/curves": "=1.7.0",
|
|
152
152
|
"@noble/hashes": "^1.6.1",
|
|
@@ -22,16 +22,17 @@ export function makeLoggingErrorHandler(
|
|
|
22
22
|
* at a specified polling interval. It allows starting, stopping, and checking the status of the
|
|
23
23
|
* internally managed promise. The class also supports interrupting the polling process when stopped.
|
|
24
24
|
*/
|
|
25
|
-
export class RunningPromise {
|
|
25
|
+
export class RunningPromise<T = void> {
|
|
26
26
|
private running = false;
|
|
27
27
|
private runningPromise = Promise.resolve();
|
|
28
28
|
private interruptibleSleep = new InterruptibleSleep();
|
|
29
29
|
private requested: PromiseWithResolvers<void> | undefined = undefined;
|
|
30
|
+
private requestedArg: T | undefined = undefined;
|
|
30
31
|
|
|
31
32
|
public static readonly EXIT: typeof EXIT = EXIT;
|
|
32
33
|
|
|
33
34
|
constructor(
|
|
34
|
-
private fn: () => void | Promise<void>,
|
|
35
|
+
private fn: (arg?: T) => void | Promise<void>,
|
|
35
36
|
private logger = createLogger('running-promise'),
|
|
36
37
|
private pollingIntervalMS = 10000,
|
|
37
38
|
private handleError: ErrorHandler = makeLoggingErrorHandler(logger),
|
|
@@ -51,7 +52,7 @@ export class RunningPromise {
|
|
|
51
52
|
while (this.running) {
|
|
52
53
|
const hasRequested = this.requested !== undefined;
|
|
53
54
|
try {
|
|
54
|
-
await this.fn();
|
|
55
|
+
await this.fn(this.requestedArg);
|
|
55
56
|
} catch (err) {
|
|
56
57
|
const code = await this.handleError(err);
|
|
57
58
|
if (code === RunningPromise.EXIT) {
|
|
@@ -64,6 +65,7 @@ export class RunningPromise {
|
|
|
64
65
|
if (hasRequested) {
|
|
65
66
|
this.requested!.resolve();
|
|
66
67
|
this.requested = undefined;
|
|
68
|
+
this.requestedArg = undefined;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
// If no immediate run was requested, sleep for the polling interval.
|
|
@@ -101,15 +103,16 @@ export class RunningPromise {
|
|
|
101
103
|
* Triggers an immediate run of the function, bypassing the polling interval.
|
|
102
104
|
* If the function is currently running, it will be allowed to continue and then called again immediately.
|
|
103
105
|
*/
|
|
104
|
-
public async trigger() {
|
|
106
|
+
public async trigger(arg?: T): Promise<void> {
|
|
105
107
|
if (!this.running) {
|
|
106
|
-
return this.fn();
|
|
108
|
+
return this.fn(arg);
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
let requested = this.requested;
|
|
110
112
|
if (!requested) {
|
|
111
113
|
requested = promiseWithResolvers<void>();
|
|
112
114
|
this.requested = requested;
|
|
115
|
+
this.requestedArg = arg;
|
|
113
116
|
this.interruptibleSleep.interrupt();
|
|
114
117
|
}
|
|
115
118
|
await requested!.promise;
|