zuzu-js 0.1.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.
- package/LICENSE +5 -0
- package/README.md +113 -0
- package/bin/zuzu +17 -0
- package/bin/zuzu-build-browser-bundle +57 -0
- package/bin/zuzu-generate-browser-stdlib +584 -0
- package/bin/zuzu-js +23 -0
- package/bin/zuzu-js-compile +152 -0
- package/bin/zuzu-js-electron +19 -0
- package/dist/zuzu-browser-worker.js +45574 -0
- package/dist/zuzu-browser.js +45362 -0
- package/lib/browser-bundle-entry.js +160 -0
- package/lib/browser-gui-renderer.js +387 -0
- package/lib/browser-runtime.js +167 -0
- package/lib/browser-worker-entry.js +413 -0
- package/lib/browser-ztests/runner.html +103 -0
- package/lib/browser-ztests/runner.js +369 -0
- package/lib/cli.js +350 -0
- package/lib/collections.js +367 -0
- package/lib/compiler.js +303 -0
- package/lib/electron/launcher.js +70 -0
- package/lib/electron/main.js +956 -0
- package/lib/electron/preload.js +80 -0
- package/lib/electron/renderer.html +122 -0
- package/lib/electron/renderer.js +24 -0
- package/lib/execution-metadata.js +18 -0
- package/lib/gui/dom-renderer.js +778 -0
- package/lib/host/browser-host.js +278 -0
- package/lib/host/capabilities.js +47 -0
- package/lib/host/electron-host.js +15 -0
- package/lib/host/node-host.js +74 -0
- package/lib/paths.js +150 -0
- package/lib/runtime-entrypoints.js +60 -0
- package/lib/runtime-helpers.js +886 -0
- package/lib/runtime.js +3529 -0
- package/lib/tap.js +37 -0
- package/lib/transpiler-new/ast.js +23 -0
- package/lib/transpiler-new/codegen.js +2455 -0
- package/lib/transpiler-new/errors.js +28 -0
- package/lib/transpiler-new/index.js +26 -0
- package/lib/transpiler-new/lexer.js +834 -0
- package/lib/transpiler-new/parser.js +2332 -0
- package/lib/transpiler-new/validate-bindings.js +326 -0
- package/lib/transpiler-utils.js +95 -0
- package/lib/transpiler.js +33 -0
- package/lib/zuzu.js +53 -0
- package/modules/javascript.js +193 -0
- package/modules/std/archive.js +603 -0
- package/modules/std/clib.js +338 -0
- package/modules/std/data/csv.js +1331 -0
- package/modules/std/data/json.js +531 -0
- package/modules/std/data/xml.js +441 -0
- package/modules/std/data/yaml.js +256 -0
- package/modules/std/db-worker.js +250 -0
- package/modules/std/db.js +664 -0
- package/modules/std/digest/_hash.js +443 -0
- package/modules/std/digest/md5.js +26 -0
- package/modules/std/digest/sha.js +72 -0
- package/modules/std/eval.js +10 -0
- package/modules/std/gui/objects.js +1519 -0
- package/modules/std/internals.js +571 -0
- package/modules/std/io/socks-worker.js +318 -0
- package/modules/std/io/socks.js +186 -0
- package/modules/std/io.js +475 -0
- package/modules/std/marshal/cbor.js +463 -0
- package/modules/std/marshal/graph.js +1624 -0
- package/modules/std/marshal.js +87 -0
- package/modules/std/math/bignum.js +91 -0
- package/modules/std/math.js +79 -0
- package/modules/std/net/dns.js +306 -0
- package/modules/std/net/http.js +820 -0
- package/modules/std/net/smtp.js +943 -0
- package/modules/std/net/url.js +109 -0
- package/modules/std/proc.js +602 -0
- package/modules/std/secure.js +3724 -0
- package/modules/std/string/base64.js +138 -0
- package/modules/std/string.js +299 -0
- package/modules/std/task.js +914 -0
- package/modules/std/time.js +579 -0
- package/modules/std/tui.js +188 -0
- package/modules/std/worker-thread.js +246 -0
- package/modules/std/worker.js +790 -0
- package/package.json +67 -0
- package/stdlib/modules/javascript.zzm +99 -0
- package/stdlib/modules/perl.zzm +105 -0
- package/stdlib/modules/std/archive.zzm +132 -0
- package/stdlib/modules/std/cache/lru.zzm +174 -0
- package/stdlib/modules/std/clib.zzm +112 -0
- package/stdlib/modules/std/colour.zzm +220 -0
- package/stdlib/modules/std/config.zzm +818 -0
- package/stdlib/modules/std/data/cbor.zzm +497 -0
- package/stdlib/modules/std/data/csv.zzm +285 -0
- package/stdlib/modules/std/data/ini.zzm +472 -0
- package/stdlib/modules/std/data/json/schema/core.zzm +573 -0
- package/stdlib/modules/std/data/json/schema/format.zzm +581 -0
- package/stdlib/modules/std/data/json/schema/model.zzm +255 -0
- package/stdlib/modules/std/data/json/schema/output.zzm +272 -0
- package/stdlib/modules/std/data/json/schema/relative_pointer.zzm +299 -0
- package/stdlib/modules/std/data/json/schema/validation.zzm +1503 -0
- package/stdlib/modules/std/data/json/schema.zzm +306 -0
- package/stdlib/modules/std/data/json.zzm +102 -0
- package/stdlib/modules/std/data/kdl/json.zzm +460 -0
- package/stdlib/modules/std/data/kdl/xml.zzm +387 -0
- package/stdlib/modules/std/data/kdl.zzm +1631 -0
- package/stdlib/modules/std/data/toml.zzm +756 -0
- package/stdlib/modules/std/data/toon.zzm +1017 -0
- package/stdlib/modules/std/data/xml/escape.zzm +156 -0
- package/stdlib/modules/std/data/xml.zzm +276 -0
- package/stdlib/modules/std/data/yaml.zzm +94 -0
- package/stdlib/modules/std/db.zzm +173 -0
- package/stdlib/modules/std/defer.zzm +75 -0
- package/stdlib/modules/std/digest/crc32.zzm +196 -0
- package/stdlib/modules/std/digest/md5.zzm +54 -0
- package/stdlib/modules/std/digest/sha.zzm +83 -0
- package/stdlib/modules/std/dump.zzm +317 -0
- package/stdlib/modules/std/eval.zzm +63 -0
- package/stdlib/modules/std/getopt.zzm +432 -0
- package/stdlib/modules/std/gui/dialogue.zzm +592 -0
- package/stdlib/modules/std/gui/objects.zzm +123 -0
- package/stdlib/modules/std/gui.zzm +1914 -0
- package/stdlib/modules/std/internals.zzm +139 -0
- package/stdlib/modules/std/io/socks.zzm +139 -0
- package/stdlib/modules/std/io.zzm +157 -0
- package/stdlib/modules/std/lingua/en.zzm +347 -0
- package/stdlib/modules/std/log.zzm +169 -0
- package/stdlib/modules/std/mail.zzm +2726 -0
- package/stdlib/modules/std/marshal.zzm +138 -0
- package/stdlib/modules/std/math/bignum.zzm +98 -0
- package/stdlib/modules/std/math/range.zzm +116 -0
- package/stdlib/modules/std/math/roman.zzm +156 -0
- package/stdlib/modules/std/math.zzm +141 -0
- package/stdlib/modules/std/net/dns.zzm +93 -0
- package/stdlib/modules/std/net/http.zzm +278 -0
- package/stdlib/modules/std/net/smtp.zzm +257 -0
- package/stdlib/modules/std/net/url.zzm +69 -0
- package/stdlib/modules/std/path/jsonpointer.zzm +526 -0
- package/stdlib/modules/std/path/kdl.zzm +1003 -0
- package/stdlib/modules/std/path/simple.zzm +520 -0
- package/stdlib/modules/std/path/z/context.zzm +147 -0
- package/stdlib/modules/std/path/z/evaluate.zzm +549 -0
- package/stdlib/modules/std/path/z/functions.zzm +874 -0
- package/stdlib/modules/std/path/z/lexer.zzm +490 -0
- package/stdlib/modules/std/path/z/node.zzm +1455 -0
- package/stdlib/modules/std/path/z/operators.zzm +445 -0
- package/stdlib/modules/std/path/z/parser.zzm +359 -0
- package/stdlib/modules/std/path/z.zzm +403 -0
- package/stdlib/modules/std/path/zz/functions.zzm +828 -0
- package/stdlib/modules/std/path/zz/operators.zzm +1036 -0
- package/stdlib/modules/std/path/zz.zzm +100 -0
- package/stdlib/modules/std/proc.zzm +155 -0
- package/stdlib/modules/std/result.zzm +149 -0
- package/stdlib/modules/std/secure.zzm +606 -0
- package/stdlib/modules/std/string/base64.zzm +66 -0
- package/stdlib/modules/std/string/quoted_printable.zzm +485 -0
- package/stdlib/modules/std/string.zzm +179 -0
- package/stdlib/modules/std/task.zzm +221 -0
- package/stdlib/modules/std/template/z.zzm +531 -0
- package/stdlib/modules/std/template/zz.zzm +62 -0
- package/stdlib/modules/std/time.zzm +188 -0
- package/stdlib/modules/std/tui.zzm +89 -0
- package/stdlib/modules/std/uuid.zzm +223 -0
- package/stdlib/modules/std/web/session.zzm +388 -0
- package/stdlib/modules/std/web/static.zzm +329 -0
- package/stdlib/modules/std/web.zzm +1942 -0
- package/stdlib/modules/std/worker.zzm +202 -0
- package/stdlib/modules/std/zuzuzoo.zzm +3960 -0
- package/stdlib/modules/test/more.zzm +528 -0
- package/stdlib/modules/test/parser.zzm +209 -0
|
@@ -0,0 +1,914 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
let AsyncLocalStorage = null;
|
|
4
|
+
try {
|
|
5
|
+
AsyncLocalStorage = require( 'node:async_hooks' ).AsyncLocalStorage;
|
|
6
|
+
}
|
|
7
|
+
catch ( _err ) {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class Exception extends Error {
|
|
11
|
+
constructor( message = '' ) {
|
|
12
|
+
super( String( message ?? '' ) );
|
|
13
|
+
this.name = 'Exception';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
to_String() {
|
|
17
|
+
const name = this.name || this.constructor.name || 'Exception';
|
|
18
|
+
const message = String( this.message ?? '' );
|
|
19
|
+
if ( message === name || message.startsWith( `${name}:` ) ) {
|
|
20
|
+
return message;
|
|
21
|
+
}
|
|
22
|
+
return message === '' ? name : `${name}: ${message}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class CancelledException extends Exception {
|
|
27
|
+
constructor( message = 'Task cancelled' ) {
|
|
28
|
+
super( message );
|
|
29
|
+
this.name = 'CancelledException';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class TimeoutException extends Exception {
|
|
34
|
+
constructor( message = 'timeout' ) {
|
|
35
|
+
super( message );
|
|
36
|
+
this.name = 'TimeoutException';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class ChannelClosedException extends Exception {
|
|
41
|
+
constructor( message = 'send on closed channel' ) {
|
|
42
|
+
super( message );
|
|
43
|
+
this.name = 'ChannelClosedException';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let taskStorage = AsyncLocalStorage ? new AsyncLocalStorage() : null;
|
|
48
|
+
let fallbackCurrentTask = null;
|
|
49
|
+
let debugLevel = 0;
|
|
50
|
+
let nextTaskId = 1;
|
|
51
|
+
const activeTasks = new Map();
|
|
52
|
+
const traceEvents = [];
|
|
53
|
+
const callsiteStack = [];
|
|
54
|
+
|
|
55
|
+
function globalTimerRoot() {
|
|
56
|
+
if ( typeof globalThis !== 'undefined' ) {
|
|
57
|
+
return globalThis;
|
|
58
|
+
}
|
|
59
|
+
if ( typeof global !== 'undefined' ) {
|
|
60
|
+
return global;
|
|
61
|
+
}
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function safeSetTimeout( callback, delay ) {
|
|
66
|
+
const root = globalTimerRoot();
|
|
67
|
+
return root.setTimeout.call( root, callback, delay );
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function safeClearTimeout( timer ) {
|
|
71
|
+
const root = globalTimerRoot();
|
|
72
|
+
return root.clearTimeout.call( root, timer );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function safeQueueMicrotask( callback ) {
|
|
76
|
+
const root = globalTimerRoot();
|
|
77
|
+
if ( typeof root.queueMicrotask === 'function' ) {
|
|
78
|
+
return root.queueMicrotask.call( root, callback );
|
|
79
|
+
}
|
|
80
|
+
return safeSetTimeout( callback, 0 );
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function currentTask() {
|
|
84
|
+
return taskStorage ? taskStorage.getStore() : fallbackCurrentTask;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function runWithTask( task, fn ) {
|
|
88
|
+
if ( taskStorage ) {
|
|
89
|
+
return taskStorage.run( task, fn );
|
|
90
|
+
}
|
|
91
|
+
const previous = fallbackCurrentTask;
|
|
92
|
+
fallbackCurrentTask = task;
|
|
93
|
+
try {
|
|
94
|
+
return fn();
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
fallbackCurrentTask = previous;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function normalizeException( value, ExceptionClass = Exception ) {
|
|
102
|
+
if ( value instanceof Error ) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
return new ExceptionClass( value == null ? '' : String( value ) );
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function currentCallsite() {
|
|
109
|
+
return callsiteStack.length > 0
|
|
110
|
+
? callsiteStack[callsiteStack.length - 1]
|
|
111
|
+
: null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function withCallsite( metadata, fn ) {
|
|
115
|
+
callsiteStack.push( metadata || null );
|
|
116
|
+
try {
|
|
117
|
+
return fn();
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
callsiteStack.pop();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function traceTask( event, task = null, extra = null ) {
|
|
125
|
+
if ( debugLevel <= 0 ) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const record = {
|
|
129
|
+
event,
|
|
130
|
+
task_id: task ? task._id : null,
|
|
131
|
+
parent_task_id: task ? task._parentId : null,
|
|
132
|
+
name: task ? task._name : null,
|
|
133
|
+
status: task ? task._status : null,
|
|
134
|
+
file: task ? task._file : null,
|
|
135
|
+
line: task ? task._line : null,
|
|
136
|
+
};
|
|
137
|
+
if ( extra && typeof extra === 'object' ) {
|
|
138
|
+
Object.assign( record, extra );
|
|
139
|
+
}
|
|
140
|
+
traceEvents.push( record );
|
|
141
|
+
return record;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function cleanupTask( task ) {
|
|
145
|
+
if ( !task || !task.done() ) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
activeTasks.delete( task._id );
|
|
149
|
+
traceTask( 'cleanup', task );
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
class Task {
|
|
153
|
+
constructor( executor = null, options = {} ) {
|
|
154
|
+
const parent = currentTask();
|
|
155
|
+
const callsite = currentCallsite();
|
|
156
|
+
this._id = nextTaskId++;
|
|
157
|
+
this._parentId = options.parentTaskId != null
|
|
158
|
+
? options.parentTaskId
|
|
159
|
+
: ( parent ? parent._id : null );
|
|
160
|
+
this._name = options.name || '<task>';
|
|
161
|
+
this._file = options.file || ( callsite ? callsite.file : null ) || null;
|
|
162
|
+
this._line = options.line || ( callsite ? callsite.line : null ) || null;
|
|
163
|
+
this._status = options.status || 'pending';
|
|
164
|
+
this._value = undefined;
|
|
165
|
+
this._reason = null;
|
|
166
|
+
this._children = new Set();
|
|
167
|
+
this._cancelHook = typeof options.cancel === 'function' ? options.cancel : null;
|
|
168
|
+
this._pollHook = typeof options.poll === 'function' ? options.poll : null;
|
|
169
|
+
activeTasks.set( this._id, this );
|
|
170
|
+
traceTask( 'schedule', this );
|
|
171
|
+
this._promise = new Promise( (resolve, reject) => {
|
|
172
|
+
this._resolve = (value) => {
|
|
173
|
+
if ( this.done() ) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this._status = 'fulfilled';
|
|
177
|
+
this._value = value;
|
|
178
|
+
traceTask( 'fulfill', this );
|
|
179
|
+
resolve( value );
|
|
180
|
+
cleanupTask( this );
|
|
181
|
+
};
|
|
182
|
+
this._reject = (err, forcedStatus = null) => {
|
|
183
|
+
if ( this.done() ) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this._status = forcedStatus
|
|
187
|
+
|| ( err instanceof CancelledException ? 'cancelled' : 'rejected' );
|
|
188
|
+
this._reason = err;
|
|
189
|
+
traceTask( this._status === 'cancelled' ? 'cancel' : 'reject', this );
|
|
190
|
+
reject( err );
|
|
191
|
+
cleanupTask( this );
|
|
192
|
+
};
|
|
193
|
+
} );
|
|
194
|
+
this._promise.catch( () => {} );
|
|
195
|
+
if ( executor ) {
|
|
196
|
+
safeQueueMicrotask( () => {
|
|
197
|
+
if ( this.done() ) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
this._status = options.status || 'running';
|
|
201
|
+
traceTask( 'start', this );
|
|
202
|
+
runWithTask( this, async () => {
|
|
203
|
+
try {
|
|
204
|
+
this._resolve( await executor() );
|
|
205
|
+
}
|
|
206
|
+
catch ( err ) {
|
|
207
|
+
this._reject( err );
|
|
208
|
+
}
|
|
209
|
+
} );
|
|
210
|
+
} );
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
static resolved( value = null ) {
|
|
215
|
+
const task = new Task();
|
|
216
|
+
task._resolve( value );
|
|
217
|
+
return task;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
static failed( value ) {
|
|
221
|
+
const task = new Task();
|
|
222
|
+
task._reject( normalizeException( value ) );
|
|
223
|
+
return task;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
static from( value ) {
|
|
227
|
+
if ( value instanceof Task ) {
|
|
228
|
+
return value;
|
|
229
|
+
}
|
|
230
|
+
if ( value && typeof value.then === 'function' ) {
|
|
231
|
+
const task = new Task();
|
|
232
|
+
Promise.resolve( value ).then(
|
|
233
|
+
(result) => task._resolve( result ),
|
|
234
|
+
(err) => task._reject( err ),
|
|
235
|
+
);
|
|
236
|
+
return task;
|
|
237
|
+
}
|
|
238
|
+
return Task.resolved( value );
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
then( resolve, reject ) {
|
|
242
|
+
return this._promise.then( resolve, reject );
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
catch( reject ) {
|
|
246
|
+
return this._promise.catch( reject );
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
finally( callback ) {
|
|
250
|
+
return this._promise.finally( callback );
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
status() {
|
|
254
|
+
return this._status;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
id() {
|
|
258
|
+
return this._id;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
parent_id() {
|
|
262
|
+
return this._parentId;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
name() {
|
|
266
|
+
return this._name;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
is_done() {
|
|
270
|
+
return this.done();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
done() {
|
|
274
|
+
return [ 'fulfilled', 'rejected', 'cancelled' ].includes( this._status ) ? 1 : 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
poll() {
|
|
278
|
+
if ( !this.done() && this._pollHook ) {
|
|
279
|
+
try {
|
|
280
|
+
this._pollHook();
|
|
281
|
+
}
|
|
282
|
+
catch ( err ) {
|
|
283
|
+
this._reject( err );
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return this.done();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
to_String() {
|
|
290
|
+
return `[Task ${this._status}]`;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
cancel( reason = null ) {
|
|
294
|
+
if ( this.done() ) {
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
const err = normalizeException(
|
|
298
|
+
reason == null ? 'Task cancelled' : reason,
|
|
299
|
+
CancelledException,
|
|
300
|
+
);
|
|
301
|
+
this._reason = err;
|
|
302
|
+
for ( const child of this._children ) {
|
|
303
|
+
if ( child && typeof child.cancel === 'function' ) {
|
|
304
|
+
child.cancel( err );
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if ( this._cancelHook ) {
|
|
308
|
+
try {
|
|
309
|
+
this._cancelHook( err );
|
|
310
|
+
}
|
|
311
|
+
catch ( _err ) {
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
this._reject( err, 'cancelled' );
|
|
315
|
+
return this;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
_track( child ) {
|
|
319
|
+
if ( child instanceof Task ) {
|
|
320
|
+
this._children.add( child );
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
_untrack( child ) {
|
|
325
|
+
if ( child instanceof Task ) {
|
|
326
|
+
this._children.delete( child );
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
Object.defineProperty( Task.prototype, '__zuzu_type_name', {
|
|
332
|
+
value: 'Task',
|
|
333
|
+
enumerable: false,
|
|
334
|
+
configurable: true,
|
|
335
|
+
writable: true,
|
|
336
|
+
} );
|
|
337
|
+
|
|
338
|
+
async function awaitValueWithParent( value, parent ) {
|
|
339
|
+
if ( parent && parent.status() === 'cancelled' ) {
|
|
340
|
+
throw parent._reason || new CancelledException();
|
|
341
|
+
}
|
|
342
|
+
const task = Task.from( value );
|
|
343
|
+
if ( parent ) {
|
|
344
|
+
parent._track( task );
|
|
345
|
+
}
|
|
346
|
+
try {
|
|
347
|
+
return await task;
|
|
348
|
+
}
|
|
349
|
+
finally {
|
|
350
|
+
if ( parent ) {
|
|
351
|
+
parent._untrack( task );
|
|
352
|
+
if ( parent.status() === 'cancelled' ) {
|
|
353
|
+
throw parent._reason || new CancelledException();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
async function awaitValue( value ) {
|
|
360
|
+
return awaitValueWithParent( value, currentTask() );
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
async function awaitBlock( value ) {
|
|
364
|
+
const parent = currentTask();
|
|
365
|
+
const boxedValue = value && typeof value.then === 'function'
|
|
366
|
+
? await value
|
|
367
|
+
: value;
|
|
368
|
+
const resolvedValue = boxedValue
|
|
369
|
+
&& typeof boxedValue === 'object'
|
|
370
|
+
&& Object.prototype.hasOwnProperty.call( boxedValue, '__zuzu_await_block_value' )
|
|
371
|
+
? boxedValue.__zuzu_await_block_value
|
|
372
|
+
: boxedValue;
|
|
373
|
+
if ( !( resolvedValue instanceof Task ) ) {
|
|
374
|
+
throw new Exception( 'await block must return a Task' );
|
|
375
|
+
}
|
|
376
|
+
return awaitValueWithParent( resolvedValue, parent );
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function awaitValueSync( value ) {
|
|
380
|
+
const task = Task.from( value );
|
|
381
|
+
if ( task.status() === 'fulfilled' ) {
|
|
382
|
+
return task._value;
|
|
383
|
+
}
|
|
384
|
+
if ( task.status() === 'rejected' || task.status() === 'cancelled' ) {
|
|
385
|
+
throw task._reason || new Exception( 'Task failed' );
|
|
386
|
+
}
|
|
387
|
+
throw new Exception( 'cannot synchronously await pending task' );
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function awaitBlockSync( value ) {
|
|
391
|
+
const resolvedValue = value
|
|
392
|
+
&& typeof value === 'object'
|
|
393
|
+
&& Object.prototype.hasOwnProperty.call( value, '__zuzu_await_block_value' )
|
|
394
|
+
? value.__zuzu_await_block_value
|
|
395
|
+
: value;
|
|
396
|
+
if ( !( resolvedValue instanceof Task ) ) {
|
|
397
|
+
throw new Exception( 'await block must return a Task' );
|
|
398
|
+
}
|
|
399
|
+
return awaitValueSync( resolvedValue );
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function task( fn, _metadata = {} ) {
|
|
403
|
+
const callsite = currentCallsite();
|
|
404
|
+
return new Task( async () => fn(), {
|
|
405
|
+
name: _metadata.name || '<async>',
|
|
406
|
+
file: ( callsite ? callsite.file : null ) || _metadata.file || null,
|
|
407
|
+
line: ( callsite ? callsite.line : null ) || _metadata.line || null,
|
|
408
|
+
} );
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function taskSync( fn, _metadata = {} ) {
|
|
412
|
+
const callsite = currentCallsite();
|
|
413
|
+
const task = new Task( null, {
|
|
414
|
+
name: _metadata.name || '<async>',
|
|
415
|
+
file: ( callsite ? callsite.file : null ) || _metadata.file || null,
|
|
416
|
+
line: ( callsite ? callsite.line : null ) || _metadata.line || null,
|
|
417
|
+
} );
|
|
418
|
+
task._status = 'running';
|
|
419
|
+
traceTask( 'start', task );
|
|
420
|
+
try {
|
|
421
|
+
const value = runWithTask( task, () => fn() );
|
|
422
|
+
if ( value instanceof Task ) {
|
|
423
|
+
if ( value.status() === 'fulfilled' ) {
|
|
424
|
+
task._resolve( value._value );
|
|
425
|
+
}
|
|
426
|
+
else if ( value.status() === 'rejected' || value.status() === 'cancelled' ) {
|
|
427
|
+
task._reject( value._reason || new Exception( 'Task failed' ) );
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
task._reject( new Exception( 'cannot synchronously await pending task' ) );
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
else if ( value && typeof value.then === 'function' ) {
|
|
434
|
+
Task.from( value ).then(
|
|
435
|
+
(result) => task._resolve( result ),
|
|
436
|
+
(err) => task._reject( err ),
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
task._resolve( value );
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
catch ( err ) {
|
|
444
|
+
task._reject( err );
|
|
445
|
+
}
|
|
446
|
+
return task;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function spawn( fn, _metadata = {} ) {
|
|
450
|
+
return new Task( async () => fn(), {
|
|
451
|
+
status: 'running',
|
|
452
|
+
name: _metadata.name || '<spawn>',
|
|
453
|
+
file: _metadata.file || ( currentCallsite() ? currentCallsite().file : null ) || null,
|
|
454
|
+
line: _metadata.line || ( currentCallsite() ? currentCallsite().line : null ) || null,
|
|
455
|
+
} );
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function resolved( value = null ) {
|
|
459
|
+
return Task.resolved( value );
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function failed( value ) {
|
|
463
|
+
return Task.failed( value == null ? 'Task failed' : value );
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function sleep( seconds = 0 ) {
|
|
467
|
+
let timer = null;
|
|
468
|
+
const readyAt = Date.now() + Math.max( 0, Number( seconds ) || 0 ) * 1000;
|
|
469
|
+
const task = new Task( null, {
|
|
470
|
+
status: 'sleeping',
|
|
471
|
+
name: 'sleep',
|
|
472
|
+
poll() {
|
|
473
|
+
if ( Date.now() >= readyAt ) {
|
|
474
|
+
if ( timer != null ) {
|
|
475
|
+
safeClearTimeout( timer );
|
|
476
|
+
timer = null;
|
|
477
|
+
}
|
|
478
|
+
task._resolve( null );
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
cancel() {
|
|
482
|
+
if ( timer != null ) {
|
|
483
|
+
safeClearTimeout( timer );
|
|
484
|
+
timer = null;
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
} );
|
|
488
|
+
timer = safeSetTimeout( () => {
|
|
489
|
+
timer = null;
|
|
490
|
+
task._resolve( null );
|
|
491
|
+
}, Math.max( 0, Number( seconds ) || 0 ) * 1000 );
|
|
492
|
+
return task;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function yieldTask() {
|
|
496
|
+
let timer = null;
|
|
497
|
+
const task = new Task( null, {
|
|
498
|
+
status: 'waiting',
|
|
499
|
+
name: 'yield',
|
|
500
|
+
cancel() {
|
|
501
|
+
if ( timer != null ) {
|
|
502
|
+
safeClearTimeout( timer );
|
|
503
|
+
timer = null;
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
} );
|
|
507
|
+
timer = safeSetTimeout( () => {
|
|
508
|
+
timer = null;
|
|
509
|
+
task._resolve( null );
|
|
510
|
+
}, 0 );
|
|
511
|
+
return task;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function all( values = [] ) {
|
|
515
|
+
const tasks = taskItems( values, 'all' );
|
|
516
|
+
return new Task(
|
|
517
|
+
() => new Promise( (resolve, reject) => {
|
|
518
|
+
if ( tasks.length === 0 ) {
|
|
519
|
+
resolve( [] );
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
const results = new Array( tasks.length );
|
|
523
|
+
let remaining = tasks.length;
|
|
524
|
+
let settled = false;
|
|
525
|
+
tasks.forEach( (task, index) => {
|
|
526
|
+
task.then(
|
|
527
|
+
(value) => {
|
|
528
|
+
if ( settled ) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
results[index] = value;
|
|
532
|
+
remaining--;
|
|
533
|
+
if ( remaining === 0 ) {
|
|
534
|
+
settled = true;
|
|
535
|
+
resolve( results );
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
(err) => {
|
|
539
|
+
if ( settled ) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
settled = true;
|
|
543
|
+
for ( const child of tasks ) {
|
|
544
|
+
if ( child !== task ) {
|
|
545
|
+
child.cancel();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
reject( err );
|
|
549
|
+
},
|
|
550
|
+
);
|
|
551
|
+
} );
|
|
552
|
+
} ),
|
|
553
|
+
{
|
|
554
|
+
status: 'waiting',
|
|
555
|
+
name: 'all',
|
|
556
|
+
cancel(reason) {
|
|
557
|
+
for ( const task of tasks ) {
|
|
558
|
+
task.cancel( reason );
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function race( values = [] ) {
|
|
566
|
+
const tasks = taskItems( values, 'race' );
|
|
567
|
+
if ( tasks.length === 0 ) {
|
|
568
|
+
return Task.failed( new Exception( 'race expects at least one task' ) );
|
|
569
|
+
}
|
|
570
|
+
return new Task(
|
|
571
|
+
() => new Promise( (resolve, reject) => {
|
|
572
|
+
let settled = false;
|
|
573
|
+
for ( const task of tasks ) {
|
|
574
|
+
task.then(
|
|
575
|
+
(value) => {
|
|
576
|
+
if ( settled ) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
settled = true;
|
|
580
|
+
for ( const loser of tasks ) {
|
|
581
|
+
if ( loser !== task ) {
|
|
582
|
+
loser.cancel( new CancelledException( 'race loser cancelled' ) );
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
resolve( value );
|
|
586
|
+
},
|
|
587
|
+
(err) => {
|
|
588
|
+
if ( settled ) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
settled = true;
|
|
592
|
+
for ( const loser of tasks ) {
|
|
593
|
+
if ( loser !== task ) {
|
|
594
|
+
loser.cancel( new CancelledException( 'race loser cancelled' ) );
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
reject( err );
|
|
598
|
+
},
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
} ),
|
|
602
|
+
{
|
|
603
|
+
status: 'waiting',
|
|
604
|
+
name: 'race',
|
|
605
|
+
cancel(reason) {
|
|
606
|
+
for ( const task of tasks ) {
|
|
607
|
+
task.cancel( reason );
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function timeout( seconds, value ) {
|
|
615
|
+
if ( !( value instanceof Task ) ) {
|
|
616
|
+
throw new Exception( 'timeout expects a Task' );
|
|
617
|
+
}
|
|
618
|
+
const waited = value;
|
|
619
|
+
const timeoutError = () => new TimeoutException( `timeout after ${Number( seconds ) || 0}s` );
|
|
620
|
+
let settled = false;
|
|
621
|
+
let timer = null;
|
|
622
|
+
return new Task(
|
|
623
|
+
() => new Promise( (resolve, reject) => {
|
|
624
|
+
timer = safeSetTimeout( () => {
|
|
625
|
+
if ( settled ) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
settled = true;
|
|
629
|
+
const err = timeoutError();
|
|
630
|
+
waited.cancel( err );
|
|
631
|
+
reject( err );
|
|
632
|
+
}, Math.max( 0, Number( seconds ) || 0 ) * 1000 );
|
|
633
|
+
waited.then(
|
|
634
|
+
(result) => {
|
|
635
|
+
if ( settled ) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
settled = true;
|
|
639
|
+
if ( timer != null ) {
|
|
640
|
+
safeClearTimeout( timer );
|
|
641
|
+
timer = null;
|
|
642
|
+
}
|
|
643
|
+
resolve( result );
|
|
644
|
+
},
|
|
645
|
+
(err) => {
|
|
646
|
+
if ( settled ) {
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
settled = true;
|
|
650
|
+
if ( timer != null ) {
|
|
651
|
+
safeClearTimeout( timer );
|
|
652
|
+
timer = null;
|
|
653
|
+
}
|
|
654
|
+
reject( err );
|
|
655
|
+
},
|
|
656
|
+
);
|
|
657
|
+
} ),
|
|
658
|
+
{
|
|
659
|
+
status: 'waiting',
|
|
660
|
+
name: 'timeout',
|
|
661
|
+
cancel(reason) {
|
|
662
|
+
settled = true;
|
|
663
|
+
if ( timer != null ) {
|
|
664
|
+
safeClearTimeout( timer );
|
|
665
|
+
timer = null;
|
|
666
|
+
}
|
|
667
|
+
waited.cancel( reason );
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
class Channel {
|
|
674
|
+
constructor() {
|
|
675
|
+
this._closed = false;
|
|
676
|
+
this._queue = [];
|
|
677
|
+
this._receivers = [];
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
send( value = null ) {
|
|
681
|
+
if ( this._closed ) {
|
|
682
|
+
return Task.failed( new ChannelClosedException() );
|
|
683
|
+
}
|
|
684
|
+
const receiver = this._receivers.shift();
|
|
685
|
+
if ( receiver ) {
|
|
686
|
+
receiver._resolve( value );
|
|
687
|
+
}
|
|
688
|
+
else {
|
|
689
|
+
this._queue.push( value );
|
|
690
|
+
}
|
|
691
|
+
return Task.resolved( value );
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
recv() {
|
|
695
|
+
if ( this._queue.length > 0 ) {
|
|
696
|
+
return Task.resolved( this._queue.shift() );
|
|
697
|
+
}
|
|
698
|
+
if ( this._closed ) {
|
|
699
|
+
return Task.resolved( null );
|
|
700
|
+
}
|
|
701
|
+
const task = new Task( null, {
|
|
702
|
+
status: 'waiting',
|
|
703
|
+
name: 'channel.recv',
|
|
704
|
+
cancel: () => {
|
|
705
|
+
this._receivers = this._receivers.filter( (item) => item !== task );
|
|
706
|
+
},
|
|
707
|
+
} );
|
|
708
|
+
this._receivers.push( task );
|
|
709
|
+
return task;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
close() {
|
|
713
|
+
this._closed = true;
|
|
714
|
+
while ( this._receivers.length > 0 ) {
|
|
715
|
+
this._receivers.shift()._resolve( null );
|
|
716
|
+
}
|
|
717
|
+
return null;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
class CancellationToken {
|
|
722
|
+
constructor() {
|
|
723
|
+
this._cancelled = false;
|
|
724
|
+
this._reason = null;
|
|
725
|
+
this._tasks = new Set();
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
cancelled() {
|
|
729
|
+
return this._cancelled ? 1 : 0;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
reason() {
|
|
733
|
+
return this._reason;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
throw_if_cancelled() {
|
|
737
|
+
if ( this._cancelled ) {
|
|
738
|
+
throw this._reason || new CancelledException();
|
|
739
|
+
}
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
watch( task ) {
|
|
744
|
+
if ( !( task instanceof Task ) ) {
|
|
745
|
+
throw new Exception( 'CancellationToken.watch expects a Task' );
|
|
746
|
+
}
|
|
747
|
+
if ( this._cancelled ) {
|
|
748
|
+
task.cancel( this._reason );
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
this._tasks.add( task );
|
|
752
|
+
}
|
|
753
|
+
return task;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
class CancellationSource {
|
|
758
|
+
constructor() {
|
|
759
|
+
this._token = new CancellationToken();
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
token() {
|
|
763
|
+
return this._token;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
cancel( reason = null ) {
|
|
767
|
+
if ( this._token._cancelled ) {
|
|
768
|
+
return this;
|
|
769
|
+
}
|
|
770
|
+
this._token._cancelled = true;
|
|
771
|
+
this._token._reason = normalizeException(
|
|
772
|
+
reason == null ? 'Task cancelled' : reason,
|
|
773
|
+
CancelledException,
|
|
774
|
+
);
|
|
775
|
+
for ( const task of this._token._tasks ) {
|
|
776
|
+
task.cancel( this._token._reason );
|
|
777
|
+
}
|
|
778
|
+
this._token._tasks.clear();
|
|
779
|
+
return this;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
cancelled() {
|
|
783
|
+
return this._token.cancelled();
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
reason() {
|
|
787
|
+
return this._token.reason();
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
function setDebugLevel( level = 0 ) {
|
|
792
|
+
debugLevel = Number( level ) || 0;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function clearTrace() {
|
|
796
|
+
traceEvents.length = 0;
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function taskTrace() {
|
|
801
|
+
return traceEvents.map( (record) => ( { ...record } ) );
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function activeCount() {
|
|
805
|
+
for ( const task of [ ...activeTasks.values() ] ) {
|
|
806
|
+
cleanupTask( task );
|
|
807
|
+
}
|
|
808
|
+
return activeTasks.size;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
function traceBlockingOperation( operation, metadata = {} ) {
|
|
812
|
+
const task = currentTask();
|
|
813
|
+
if ( !task || debugLevel <= 0 ) {
|
|
814
|
+
return null;
|
|
815
|
+
}
|
|
816
|
+
return traceTask( 'blocked_operation', task, {
|
|
817
|
+
operation: String( operation ?? '' ),
|
|
818
|
+
...metadata,
|
|
819
|
+
} );
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function shutdown( reason = null ) {
|
|
823
|
+
for ( const task of [ ...activeTasks.values() ] ) {
|
|
824
|
+
if ( !task.done() ) {
|
|
825
|
+
task.cancel( reason == null ? 'Task cancelled' : reason );
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
traceTask( 'shutdown', null );
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function resetForRun( level = 0 ) {
|
|
833
|
+
const previousDebugLevel = debugLevel;
|
|
834
|
+
debugLevel = 0;
|
|
835
|
+
shutdown( 'Task cancelled' );
|
|
836
|
+
debugLevel = Number( level ) || 0;
|
|
837
|
+
traceEvents.length = 0;
|
|
838
|
+
nextTaskId = 1;
|
|
839
|
+
fallbackCurrentTask = null;
|
|
840
|
+
callsiteStack.length = 0;
|
|
841
|
+
return previousDebugLevel;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function withoutAsyncLocalStorageForTesting( fn ) {
|
|
845
|
+
const previous = taskStorage;
|
|
846
|
+
taskStorage = null;
|
|
847
|
+
try {
|
|
848
|
+
const result = fn();
|
|
849
|
+
if ( result && typeof result.then === 'function' ) {
|
|
850
|
+
return Promise.resolve( result ).finally( () => {
|
|
851
|
+
taskStorage = previous;
|
|
852
|
+
fallbackCurrentTask = null;
|
|
853
|
+
} );
|
|
854
|
+
}
|
|
855
|
+
taskStorage = previous;
|
|
856
|
+
fallbackCurrentTask = null;
|
|
857
|
+
return result;
|
|
858
|
+
}
|
|
859
|
+
catch ( err ) {
|
|
860
|
+
taskStorage = previous;
|
|
861
|
+
fallbackCurrentTask = null;
|
|
862
|
+
throw err;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function taskItems( values, label ) {
|
|
867
|
+
if ( !Array.isArray( values ) ) {
|
|
868
|
+
throw new Exception( 'TypeException: task combinator expects Array' );
|
|
869
|
+
}
|
|
870
|
+
const out = [];
|
|
871
|
+
for ( const value of values ) {
|
|
872
|
+
if ( !( value instanceof Task ) ) {
|
|
873
|
+
throw new Exception( `${label} expects only Task values` );
|
|
874
|
+
}
|
|
875
|
+
out.push( value );
|
|
876
|
+
}
|
|
877
|
+
return out;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
module.exports = {
|
|
881
|
+
Task,
|
|
882
|
+
Exception,
|
|
883
|
+
CancelledException,
|
|
884
|
+
TimeoutException,
|
|
885
|
+
ChannelClosedException,
|
|
886
|
+
Channel,
|
|
887
|
+
CancellationToken,
|
|
888
|
+
CancellationSource,
|
|
889
|
+
awaitValue,
|
|
890
|
+
awaitBlock,
|
|
891
|
+
awaitValueSync,
|
|
892
|
+
awaitBlockSync,
|
|
893
|
+
withCallsite,
|
|
894
|
+
runWithTask,
|
|
895
|
+
currentTask,
|
|
896
|
+
setDebugLevel,
|
|
897
|
+
clearTrace,
|
|
898
|
+
taskTrace,
|
|
899
|
+
activeCount,
|
|
900
|
+
traceBlockingOperation,
|
|
901
|
+
shutdown,
|
|
902
|
+
resetForRun,
|
|
903
|
+
withoutAsyncLocalStorageForTesting,
|
|
904
|
+
task,
|
|
905
|
+
taskSync,
|
|
906
|
+
spawn,
|
|
907
|
+
resolved,
|
|
908
|
+
failed,
|
|
909
|
+
sleep,
|
|
910
|
+
yield: yieldTask,
|
|
911
|
+
all,
|
|
912
|
+
race,
|
|
913
|
+
timeout,
|
|
914
|
+
};
|