async-browser-context 0.2.4 → 0.3.1
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/CHANGELOG.md +94 -0
- package/README.md +45 -30
- package/dist/babel/async-generator-helpers.d.ts +6 -6
- package/dist/babel/async-generator-helpers.d.ts.map +1 -1
- package/dist/babel/async-generator-helpers.js +33 -22
- package/dist/babel/async-generator-helpers.js.map +1 -1
- package/dist/babel/async-generator-resources.d.ts +14 -0
- package/dist/babel/async-generator-resources.d.ts.map +1 -0
- package/dist/babel/async-generator-resources.js +38 -0
- package/dist/babel/async-generator-resources.js.map +1 -0
- package/dist/babel/bind-generators.d.ts +1 -1
- package/dist/babel/bind-generators.d.ts.map +1 -1
- package/dist/babel/bind-generators.js +88 -44
- package/dist/babel/bind-generators.js.map +1 -1
- package/dist/babel/name-coroutines.d.ts +14 -8
- package/dist/babel/name-coroutines.d.ts.map +1 -1
- package/dist/babel/name-coroutines.js +160 -39
- package/dist/babel/name-coroutines.js.map +1 -1
- package/dist/babel/preset.d.ts +24 -13
- package/dist/babel/preset.d.ts.map +1 -1
- package/dist/babel/preset.js +37 -9
- package/dist/babel/preset.js.map +1 -1
- package/dist/babel/runtime-calls.d.ts +22 -0
- package/dist/babel/runtime-calls.d.ts.map +1 -0
- package/dist/babel/runtime-calls.js +69 -0
- package/dist/babel/runtime-calls.js.map +1 -0
- package/dist/babel/skip-runtime.d.ts +18 -11
- package/dist/babel/skip-runtime.d.ts.map +1 -1
- package/dist/babel/skip-runtime.js +52 -16
- package/dist/babel/skip-runtime.js.map +1 -1
- package/dist/babel/static-members.d.ts +4 -0
- package/dist/babel/static-members.d.ts.map +1 -0
- package/dist/babel/static-members.js +112 -0
- package/dist/babel/static-members.js.map +1 -0
- package/dist/core/async-generator.d.ts +26 -8
- package/dist/core/async-generator.d.ts.map +1 -1
- package/dist/core/async-generator.js +162 -44
- package/dist/core/async-generator.js.map +1 -1
- package/dist/core/async-local-storage.d.ts +3 -0
- package/dist/core/async-local-storage.d.ts.map +1 -1
- package/dist/core/async-local-storage.js +3 -0
- package/dist/core/async-local-storage.js.map +1 -1
- package/dist/core/callback-hook.d.ts +3 -3
- package/dist/core/coroutine.d.ts +6 -2
- package/dist/core/coroutine.d.ts.map +1 -1
- package/dist/core/coroutine.js +35 -21
- package/dist/core/coroutine.js.map +1 -1
- package/dist/core/function-name.d.ts +9 -0
- package/dist/core/function-name.d.ts.map +1 -0
- package/dist/core/function-name.js +12 -0
- package/dist/core/function-name.js.map +1 -0
- package/dist/core/hooks.d.ts +2 -1
- package/dist/core/hooks.d.ts.map +1 -1
- package/dist/core/hooks.js +21 -6
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/snapshot.d.ts +2 -1
- package/dist/core/snapshot.d.ts.map +1 -1
- package/dist/core/snapshot.js +7 -3
- package/dist/core/snapshot.js.map +1 -1
- package/dist/core/store.d.ts +28 -0
- package/dist/core/store.d.ts.map +1 -1
- package/dist/core/store.js +90 -20
- package/dist/core/store.js.map +1 -1
- package/dist/core/variable.d.ts +2 -1
- package/dist/core/variable.d.ts.map +1 -1
- package/dist/core/variable.js +5 -2
- package/dist/core/variable.js.map +1 -1
- package/dist/node/index.d.ts +10 -4
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +51 -16
- package/dist/node/index.js.map +1 -1
- package/dist/node/runtime.d.ts +7 -6
- package/dist/node/runtime.d.ts.map +1 -1
- package/dist/node/runtime.js +29 -16
- package/dist/node/runtime.js.map +1 -1
- package/dist/opentelemetry/context-manager.d.ts.map +1 -1
- package/dist/opentelemetry/context-manager.js +172 -13
- package/dist/opentelemetry/context-manager.js.map +1 -1
- package/dist/patches/callbacks.d.ts.map +1 -1
- package/dist/patches/callbacks.js +84 -29
- package/dist/patches/callbacks.js.map +1 -1
- package/dist/patches/events.d.ts.map +1 -1
- package/dist/patches/events.js +203 -91
- package/dist/patches/events.js.map +1 -1
- package/dist/patches/handler-interfaces.d.ts +4 -3
- package/dist/patches/handler-interfaces.d.ts.map +1 -1
- package/dist/patches/handler-interfaces.js +7 -5
- package/dist/patches/handler-interfaces.js.map +1 -1
- package/dist/patches/promise.d.ts +3 -0
- package/dist/patches/promise.d.ts.map +1 -1
- package/dist/patches/promise.js +13 -5
- package/dist/patches/promise.js.map +1 -1
- package/dist/patches/streams.d.ts.map +1 -1
- package/dist/patches/streams.js +36 -16
- package/dist/patches/streams.js.map +1 -1
- package/dist/patches/timers.d.ts.map +1 -1
- package/dist/patches/timers.js +17 -5
- package/dist/patches/timers.js.map +1 -1
- package/dist/patches/to-string.d.ts +4 -0
- package/dist/patches/to-string.d.ts.map +1 -1
- package/dist/patches/to-string.js +12 -6
- package/dist/patches/to-string.js.map +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +3 -3
- package/dist/runtime.js.map +1 -1
- package/dist/vite/plugin.d.ts +7 -2
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/plugin.js +30 -6
- package/dist/vite/plugin.js.map +1 -1
- package/package.json +52 -25
- package/src/babel/async-generator-helpers.ts +34 -23
- package/src/babel/async-generator-resources.ts +40 -0
- package/src/babel/bind-generators.ts +91 -47
- package/src/babel/name-coroutines.ts +170 -41
- package/src/babel/preset.ts +47 -15
- package/src/babel/runtime-calls.ts +73 -0
- package/src/babel/skip-runtime.ts +58 -18
- package/src/babel/static-members.ts +117 -0
- package/src/core/async-generator.ts +169 -46
- package/src/core/async-local-storage.ts +3 -0
- package/src/core/callback-hook.ts +3 -3
- package/src/core/coroutine.ts +35 -21
- package/src/core/function-name.ts +11 -0
- package/src/core/hooks.ts +23 -6
- package/src/core/snapshot.ts +8 -3
- package/src/core/store.ts +107 -21
- package/src/core/variable.ts +6 -2
- package/src/node/index.ts +62 -19
- package/src/node/runtime.ts +33 -15
- package/src/opentelemetry/context-manager.ts +188 -13
- package/src/patches/callbacks.ts +87 -30
- package/src/patches/events.ts +249 -103
- package/src/patches/handler-interfaces.ts +7 -5
- package/src/patches/promise.ts +17 -13
- package/src/patches/streams.ts +36 -16
- package/src/patches/timers.ts +17 -5
- package/src/patches/to-string.ts +12 -6
- package/src/runtime.ts +3 -3
- package/src/vite/plugin.ts +38 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-name.js","sourceRoot":"","sources":["../../src/core/function-name.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAa,EAAE,IAAyB,EAAE,MAAe;IACvF,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAG,IAAI,IAAI,EAAE,EAAE,YAAY,EAAG,IAAI,EAAE,CAAC,CAAC;IAC/E,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAG,MAAM,EAAE,YAAY,EAAG,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"}
|
package/dist/core/hooks.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export type { CallbackHook } from "./callback-hook.js";
|
|
|
9
9
|
* A tool can use the hook to measure the time of each callback, with the
|
|
10
10
|
* name of the callback and the values of its context. An error in a hook goes
|
|
11
11
|
* to `reportError()`, and the callback operates as usual. A callback that
|
|
12
|
-
* starts synchronously in a hook does not start the hook methods.
|
|
12
|
+
* starts synchronously in a hook does not start the hook methods. A callback
|
|
13
|
+
* that a hook schedules does not start them either, also later.
|
|
13
14
|
*/
|
|
14
15
|
export declare function addCallbackHook(hook: CallbackHook): () => void;
|
|
15
16
|
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/core/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/core/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG3E,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/core/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG3E,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAqBvD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAG,YAAY,GAAI,MAAM,IAAI,CAUhE"}
|
package/dist/core/hooks.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { assertCallbackHook } from "./callback-hook.js";
|
|
2
2
|
import { store } from "./store.js";
|
|
3
|
+
let warned = false;
|
|
4
|
+
/**
|
|
5
|
+
* Version 0.1 of the library has no callback hooks. If a copy of version 0.1 installed some
|
|
6
|
+
* patches first, the callbacks of those patches do not start the hooks. The function tells
|
|
7
|
+
* this one time on the console. The patches of version 0.2 start the hooks, and the patch of
|
|
8
|
+
* `Function.prototype.toString` has no callbacks.
|
|
9
|
+
*/
|
|
10
|
+
function warnAboutOldPatches() {
|
|
11
|
+
if (warned) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const without = [...(store.oldCopyPatches ?? [])].filter((name) => name !== "Function.prototype.toString");
|
|
15
|
+
if (without.length > 0) {
|
|
16
|
+
warned = true;
|
|
17
|
+
console.warn(`async-browser-context: an older copy of the library installed these patches, and their callbacks do not start the callback hooks: ${without.join(", ")}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
3
20
|
/**
|
|
4
21
|
* This function adds a hook. The library starts its methods before and after each
|
|
5
22
|
* callback that it starts. These callbacks are the callbacks of the patched
|
|
@@ -9,18 +26,16 @@ import { store } from "./store.js";
|
|
|
9
26
|
* A tool can use the hook to measure the time of each callback, with the
|
|
10
27
|
* name of the callback and the values of its context. An error in a hook goes
|
|
11
28
|
* to `reportError()`, and the callback operates as usual. A callback that
|
|
12
|
-
* starts synchronously in a hook does not start the hook methods.
|
|
29
|
+
* starts synchronously in a hook does not start the hook methods. A callback
|
|
30
|
+
* that a hook schedules does not start them either, also later.
|
|
13
31
|
*/
|
|
14
32
|
export function addCallbackHook(hook) {
|
|
15
33
|
assertCallbackHook(hook);
|
|
34
|
+
warnAboutOldPatches();
|
|
16
35
|
const entry = { hook };
|
|
17
36
|
store.hooks = [...(store.hooks ?? []), entry];
|
|
18
|
-
|
|
37
|
+
// A second removal finds no entry, and the list stays the same
|
|
19
38
|
return function removeCallbackHook() {
|
|
20
|
-
if (removed) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
removed = true;
|
|
24
39
|
const remaining = (store.hooks ?? []).filter((other) => other !== entry);
|
|
25
40
|
store.hooks = remaining.length === 0 ? undefined : remaining;
|
|
26
41
|
};
|
package/dist/core/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/core/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAkB,MAAM,YAAY,CAAC;AAInD
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/core/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAkB,MAAM,YAAY,CAAC;AAInD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB;;;;;GAKG;AACH,SAAS,mBAAmB;IACxB,IAAI,MAAM,EAAE,CAAC;QACT,OAAO;IACX,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,6BAA6B,CAAC,CAAC;IAC3G,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,GAAG,IAAI,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,qIAAqI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5K,CAAC;AACL,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,IAAmB;IAC/C,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACzB,mBAAmB,EAAE,CAAC;IACtB,MAAM,KAAK,GAAe,EAAE,IAAI,EAAE,CAAC;IACnC,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9C,+DAA+D;IAC/D,OAAO,SAAS,kBAAkB;QAC9B,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QACzE,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC,CAAC;AACN,CAAC"}
|
package/dist/core/snapshot.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export declare class Snapshot {
|
|
|
16
16
|
/**
|
|
17
17
|
* This method records the current context and gives a wrapper of `fn`. The
|
|
18
18
|
* wrapper starts `fn` in the recorded context, with the `this` value and the arguments of
|
|
19
|
-
* each call.
|
|
19
|
+
* each call. The name of the wrapper is "wrapped" and the name of `fn`, and its length is
|
|
20
|
+
* the length of `fn`.
|
|
20
21
|
*/
|
|
21
22
|
static wrap<T, A extends unknown[], R>(fn: (this: T, ...args: A) => R): (this: T, ...args: A) => R;
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/core/snapshot.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,qBAAa,QAAQ;;IAGjB;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,EAAE,EAAE,EAAG,CAAC,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,GAAI,CAAC;IAUrE
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/core/snapshot.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,qBAAa,QAAQ;;IAGjB;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,EAAE,EAAE,EAAG,CAAC,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,GAAI,CAAC;IAUrE;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,EAAG,CAAC,IAAI,EAAG,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC,GAAI,CAAC,IAAI,EAAG,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC;CAoB3G"}
|
package/dist/core/snapshot.js
CHANGED
|
@@ -26,7 +26,8 @@ export class Snapshot {
|
|
|
26
26
|
/**
|
|
27
27
|
* This method records the current context and gives a wrapper of `fn`. The
|
|
28
28
|
* wrapper starts `fn` in the recorded context, with the `this` value and the arguments of
|
|
29
|
-
* each call.
|
|
29
|
+
* each call. The name of the wrapper is "wrapped" and the name of `fn`, and its length is
|
|
30
|
+
* the length of `fn`.
|
|
30
31
|
*/
|
|
31
32
|
static wrap(fn) {
|
|
32
33
|
if (typeof fn !== "function") {
|
|
@@ -37,15 +38,18 @@ export class Snapshot {
|
|
|
37
38
|
const previous = store.current;
|
|
38
39
|
store.current = frame;
|
|
39
40
|
try {
|
|
40
|
-
return
|
|
41
|
+
return Reflect.apply(fn, this, args);
|
|
41
42
|
}
|
|
42
43
|
finally {
|
|
43
44
|
store.current = previous;
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
// As CopyNameAndLength with the prefix "wrapped" in the TC39 draft
|
|
48
|
+
const name = fn.name;
|
|
49
|
+
Object.defineProperty(wrapped, "name", { value: `wrapped ${typeof name === "string" ? name : ""}`, configurable: true });
|
|
47
50
|
Object.defineProperty(wrapped, "length", { value: fn.length, configurable: true });
|
|
48
51
|
return wrapped;
|
|
49
52
|
}
|
|
50
53
|
}
|
|
54
|
+
Object.defineProperty(Snapshot.prototype, Symbol.toStringTag, { value: "AsyncContext.Snapshot", configurable: true });
|
|
51
55
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/core/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,YAAY,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IACR,MAAM,GAAW,KAAK,CAAC,OAAO,CAAC;IAExC;;;OAGG;IACH,GAAG,CAAyB,EAAuB,EAAE,GAAG,IAAQ;QAC5D,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;QAC/B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC;YACD,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACvB,CAAC;gBAAS,CAAC;YACP,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC7B,CAAC;IACL,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/core/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,YAAY,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IACR,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AK,EAAG,EAAE,CAAC,MAAM,EAAE,YAAY,EAAG,IAAI,EAAE,CAAC,CAAC;QACrF,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,EAAG,uBAAuB,EAAE,YAAY,EAAG,IAAI,EAAE,CAAC,CAAC"}
|
package/dist/core/store.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export interface Frame {
|
|
|
17
17
|
/** The native functions that the runtime uses. The store records them before a patch replaces them. */
|
|
18
18
|
export interface Intrinsics {
|
|
19
19
|
readonly Promise: PromiseConstructor;
|
|
20
|
+
/** The patch of version 0.3 does not use it. An older copy of the library that shares the store can use it. */
|
|
20
21
|
readonly promiseThen: typeof Promise.prototype.then;
|
|
21
22
|
readonly promiseResolve: <T>(value: T) => Promise<Awaited<T>>;
|
|
23
|
+
/** The patch of version 0.3 does not use it. An older copy of the library that shares the store can use it. */
|
|
22
24
|
readonly functionToString: () => string;
|
|
23
25
|
}
|
|
24
26
|
export interface ContextStore {
|
|
@@ -39,6 +41,18 @@ export interface ContextStore {
|
|
|
39
41
|
hooks?: readonly HookEntry[] | undefined;
|
|
40
42
|
/** `true` while a hook operates. Callbacks that start in a hook do not start the hook methods. */
|
|
41
43
|
inHook?: boolean | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The patches that a copy of version 0.1 installed before a newer copy loaded. Version 0.1
|
|
46
|
+
* has no callback hooks, so the callbacks of these patches do not start the hooks. Only a
|
|
47
|
+
* store that a copy of version 0.1 made has this property.
|
|
48
|
+
*/
|
|
49
|
+
oldCopyPatches?: ReadonlySet<string> | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The frame that stays current between tasks: the root frame, or the frame of a top-level
|
|
52
|
+
* `enterWith()` (a default store). The event patch handles it as the root frame (rule C13).
|
|
53
|
+
* The store of an older copy of the library does not have this property.
|
|
54
|
+
*/
|
|
55
|
+
idle?: Frame | undefined;
|
|
42
56
|
}
|
|
43
57
|
/** The methods of a callback hook. The public type is `CallbackHook` in `hooks.ts`. */
|
|
44
58
|
export interface HookMethods {
|
|
@@ -51,6 +65,13 @@ export interface HookEntry {
|
|
|
51
65
|
}
|
|
52
66
|
/** The store of this global object. */
|
|
53
67
|
export declare const store: ContextStore;
|
|
68
|
+
/**
|
|
69
|
+
* This function records `store.idle` in the next microtask. `enterWith()` starts it, because a
|
|
70
|
+
* top-level `enterWith()` changes the frame that stays current between tasks. A microtask
|
|
71
|
+
* operates when the stack is empty, after each wrapper set its previous frame again. The callback
|
|
72
|
+
* goes to the native `then`, so no wrapper sets a frame for it.
|
|
73
|
+
*/
|
|
74
|
+
export declare function recordIdleFrame(): void;
|
|
54
75
|
/** This function makes `frame` the current frame. It gives the frame that was current before. */
|
|
55
76
|
export declare function enter(frame: Frame): Frame;
|
|
56
77
|
/** The result of `findValue` when no frame sets the variable. */
|
|
@@ -66,6 +87,13 @@ export declare function findValue(frame: Frame, variable: object): unknown;
|
|
|
66
87
|
* the hooks again.
|
|
67
88
|
*/
|
|
68
89
|
export declare function applyWithHooks<T, A extends unknown[], R>(hooks: readonly HookEntry[], callback: Function, source: string, fn: (this: T, ...args: A) => R, thisValue: T, args: A): R;
|
|
90
|
+
/**
|
|
91
|
+
* This function starts `fn` as a callback that a hook registered: the hooks do not operate for
|
|
92
|
+
* it. `store.inHook` stays `true` while it operates. Thus the callbacks and the async functions
|
|
93
|
+
* that it starts or registers do not start the hooks either. A hook cannot start itself without
|
|
94
|
+
* end, also through a chain of callbacks.
|
|
95
|
+
*/
|
|
96
|
+
export declare function applyQuietly<T, A extends unknown[], R>(fn: (this: T, ...args: A) => R, thisValue: T, args: A): R;
|
|
69
97
|
/**
|
|
70
98
|
* This function wraps `fn`. The wrapper starts `fn` in `frame`, with the `this`
|
|
71
99
|
* value and the arguments of the call. After `fn` ends, also with an error, the
|
package/dist/core/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sDAAsD;AACtD,MAAM,WAAW,KAAK;IAClB,QAAQ,CAAC,MAAM,EAAG,KAAK,GAAG,IAAI,CAAC;CAClC;AAED,uGAAuG;AACvG,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,OAAO,EAAG,kBAAkB,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAG,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;IACrD,QAAQ,CAAC,cAAc,EAAG,CAAC,CAAC,EAAE,KAAK,EAAG,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,gBAAgB,EAAG,MAAM,MAAM,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IACzB,wDAAwD;IACxD,OAAO,EAAG,KAAK,CAAC;IAChB,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAC;IACtB,mGAAmG;IACnG,QAAQ,CAAC,OAAO,EAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,wGAAwG;IACxG,QAAQ,CAAC,SAAS,EAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAG,UAAU,CAAC;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAG,SAAS,SAAS,EAAE,GAAG,SAAS,CAAC;IAC1C,kGAAkG;IAClG,MAAM,CAAC,EAAG,OAAO,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sDAAsD;AACtD,MAAM,WAAW,KAAK;IAClB,QAAQ,CAAC,MAAM,EAAG,KAAK,GAAG,IAAI,CAAC;CAClC;AAED,uGAAuG;AACvG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,CAAC,IAAI,EAAG,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAG,MAAM,GAAI,CAAC,IAAI,EAAG,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC,CAmBvJ;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAG,KAAK,EAAE,EAAE,EAAG,CAAC,IAAI,EAAG,CAAC,EAAE,QAAQ,EAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAG,MAAM,GAAI,CAAC,IAAI,EAAG,CAAC,EAAE,QAAQ,EAAG,CAAC,KAAK,CAAC,CAkB3I"}
|
package/dist/core/store.js
CHANGED
|
@@ -29,20 +29,50 @@ function createStore() {
|
|
|
29
29
|
// Own properties from the start: each callback reads `hooks`, and the read of an own property is faster
|
|
30
30
|
hooks: undefined,
|
|
31
31
|
inHook: false,
|
|
32
|
+
idle: root,
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* This function gives the store of the global object `holder`. If `holder` has no store, the
|
|
37
|
+
* function makes one, and adds it as a property that code cannot change or remove.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export function getOrCreateStore(holder) {
|
|
36
42
|
const existing = holder[STORE_KEY];
|
|
37
43
|
if (existing !== undefined) {
|
|
44
|
+
// The stores of version 0.2 and later have the own property hooks from the start. Version 0.1 has no hooks.
|
|
45
|
+
if (!Object.prototype.hasOwnProperty.call(existing, "hooks") && existing.oldCopyPatches === undefined) {
|
|
46
|
+
existing.oldCopyPatches = new Set(existing.patches);
|
|
47
|
+
}
|
|
38
48
|
return existing;
|
|
39
49
|
}
|
|
40
50
|
const created = createStore();
|
|
41
|
-
Object.defineProperty(
|
|
51
|
+
Object.defineProperty(holder, STORE_KEY, { value: created, writable: false, enumerable: false, configurable: false });
|
|
42
52
|
return created;
|
|
43
53
|
}
|
|
44
54
|
/** The store of this global object. */
|
|
45
|
-
export const store = getOrCreateStore();
|
|
55
|
+
export const store = getOrCreateStore(globalThis);
|
|
56
|
+
/** `true` while a record of the idle frame waits in the microtask queue. */
|
|
57
|
+
let idleRecordQueued = false;
|
|
58
|
+
/**
|
|
59
|
+
* This function records `store.idle` in the next microtask. `enterWith()` starts it, because a
|
|
60
|
+
* top-level `enterWith()` changes the frame that stays current between tasks. A microtask
|
|
61
|
+
* operates when the stack is empty, after each wrapper set its previous frame again. The callback
|
|
62
|
+
* goes to the native `then`, so no wrapper sets a frame for it.
|
|
63
|
+
*/
|
|
64
|
+
export function recordIdleFrame() {
|
|
65
|
+
// Stryker disable next-line ConditionalExpression,BlockStatement: a second record in the same turn records the same frame, so the flag only prevents more microtasks
|
|
66
|
+
if (idleRecordQueued) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Stryker disable next-line BooleanLiteral: a second record in the same turn records the same frame, so the flag only prevents more microtasks
|
|
70
|
+
idleRecordQueued = true;
|
|
71
|
+
Reflect.apply(store.intrinsics.promiseThen, store.intrinsics.promiseResolve(undefined), [() => {
|
|
72
|
+
idleRecordQueued = false;
|
|
73
|
+
store.idle = store.current;
|
|
74
|
+
}]);
|
|
75
|
+
}
|
|
46
76
|
/** This function makes `frame` the current frame. It gives the frame that was current before. */
|
|
47
77
|
export function enter(frame) {
|
|
48
78
|
const previous = store.current;
|
|
@@ -64,7 +94,8 @@ class ValueFrame {
|
|
|
64
94
|
/**
|
|
65
95
|
* The result of the last search for another variable from this frame. A
|
|
66
96
|
* frame does not change, so the result stays correct. The cached value
|
|
67
|
-
* comes from a parent frame
|
|
97
|
+
* comes from a parent frame. The cache also keeps the last variable of a
|
|
98
|
+
* search, so a frame can keep one more variable in memory.
|
|
68
99
|
*/
|
|
69
100
|
#cachedVariable = undefined;
|
|
70
101
|
#cachedValue = undefined;
|
|
@@ -91,6 +122,15 @@ class ValueFrame {
|
|
|
91
122
|
start.#cachedValue = value;
|
|
92
123
|
return value;
|
|
93
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* This method makes a frame that sets `variable`. When `parent` sets the same variable,
|
|
127
|
+
* the new frame replaces it: the new frame has the parent of `parent`. A search gives the
|
|
128
|
+
* same values. Many uses of enterWith() in one context thus do not make a long chain.
|
|
129
|
+
*/
|
|
130
|
+
static create(parent, variable, value) {
|
|
131
|
+
const base = #variable in parent && parent.#variable === variable ? parent.parent : parent;
|
|
132
|
+
return new ValueFrame(base, variable, value);
|
|
133
|
+
}
|
|
94
134
|
static #search(start, variable) {
|
|
95
135
|
for (let frame = start; frame !== null; frame = frame.parent) {
|
|
96
136
|
if (#variable in frame && frame.#variable === variable) {
|
|
@@ -102,7 +142,7 @@ class ValueFrame {
|
|
|
102
142
|
}
|
|
103
143
|
/** This function makes a new frame that has `parent` as its parent and sets `variable` to `value`. */
|
|
104
144
|
export function createFrame(parent, variable, value) {
|
|
105
|
-
return
|
|
145
|
+
return ValueFrame.create(parent, variable, value);
|
|
106
146
|
}
|
|
107
147
|
/** This function gives the value of `variable` in `frame`, or `NOT_FOUND` if no frame sets it. */
|
|
108
148
|
export function findValue(frame, variable) {
|
|
@@ -110,12 +150,17 @@ export function findValue(frame, variable) {
|
|
|
110
150
|
}
|
|
111
151
|
/** This function gives the error of a hook to the host. A hook error does not stop the callback. */
|
|
112
152
|
function reportHookError(error) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
report
|
|
116
|
-
|
|
153
|
+
try {
|
|
154
|
+
const report = globalThis.reportError;
|
|
155
|
+
if (typeof report === "function") {
|
|
156
|
+
Reflect.apply(report, globalThis, [error]);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
console.error(error);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// The report itself failed. The callback must operate, so the error stops here.
|
|
117
163
|
}
|
|
118
|
-
console.error(error);
|
|
119
164
|
}
|
|
120
165
|
/**
|
|
121
166
|
* This function starts one method of each hook. `before` uses the order of
|
|
@@ -129,12 +174,12 @@ function callHooks(hooks, phase, callback, source) {
|
|
|
129
174
|
const count = hooks.length;
|
|
130
175
|
for (let step = 0; step < count; step++) {
|
|
131
176
|
const { hook } = hooks[phase === "before" ? step : count - 1 - step];
|
|
132
|
-
const method = hook[phase];
|
|
133
|
-
if (typeof method !== "function") {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
177
|
try {
|
|
137
|
-
method
|
|
178
|
+
// A getter of the method can also throw
|
|
179
|
+
const method = hook[phase];
|
|
180
|
+
if (typeof method === "function") {
|
|
181
|
+
Reflect.apply(method, hook, [callback, source]);
|
|
182
|
+
}
|
|
138
183
|
}
|
|
139
184
|
catch (error) {
|
|
140
185
|
reportHookError(error);
|
|
@@ -154,16 +199,32 @@ function callHooks(hooks, phase, callback, source) {
|
|
|
154
199
|
*/
|
|
155
200
|
export function applyWithHooks(hooks, callback, source, fn, thisValue, args) {
|
|
156
201
|
if (store.inHook === true) {
|
|
157
|
-
return
|
|
202
|
+
return Reflect.apply(fn, thisValue, args);
|
|
158
203
|
}
|
|
159
204
|
callHooks(hooks, "before", callback, source);
|
|
160
205
|
try {
|
|
161
|
-
return
|
|
206
|
+
return Reflect.apply(fn, thisValue, args);
|
|
162
207
|
}
|
|
163
208
|
finally {
|
|
164
209
|
callHooks(hooks, "after", callback, source);
|
|
165
210
|
}
|
|
166
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* This function starts `fn` as a callback that a hook registered: the hooks do not operate for
|
|
214
|
+
* it. `store.inHook` stays `true` while it operates. Thus the callbacks and the async functions
|
|
215
|
+
* that it starts or registers do not start the hooks either. A hook cannot start itself without
|
|
216
|
+
* end, also through a chain of callbacks.
|
|
217
|
+
*/
|
|
218
|
+
export function applyQuietly(fn, thisValue, args) {
|
|
219
|
+
const previous = store.inHook;
|
|
220
|
+
store.inHook = true;
|
|
221
|
+
try {
|
|
222
|
+
return Reflect.apply(fn, thisValue, args);
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
store.inHook = previous;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
167
228
|
/*
|
|
168
229
|
* Each wrapper has the name `asyncBrowserContextWrapper`. Profilers, stack
|
|
169
230
|
* traces and the Long Animation Frames API show the static name of a
|
|
@@ -177,13 +238,18 @@ export function applyWithHooks(hooks, callback, source, fn, thisValue, args) {
|
|
|
177
238
|
* `fn`, for the callback hooks.
|
|
178
239
|
*/
|
|
179
240
|
export function bindToFrame(frame, fn, source) {
|
|
241
|
+
// A callback that a hook registers does not start the hooks, so a hook cannot start itself without end
|
|
242
|
+
const quiet = store.inHook === true;
|
|
180
243
|
return function asyncBrowserContextWrapper(...args) {
|
|
181
244
|
const previous = store.current;
|
|
182
245
|
store.current = frame;
|
|
183
246
|
try {
|
|
247
|
+
if (quiet) {
|
|
248
|
+
return applyQuietly(fn, this, args);
|
|
249
|
+
}
|
|
184
250
|
const hooks = store.hooks;
|
|
185
251
|
if (hooks === undefined) {
|
|
186
|
-
return
|
|
252
|
+
return Reflect.apply(fn, this, args);
|
|
187
253
|
}
|
|
188
254
|
return applyWithHooks(hooks, fn, source, fn, this, args);
|
|
189
255
|
}
|
|
@@ -198,13 +264,17 @@ export function bindToFrame(frame, fn, source) {
|
|
|
198
264
|
* `bindToFrame` on the hot path.
|
|
199
265
|
*/
|
|
200
266
|
export function bindOneArgument(frame, fn, source) {
|
|
267
|
+
const quiet = store.inHook === true;
|
|
201
268
|
return function asyncBrowserContextWrapper(argument) {
|
|
202
269
|
const previous = store.current;
|
|
203
270
|
store.current = frame;
|
|
204
271
|
try {
|
|
272
|
+
if (quiet) {
|
|
273
|
+
return applyQuietly(fn, this, [argument]);
|
|
274
|
+
}
|
|
205
275
|
const hooks = store.hooks;
|
|
206
276
|
if (hooks === undefined) {
|
|
207
|
-
return
|
|
277
|
+
return Reflect.apply(fn, this, [argument]);
|
|
208
278
|
}
|
|
209
279
|
return applyWithHooks(hooks, fn, source, fn, this, [argument]);
|
|
210
280
|
}
|
package/dist/core/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA4DH,+FAA+F;AAC/F,MAAM,SAAS,GAAY,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAExE,SAAS,WAAW;IAChB,MAAM,aAAa,GAAG,OAAO,CAAC;IAC9B,MAAM,IAAI,GAAW,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAG,IAAI,EAAE,CAAC,CAAC;IACtD,OAAO;QACH,OAAO,EAAG,IAAI;QACd,IAAI;QACJ,OAAO,EAAG,IAAI,GAAG,EAAE;QACnB,SAAS,EAAG,IAAI,OAAO,EAAE;QACzB,UAAU,EAAG,MAAM,CAAC,MAAM,CAAC;YACvB,OAAO,EAAG,aAAa;YACvB,WAAW,EAAG,aAAa,CAAC,SAAS,CAAC,IAAI;YAC1C,cAAc,EAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAiC;YAC1F,gBAAgB,EAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ;SACjD,CAAC;QACF,wGAAwG;QACxG,KAAK,EAAG,SAAS;QACjB,MAAM,EAAG,KAAK;QACd,IAAI,EAAG,IAAI;KACd,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC5C,MAAM,QAAQ,GAAI,MAAmD,CAAC,SAAS,CAAC,CAAC;IACjF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACzB,4GAA4G;QAC5G,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,I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EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;gBAAS,CAAC;YACP,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC7B,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAU,KAAa,EAAE,EAAkC,EAAE,MAAe;IACvG,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,SAAS,0BAA0B,CAAW,QAAY;QAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;QAC/B,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC;YACD,IAAI,KAAK,EAAE,CAAC;gBACR,OAAO,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC9C,CAAC;YACD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACtB,OAAO,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,cAAc,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnE,CAAC;gBAAS,CAAC;YACP,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC7B,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
|
package/dist/core/variable.d.ts
CHANGED
|
@@ -34,7 +34,8 @@ export declare class Variable<T> {
|
|
|
34
34
|
get(): T | undefined;
|
|
35
35
|
/**
|
|
36
36
|
* This method starts `fn` with `args` in a new context in which `get()`
|
|
37
|
-
* gives `value`.
|
|
37
|
+
* gives `value`. As in the TC39 draft, `fn` gets `undefined` as its `this`
|
|
38
|
+
* value. After `fn` ends, also with an error, the previous context is
|
|
38
39
|
* current again. The method gives the result of `fn`.
|
|
39
40
|
*/
|
|
40
41
|
run<R, A extends unknown[]>(value: T, fn: (...args: A) => R, ...args: A): R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/core/variable.ts"],"names":[],"mappings":"AAEA,mCAAmC;AACnC,MAAM,WAAW,eAAe,CAAC,CAAC;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,CAAC,EAAG,MAAM,GAAG,SAAS,CAAC;IACpC,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAG,CAAC,GAAG,SAAS,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,QAAQ,CAAC,CAAC;;gBAIP,OAAO,GAAG,eAAe,CAAC,CAAC,CAAM;IAK7C,gCAAgC;IAChC,IAAI,IAAI,IAAK,MAAM,CAElB;IAED;;;OAGG;IACH,GAAG,IAAK,CAAC,GAAG,SAAS;IAKrB
|
|
1
|
+
{"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/core/variable.ts"],"names":[],"mappings":"AAEA,mCAAmC;AACnC,MAAM,WAAW,eAAe,CAAC,CAAC;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,CAAC,EAAG,MAAM,GAAG,SAAS,CAAC;IACpC,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAG,CAAC,GAAG,SAAS,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,QAAQ,CAAC,CAAC;;gBAIP,OAAO,GAAG,eAAe,CAAC,CAAC,CAAM;IAK7C,gCAAgC;IAChC,IAAI,IAAI,IAAK,MAAM,CAElB;IAED;;;OAGG;IACH,GAAG,IAAK,CAAC,GAAG,SAAS;IAKrB;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,EAAE,KAAK,EAAG,CAAC,EAAE,EAAE,EAAG,CAAC,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,GAAI,CAAC;CASnF"}
|
package/dist/core/variable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createFrame, findValue, NOT_FOUND, store } from "./store.js";
|
|
1
|
+
import { createFrame, findValue, NOT_FOUND, recordIdleFrame, store } from "./store.js";
|
|
2
2
|
/**
|
|
3
3
|
* A value that is different in each context. This class is the
|
|
4
4
|
* `AsyncContext.Variable` of the TC39 AsyncContext proposal.
|
|
@@ -37,7 +37,8 @@ export class Variable {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* This method starts `fn` with `args` in a new context in which `get()`
|
|
40
|
-
* gives `value`.
|
|
40
|
+
* gives `value`. As in the TC39 draft, `fn` gets `undefined` as its `this`
|
|
41
|
+
* value. After `fn` ends, also with an error, the previous context is
|
|
41
42
|
* current again. The method gives the result of `fn`.
|
|
42
43
|
*/
|
|
43
44
|
run(value, fn, ...args) {
|
|
@@ -51,6 +52,7 @@ export class Variable {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
}
|
|
55
|
+
Object.defineProperty(Variable.prototype, Symbol.toStringTag, { value: "AsyncContext.Variable", configurable: true });
|
|
54
56
|
/**
|
|
55
57
|
* This function makes a new current frame in which `variable` has `value`.
|
|
56
58
|
* The frame stays current until the code that controls the current step sets
|
|
@@ -60,5 +62,6 @@ export class Variable {
|
|
|
60
62
|
*/
|
|
61
63
|
export function enterValue(variable, value) {
|
|
62
64
|
store.current = createFrame(store.current, variable, value);
|
|
65
|
+
recordIdleFrame();
|
|
63
66
|
}
|
|
64
67
|
//# sourceMappingURL=variable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable.js","sourceRoot":"","sources":["../../src/core/variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAA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AAC,WAAW,EAAE,EAAE,KAAK,EAAG,uBAAuB,EAAE,YAAY,EAAG,IAAI,EAAE,CAAC,CAAC;AAExH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAI,QAAsB,EAAE,KAAS;IAC3D,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5D,eAAe,EAAE,CAAC;AACtB,CAAC"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -21,20 +21,26 @@ export declare class Variable<T> {
|
|
|
21
21
|
get name(): string;
|
|
22
22
|
/** This method gives the value of this variable in the current context, or the default value. */
|
|
23
23
|
get(): T | undefined;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* This method starts `fn` with `args` in a new context in which `get()` gives `value`. As
|
|
26
|
+
* in the TC39 draft, `fn` gets `undefined` as its `this` value.
|
|
27
|
+
*/
|
|
25
28
|
run<R, A extends unknown[]>(value: T, fn: (...args: A) => R, ...args: A): R;
|
|
26
29
|
}
|
|
27
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* The `AsyncContext.Snapshot` of the TC39 proposal. An `AsyncResource` records the context, as
|
|
32
|
+
* `AsyncLocalStorage.snapshot()` does, at a much lower cost (src/node/runtime.ts).
|
|
33
|
+
*/
|
|
28
34
|
export declare class Snapshot {
|
|
29
35
|
#private;
|
|
30
|
-
/** This method starts `fn` with `args` in the recorded context. */
|
|
36
|
+
/** This method starts `fn` with `args` in the recorded context. `fn` gets `undefined` as its `this` value. */
|
|
31
37
|
run<R, A extends unknown[]>(fn: (...args: A) => R, ...args: A): R;
|
|
32
38
|
/** This method records the current context. It gives a wrapper of `fn` that operates in that context. */
|
|
33
39
|
static wrap<T, A extends unknown[], R>(fn: (this: T, ...args: A) => R): (this: T, ...args: A) => R;
|
|
34
40
|
}
|
|
35
41
|
/**
|
|
36
42
|
* The native `AsyncLocalStorage` of Node.js. On a Node.js version without the
|
|
37
|
-
* `defaultValue` and `name` options, a
|
|
43
|
+
* `defaultValue` and `name` options, a compatible class adds them (compatible-storage.ts).
|
|
38
44
|
*/
|
|
39
45
|
export declare const AsyncLocalStorage: typeof NodeAsyncLocalStorage;
|
|
40
46
|
/** The type of the native `AsyncLocalStorage`. */
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAiB,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAmB3D,2FAA2F;AAC3F,qBAAa,QAAQ,CAAC,CAAC;;gBAIP,OAAO,GAAG,eAAe,CAAC,CAAC,CAAM;IAK7C,gCAAgC;IAChC,IAAI,IAAI,IAAK,MAAM,CAElB;IAED,iGAAiG;IACjG,GAAG,IAAK,CAAC,GAAG,SAAS;IASrB;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,EAAE,KAAK,EAAG,CAAC,EAAE,EAAE,EAAG,CAAC,GAAG,IAAI,EAAG,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAG,CAAC,GAAI,CAAC;CAMnF;AAOD;;;GAGG;AACH,qBAAa,QAA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