async-browser-context 0.1.1 → 0.2.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 (75) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +26 -3
  3. package/dist/babel/name-coroutines.d.ts +25 -0
  4. package/dist/babel/name-coroutines.d.ts.map +1 -0
  5. package/dist/babel/name-coroutines.js +116 -0
  6. package/dist/babel/name-coroutines.js.map +1 -0
  7. package/dist/babel/preset.d.ts +4 -2
  8. package/dist/babel/preset.d.ts.map +1 -1
  9. package/dist/babel/preset.js +6 -2
  10. package/dist/babel/preset.js.map +1 -1
  11. package/dist/core/callback-hook.d.ts +24 -0
  12. package/dist/core/callback-hook.d.ts.map +1 -0
  13. package/dist/core/callback-hook.js +13 -0
  14. package/dist/core/callback-hook.js.map +1 -0
  15. package/dist/core/coroutine.d.ts +2 -12
  16. package/dist/core/coroutine.d.ts.map +1 -1
  17. package/dist/core/coroutine.js +23 -8
  18. package/dist/core/coroutine.js.map +1 -1
  19. package/dist/core/hooks.d.ts +15 -0
  20. package/dist/core/hooks.d.ts.map +1 -0
  21. package/dist/core/hooks.js +28 -0
  22. package/dist/core/hooks.js.map +1 -0
  23. package/dist/core/store.d.ts +28 -3
  24. package/dist/core/store.d.ts.map +1 -1
  25. package/dist/core/store.js +81 -7
  26. package/dist/core/store.js.map +1 -1
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/node/index.d.ts +10 -0
  32. package/dist/node/index.d.ts.map +1 -1
  33. package/dist/node/index.js +14 -0
  34. package/dist/node/index.js.map +1 -1
  35. package/dist/patches/callbacks.d.ts.map +1 -1
  36. package/dist/patches/callbacks.js +10 -8
  37. package/dist/patches/callbacks.js.map +1 -1
  38. package/dist/patches/events.d.ts.map +1 -1
  39. package/dist/patches/events.js +39 -22
  40. package/dist/patches/events.js.map +1 -1
  41. package/dist/patches/handler-interfaces.d.ts +16 -0
  42. package/dist/patches/handler-interfaces.d.ts.map +1 -0
  43. package/dist/patches/handler-interfaces.js +42 -0
  44. package/dist/patches/handler-interfaces.js.map +1 -0
  45. package/dist/patches/observers.js +1 -1
  46. package/dist/patches/observers.js.map +1 -1
  47. package/dist/patches/patch.d.ts +5 -2
  48. package/dist/patches/patch.d.ts.map +1 -1
  49. package/dist/patches/patch.js +6 -3
  50. package/dist/patches/patch.js.map +1 -1
  51. package/dist/patches/promise.js +1 -1
  52. package/dist/patches/promise.js.map +1 -1
  53. package/dist/patches/streams.d.ts.map +1 -1
  54. package/dist/patches/streams.js +12 -7
  55. package/dist/patches/streams.js.map +1 -1
  56. package/dist/patches/timers.d.ts.map +1 -1
  57. package/dist/patches/timers.js +6 -5
  58. package/dist/patches/timers.js.map +1 -1
  59. package/package.json +2 -1
  60. package/src/babel/name-coroutines.ts +128 -0
  61. package/src/babel/preset.ts +6 -2
  62. package/src/core/callback-hook.ts +34 -0
  63. package/src/core/coroutine.ts +27 -8
  64. package/src/core/hooks.ts +30 -0
  65. package/src/core/store.ts +108 -7
  66. package/src/index.ts +1 -0
  67. package/src/node/index.ts +16 -0
  68. package/src/patches/callbacks.ts +10 -8
  69. package/src/patches/events.ts +38 -22
  70. package/src/patches/handler-interfaces.ts +41 -0
  71. package/src/patches/observers.ts +1 -1
  72. package/src/patches/patch.ts +6 -3
  73. package/src/patches/promise.ts +2 -2
  74. package/src/patches/streams.ts +12 -7
  75. package/src/patches/timers.ts +6 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change history
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### New functions
6
+
7
+ - `addCallbackHook(hook)` adds a hook. The library starts `hook.before` and `hook.after` around each callback of a patched API and each step of an async function after an `await`. The hook methods get the callback and its source, for example `"setTimeout"` or `"addEventListener:click"`, and operate in the context of the callback. Thus, a tool can find the operation and the function of a long task in all browsers. On Node.js, the function does nothing.
8
+ - The Babel preset gives the name of each async function to `coroutine`. The callback hooks show this name for the steps after an `await`.
9
+
10
+ ### Changes
11
+
12
+ - Each wrapper of the library has the name `asyncBrowserContextWrapper`. Before, the wrappers had the name `boundToFrame` or no name. Stack traces, profilers and the Long Animation Frames API show this name between the browser and the callback.
13
+ - The event patch reads only the 138 interfaces that have `on...` properties. Before, it read all globals of the page, approximately 1,000. For each global that code reads for the first time, the browser makes an interface object. Thus, the patches take less time when the page loads. The median changed from 18 to 8 ms in Chromium, from 22 to 8 ms in Firefox and from 16 to 7 ms in WebKit. A browser test makes sure that the list contains each interface with `on...` properties.
14
+ - The documents tell one more case of rule C13. When code in the root context dispatches an event, the listener gets the context of its registration.
15
+
3
16
  ## 0.1.1
4
17
 
5
18
  This version changes only the documentation. The code is the same as in 0.1.0.
package/README.md CHANGED
@@ -95,7 +95,7 @@ The plugin transforms the modules of the application and of its dependencies, al
95
95
 
96
96
  2. Make sure that Babel transforms the dependencies too. With webpack, do not exclude `node_modules` from `babel-loader`.
97
97
 
98
- The preset operates with Babel 7.22 and later, and with Babel 8.
98
+ The preset operates with Babel 7.22 and later, and with Babel 8. CI examines Babel 7.22, the newest Babel 7 and the newest Babel 8 with the packed package (`pnpm test:babel`).
99
99
 
100
100
  ### Node.js
101
101
 
@@ -133,6 +133,24 @@ snapshot.run(() => userId.get()); // "u-1"
133
133
 
134
134
  The package also exports `Variable`, `Snapshot`, and the other names `AsyncVariable` and `AsyncSnapshot`.
135
135
 
136
+ **`addCallbackHook`** adds a hook. The library starts its methods before and after each callback that it starts, in the context of that callback. Use it to measure callbacks, and to find the operation of a long task, also in Firefox and Safari:
137
+
138
+ ```ts
139
+ import { addCallbackHook, AsyncLocalStorage } from "async-browser-context";
140
+
141
+ const operation = new AsyncLocalStorage<string>(); // Start each operation in operation.run()
142
+ const starts : number[] = [];
143
+ addCallbackHook({
144
+ before() { starts.push(performance.now()); },
145
+ after(callback, source) {
146
+ const duration = performance.now() - (starts.pop() ?? 0);
147
+ if (duration >= 50) report(operation.getStore(), callback.name, source, duration);
148
+ },
149
+ });
150
+ ```
151
+
152
+ `source` names the API, for example `"setTimeout"`, `"addEventListener:click"` or `"await"`. For a step after an `await`, `callback.name` is the name of the async function. The guide [Find the operation of a long task](https://mark1russell7.github.io/AsyncBrowserContext/docs/guides/long-tasks) tells more.
153
+
136
154
  ## Entry points
137
155
 
138
156
  | Import | Function |
@@ -177,7 +195,7 @@ The tests examine each rule on the browser runtime, on the Node.js runtime and i
177
195
  | C10 | Two copies of the library on one page use one context store. |
178
196
  | C11 | The library does not replace the `Promise` constructor. `Promise` subclasses operate as without the library. |
179
197
  | C12 | The library does not keep promises or values in memory after the program has no reference to them. |
180
- | C13 | An event listener gets the context of the code that dispatches the event. When the browser dispatches the event, the listener gets the context of the `addEventListener()` call or of the assignment to the `on...` property. |
198
+ | C13 | An event listener gets the context of the code that dispatches the event. If that code has the root context, the listener gets the registration context. This is the context of the `addEventListener()` call or of the assignment to the `on...` property. An event that the browser dispatches, for example a click of the user, also gives the registration context. |
181
199
 
182
200
  ## Patched APIs
183
201
 
@@ -201,6 +219,7 @@ In transformed code, each step gets the context of its own operation. Code witho
201
219
  | The other code | What to do |
202
220
  | --- | --- |
203
221
  | Gives a promise, and your code awaits it | Nothing. After the `await`, your code gets its context again. |
222
+ | Is async code that a compiler changed before the publish (`__awaiter` of TypeScript, `_asyncToGenerator` of Babel) | Nothing. The helpers continue in `then` callbacks, and the patch of `then` keeps the context. |
204
223
  | Starts your callback synchronously, or from a timer, an observer or a promise that it registers before its first `await` | Nothing. The patched APIs keep the context. Event listeners follow rule C13. |
205
224
  | Starts your callback after its own native `await` | `AsyncLocalStorage.bind(callback)` or `AsyncContext.Snapshot.wrap(callback)` |
206
225
  | Keeps your callback in a list and starts it later from other code | `AsyncLocalStorage.bind(callback)` when you give the callback |
@@ -213,7 +232,7 @@ untransformedLibrary.onDone(AsyncLocalStorage.bind((result) => {
213
232
  }));
214
233
  ```
215
234
 
216
- The Vite plugin transforms the dependencies in `node_modules` by default. Thus, these boundaries are usually only scripts from other servers, browser extensions and code from `eval()` or `new Function()`. The tests in `test/rules/c07-boundaries.test.ts` examine each row. The [boundaries page](https://mark1russell7.github.io/AsyncBrowserContext/docs/concepts/boundaries) of the website gives the details.
235
+ The Vite plugin transforms the dependencies in `node_modules` by default. Thus, these boundaries are usually only scripts from other servers, browser extensions and code from `eval()` or `new Function()`. The tests in `test/rules/c07-boundaries.test.ts` and `test/rules/c07-compiled-dependencies.test.ts` examine each row. The [boundaries page](https://mark1russell7.github.io/AsyncBrowserContext/docs/concepts/boundaries) of the website gives the details.
217
236
 
218
237
  Do not use the library together with zone.js or with another library that patches `Promise.prototype.then`. The two libraries patch the same functions with different rules. For OpenTelemetry, use `AsyncContextManager` in place of the `ZoneContextManager`.
219
238
 
@@ -221,6 +240,7 @@ Do not use the library together with zone.js or with another library that patche
221
240
 
222
241
  - **Generator functions.** A transformed generator function is an ordinary function that gives a generator. `fn.prototype` and `instanceof fn` do not operate as for a native generator function. The generator objects operate as native generator objects.
223
242
  - **Stack traces.** In transformed code, a stack trace shows the generator and the `coroutine` function of the runtime.
243
+ - **Profilers.** Between the browser and each callback of a patched API, stack traces and profilers show the wrapper `asyncBrowserContextWrapper`. The Long Animation Frames API of Chromium shows this name in place of your function. `addCallbackHook()` gives the function and the context of each callback.
224
244
 
225
245
  ## Performance
226
246
 
@@ -237,6 +257,8 @@ These results are from `pnpm bench`: the mean time of each scenario, on Node.js
237
257
 
238
258
  One read with `get()` takes approximately 4 ns. The [documentation website](https://mark1russell7.github.io/AsyncBrowserContext/) shows the full results.
239
259
 
260
+ When the page loads, the library installs its patches in approximately 8 ms: the median of Chromium, Firefox and WebKit on the same computer.
261
+
240
262
  ## Tests
241
263
 
242
264
  | Command | Function |
@@ -245,6 +267,7 @@ One read with `get()` takes approximately 4 ns. The [documentation website](http
245
267
  | `pnpm test:node` | The tests in Node.js only |
246
268
  | `pnpm test:browser` | The tests in Chromium, Firefox and WebKit |
247
269
  | `pnpm smoke` | Packs the package, installs it in a new Vite application, and examines the application in Chromium |
270
+ | `pnpm test:babel` | Packs the package, transforms a program with the preset in Babel 7.22, the newest Babel 7 and Babel 8, and starts the output |
248
271
  | `pnpm mutation` | Mutation testing with Stryker |
249
272
  | `pnpm bench` | The benchmarks |
250
273
  | `pnpm lint:ste` | The STE linter of the documentation and the TSDoc comments |
@@ -0,0 +1,25 @@
1
+ import { types, type NodePath, type PluginObject, type PluginPass } from "@babel/core";
2
+ /** The options of the plugin. */
3
+ export interface NameCoroutinesOptions {
4
+ /** The module that exports `coroutine`. */
5
+ readonly runtime: string;
6
+ }
7
+ /**
8
+ * This function gives the `name` that JavaScript gives to the function, or
9
+ * `undefined` if the name is not known before run time.
10
+ */
11
+ export declare function functionName(path: NodePath<types.Function>): string | undefined;
12
+ /**
13
+ * The Babel plugin that gives the name of each async function to `coroutine`:
14
+ * `_coroutine(function* () {...}, "load")`. The generator function of
15
+ * `@babel/plugin-transform-async-to-generator` has no name, and the callback
16
+ * hooks of the runtime show the name of the async function.
17
+ *
18
+ * In `Program` enter, before the async transform, the plugin records the
19
+ * name of each async function. In `Program` exit, it adds the name to each
20
+ * `coroutine` call. For a plain function, the async transform keeps the
21
+ * function node as the argument of `coroutine`. For a method, the call is in
22
+ * the body of the method.
23
+ */
24
+ export declare function nameCoroutinesPlugin(_api: unknown, options: object): PluginObject<PluginPass>;
25
+ //# sourceMappingURL=name-coroutines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-coroutines.d.ts","sourceRoot":"","sources":["../../src/babel/name-coroutines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvF,iCAAiC;AACjC,MAAM,WAAW,qBAAqB;IAClC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAG,MAAM,CAAC;CAC7B;AAyBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAI,MAAM,GAAG,SAAS,CAsBjF;AAcD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAG,OAAO,EAAE,OAAO,EAAG,MAAM,GAAI,YAAY,CAAC,UAAU,CAAC,CA4ChG"}
@@ -0,0 +1,116 @@
1
+ import { types } from "@babel/core";
2
+ /** The local names that Babel gives to the import of `coroutine`. */
3
+ const COROUTINE_NAME = /^_coroutine\d*$/;
4
+ /** The assignment operators that give a name to an anonymous function, as in the specification (NamedEvaluation). */
5
+ const NAMING_OPERATORS = new Set(["=", "&&=", "||=", "??="]);
6
+ /** This function gives the name of a property key, or `undefined` if the name is known only at run time. */
7
+ function keyName(key, computed) {
8
+ if (types.isStringLiteral(key)) {
9
+ return key.value;
10
+ }
11
+ if (types.isNumericLiteral(key)) {
12
+ return String(key.value);
13
+ }
14
+ if (computed) {
15
+ return undefined;
16
+ }
17
+ if (types.isIdentifier(key)) {
18
+ return key.name;
19
+ }
20
+ return types.isPrivateName(key) ? `#${key.id.name}` : undefined;
21
+ }
22
+ /**
23
+ * This function gives the `name` that JavaScript gives to the function, or
24
+ * `undefined` if the name is not known before run time.
25
+ */
26
+ export function functionName(path) {
27
+ const node = path.node;
28
+ if ((types.isFunctionDeclaration(node) || types.isFunctionExpression(node)) && node.id) {
29
+ return node.id.name;
30
+ }
31
+ if (types.isObjectMethod(node) || types.isClassMethod(node) || types.isClassPrivateMethod(node)) {
32
+ return keyName(node.key, node.computed === true);
33
+ }
34
+ const parent = path.parent;
35
+ if (types.isVariableDeclarator(parent) && parent.init === node && types.isIdentifier(parent.id)) {
36
+ return parent.id.name;
37
+ }
38
+ if (types.isAssignmentExpression(parent) && parent.right === node && NAMING_OPERATORS.has(parent.operator) && types.isIdentifier(parent.left)) {
39
+ return parent.left.name;
40
+ }
41
+ if (types.isAssignmentPattern(parent) && parent.right === node && types.isIdentifier(parent.left)) {
42
+ return parent.left.name;
43
+ }
44
+ if ((types.isObjectProperty(parent) || types.isClassProperty(parent) || types.isClassPrivateProperty(parent)) && parent.value === node) {
45
+ return keyName(parent.key, "computed" in parent && parent.computed === true);
46
+ }
47
+ return types.isExportDefaultDeclaration(parent) ? "default" : undefined;
48
+ }
49
+ /** This function gives `true` if `callee` is the `coroutine` function of the runtime, also in CommonJS output. */
50
+ function isCoroutineCallee(callee, path, runtime) {
51
+ if (types.isIdentifier(callee)) {
52
+ return COROUTINE_NAME.test(callee.name) || path.referencesImport(runtime, "coroutine");
53
+ }
54
+ const member = types.isSequenceExpression(callee) ? callee.expressions.at(-1) : callee;
55
+ return types.isMemberExpression(member) && types.isIdentifier(member.property, { name: "coroutine" });
56
+ }
57
+ /** The key of the names of one file in the plugin state. */
58
+ const NAMES_KEY = "async-browser-context/coroutine-names";
59
+ /**
60
+ * The Babel plugin that gives the name of each async function to `coroutine`:
61
+ * `_coroutine(function* () {...}, "load")`. The generator function of
62
+ * `@babel/plugin-transform-async-to-generator` has no name, and the callback
63
+ * hooks of the runtime show the name of the async function.
64
+ *
65
+ * In `Program` enter, before the async transform, the plugin records the
66
+ * name of each async function. In `Program` exit, it adds the name to each
67
+ * `coroutine` call. For a plain function, the async transform keeps the
68
+ * function node as the argument of `coroutine`. For a method, the call is in
69
+ * the body of the method.
70
+ */
71
+ export function nameCoroutinesPlugin(_api, options) {
72
+ const { runtime } = options;
73
+ return {
74
+ name: "async-browser-context/name-coroutines",
75
+ visitor: {
76
+ Program: {
77
+ enter(programPath, state) {
78
+ const names = new WeakMap();
79
+ programPath.traverse({
80
+ Function(path) {
81
+ if (!path.node.async || path.node.generator) {
82
+ return;
83
+ }
84
+ const name = functionName(path);
85
+ if (name !== undefined && name !== "") {
86
+ names.set(path.node, name);
87
+ }
88
+ },
89
+ });
90
+ state.set(NAMES_KEY, names);
91
+ },
92
+ exit(programPath, state) {
93
+ const names = state.get(NAMES_KEY);
94
+ programPath.traverse({
95
+ CallExpression(path) {
96
+ const { callee, arguments: args } = path.node;
97
+ const [body] = args;
98
+ if (args.length !== 1 || !types.isFunctionExpression(body) || !body.generator) {
99
+ return;
100
+ }
101
+ if (!isCoroutineCallee(callee, path.get("callee"), runtime)) {
102
+ return;
103
+ }
104
+ const parent = path.getFunctionParent()?.node;
105
+ const name = names.get(body) ?? (types.isMethod(parent) ? names.get(parent) : undefined);
106
+ if (name !== undefined) {
107
+ args.push(types.stringLiteral(name));
108
+ }
109
+ },
110
+ });
111
+ },
112
+ },
113
+ },
114
+ };
115
+ }
116
+ //# sourceMappingURL=name-coroutines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-coroutines.js","sourceRoot":"","sources":["../../src/babel/name-coroutines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqD,MAAM,aAAa,CAAC;AAQvF,qEAAqE;AACrE,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC,qHAAqH;AACrH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAE7D,4GAA4G;AAC5G,SAAS,OAAO,CAAC,GAAgB,EAAE,QAAkB;IACjD,IAAI,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,IAAI,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC,IAAI,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,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E,CAAC;gCAC5E,OAAO;4BACX,CAAC;4BACD,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC;gCAC1D,OAAO;4BACX,CAAC;4BACD,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,CAAC;4BAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;4BACzF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gCACrB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;4BACzC,CAAC;wBACL,CAAC;qBACJ,CAAC,CAAC;gBACP,CAAC;aACJ;SACJ;KACJ,CAAC;AACN,CAAC"}
@@ -16,9 +16,11 @@ export declare const DEFAULT_RUNTIME = "async-browser-context/runtime";
16
16
  *
17
17
  * 1. A plugin of this library binds each generator to the context of its
18
18
  * creation.
19
- * 2. `@babel/plugin-transform-async-generator-functions` changes async
19
+ * 2. A plugin of this library gives the name of each async function to
20
+ * `coroutine`, for the callback hooks.
21
+ * 3. `@babel/plugin-transform-async-generator-functions` changes async
20
22
  * generators and `for await` loops.
21
- * 3. `@babel/plugin-transform-async-to-generator` changes each async function
23
+ * 4. `@babel/plugin-transform-async-to-generator` changes each async function
22
24
  * into a generator that the `coroutine` function of the runtime operates.
23
25
  *
24
26
  * The preset operates with Babel 7.22 and later and with Babel 8. Put it last
@@ -1 +1 @@
1
- {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/babel/preset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,iCAAiC;AACjC,MAAM,WAAW,aAAa;IAC1B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAG,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,kCAAkC;AAClC,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,GAAG,EAAG,SAAS,EAAE,OAAO,GAAG,aAAkB,GAAI,YAAY,CAU9G"}
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/babel/preset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,iCAAiC;AACjC,MAAM,WAAW,aAAa;IAC1B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAG,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,kCAAkC;AAClC,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,GAAG,EAAG,SAAS,EAAE,OAAO,GAAG,aAAkB,GAAI,YAAY,CAW9G"}
@@ -1,6 +1,7 @@
1
1
  import asyncGeneratorFunctions from "@babel/plugin-transform-async-generator-functions";
2
2
  import asyncToGenerator from "@babel/plugin-transform-async-to-generator";
3
3
  import { bindGeneratorsPlugin } from "./bind-generators.js";
4
+ import { nameCoroutinesPlugin } from "./name-coroutines.js";
4
5
  export { METADATA_KEY } from "./bind-generators.js";
5
6
  /** The default runtime module. */
6
7
  export const DEFAULT_RUNTIME = "async-browser-context/runtime";
@@ -10,9 +11,11 @@ export const DEFAULT_RUNTIME = "async-browser-context/runtime";
10
11
  *
11
12
  * 1. A plugin of this library binds each generator to the context of its
12
13
  * creation.
13
- * 2. `@babel/plugin-transform-async-generator-functions` changes async
14
+ * 2. A plugin of this library gives the name of each async function to
15
+ * `coroutine`, for the callback hooks.
16
+ * 3. `@babel/plugin-transform-async-generator-functions` changes async
14
17
  * generators and `for await` loops.
15
- * 3. `@babel/plugin-transform-async-to-generator` changes each async function
18
+ * 4. `@babel/plugin-transform-async-to-generator` changes each async function
16
19
  * into a generator that the `coroutine` function of the runtime operates.
17
20
  *
18
21
  * The preset operates with Babel 7.22 and later and with Babel 8. Put it last
@@ -24,6 +27,7 @@ export default function asyncBrowserContextPreset(api, options = {}) {
24
27
  return {
25
28
  plugins: [
26
29
  [bindGeneratorsPlugin, { runtime }],
30
+ [nameCoroutinesPlugin, { runtime }],
27
31
  asyncGeneratorFunctions,
28
32
  [asyncToGenerator, { module: runtime, method: "coroutine" }],
29
33
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","sourceRoot":"","sources":["../../src/babel/preset.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,MAAM,mDAAmD,CAAC;AACxF,OAAO,gBAAgB,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAWpD,kCAAkC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,+BAA+B,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,GAAe,EAAE,UAA0B,EAAE;IAC3F,GAAG,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC;IACnD,OAAO;QACH,OAAO,EAAG;YACN,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,CAAC;YACnC,uBAAuB;YACvB,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAG,OAAO,EAAE,MAAM,EAAG,WAAW,EAAE,CAAC;SACjE;KACJ,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"preset.js","sourceRoot":"","sources":["../../src/babel/preset.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,MAAM,mDAAmD,CAAC;AACxF,OAAO,gBAAgB,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAWpD,kCAAkC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,+BAA+B,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,GAAe,EAAE,UAA0B,EAAE;IAC3F,GAAG,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC;IACnD,OAAO;QACH,OAAO,EAAG;YACN,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,CAAC;YACnC,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,CAAC;YACnC,uBAAuB;YACvB,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAG,OAAO,EAAE,MAAM,EAAG,WAAW,EAAE,CAAC;SACjE;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A callback hook. The library starts `before` immediately before each
3
+ * callback that it starts, and `after` immediately after the callback, also
4
+ * after an error. Both methods operate in the context of the callback, so
5
+ * `variable.get()` and `storage.getStore()` give the values of the callback.
6
+ */
7
+ export interface CallbackHook {
8
+ /**
9
+ * The library starts this method before the callback.
10
+ *
11
+ * @param callback - The function that the library starts. For the step
12
+ * of an async function after an `await`, it is the body of the async
13
+ * function, with the name of the async function.
14
+ * @param source - The API that got the callback, for example
15
+ * `"setTimeout"`, `"Promise.then"`, `"addEventListener:click"`,
16
+ * `"onclick"` or `"await"`.
17
+ */
18
+ before?(callback: Function, source: string): void;
19
+ /** The library starts this method after the callback, also after an error. The arguments are the same as for `before`. */
20
+ after?(callback: Function, source: string): void;
21
+ }
22
+ /** This function makes sure that `hook` is an object, and that `before` and `after` are functions or `undefined`. */
23
+ export declare function assertCallbackHook(hook: CallbackHook): void;
24
+ //# sourceMappingURL=callback-hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback-hook.d.ts","sourceRoot":"","sources":["../../src/core/callback-hook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IACzB;;;;;;;;;OASG;IACH,MAAM,CAAC,CAAC,QAAQ,EAAG,QAAQ,EAAE,MAAM,EAAG,MAAM,GAAI,IAAI,CAAC;IACrD,0HAA0H;IAC1H,KAAK,CAAC,CAAC,QAAQ,EAAG,QAAQ,EAAE,MAAM,EAAG,MAAM,GAAI,IAAI,CAAC;CACvD;AAED,qHAAqH;AACrH,wBAAgB,kBAAkB,CAAC,IAAI,EAAG,YAAY,GAAI,IAAI,CAU7D"}
@@ -0,0 +1,13 @@
1
+ /** This function makes sure that `hook` is an object, and that `before` and `after` are functions or `undefined`. */
2
+ export function assertCallbackHook(hook) {
3
+ if (typeof hook !== "object" || hook === null) {
4
+ throw new TypeError("addCallbackHook: the hook is not an object");
5
+ }
6
+ for (const phase of ["before", "after"]) {
7
+ const method = hook[phase];
8
+ if (method !== undefined && typeof method !== "function") {
9
+ throw new TypeError(`addCallbackHook: hook.${phase} is not a function`);
10
+ }
11
+ }
12
+ }
13
+ //# sourceMappingURL=callback-hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback-hook.js","sourceRoot":"","sources":["../../src/core/callback-hook.ts"],"names":[],"mappings":"AAsBA,qHAAqH;AACrH,MAAM,UAAU,kBAAkB,CAAC,IAAmB;IAClD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;IACtE,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAU,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAa,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YACvD,MAAM,IAAI,SAAS,CAAC,yBAAyB,KAAK,oBAAoB,CAAC,CAAC;QAC5E,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -1,19 +1,9 @@
1
- /**
2
- * The code from the Babel preset uses these runtime functions. Do not use them
3
- * directly.
4
- *
5
- * Each async function becomes a generator function, and `coroutine` operates it.
6
- * Each `await` becomes a `yield`. Before each step of the generator,
7
- * `coroutine` sets the context of the async function. After the step, it sets
8
- * the previous context again. Thus, the context is correct after each `await`,
9
- * also in the same expression, and no other code gets this context.
10
- */
11
1
  /**
12
2
  * This function gives an async function that operates `generatorFunction`. The preset gives
13
3
  * this function to `@babel/plugin-transform-async-to-generator` as its
14
- * `method` option.
4
+ * `method` option, and adds `name`, the name of the async function, if it has one.
15
5
  */
16
- export declare function coroutine<T, A extends unknown[], R>(generatorFunction: (this: T, ...args: A) => Generator<unknown, R, unknown>): (this: T, ...args: A) => Promise<R>;
6
+ export declare function coroutine<T, A extends unknown[], R>(generatorFunction: (this: T, ...args: A) => Generator<unknown, R, unknown>, name?: string): (this: T, ...args: A) => Promise<R>;
17
7
  type AnyIterator = Iterator<unknown, unknown, unknown> | AsyncIterator<unknown, unknown, unknown>;
18
8
  /**
19
9
  * This function binds a generator object to the current context. The body of
@@ -1 +1 @@
1
- {"version":3,"file":"coroutine.d.ts","sourceRoot":"","sources":["../../src/core/coroutine.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,wBAAgB,SAAS,CAAC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import { applyWithHooks, store } from "./store.js";
2
2
  /**
3
3
  * The code from the Babel preset uses these runtime functions. Do not use them
4
4
  * directly.
@@ -9,25 +9,40 @@ import { store } from "./store.js";
9
9
  * the previous context again. Thus, the context is correct after each `await`,
10
10
  * also in the same expression, and no other code gets this context.
11
11
  */
12
+ /**
13
+ * This function gives the generator function to the callback hooks, with the name of the
14
+ * async function. The preset gives the name, because the generator function
15
+ * of Babel has no name. The function sets the name only when a hook operates.
16
+ */
17
+ function namedForHooks(generatorFunction, name) {
18
+ if (name !== undefined && generatorFunction.name !== name) {
19
+ Object.defineProperty(generatorFunction, "name", { value: name, configurable: true });
20
+ }
21
+ return generatorFunction;
22
+ }
12
23
  /**
13
24
  * This function gives an async function that operates `generatorFunction`. The preset gives
14
25
  * this function to `@babel/plugin-transform-async-to-generator` as its
15
- * `method` option.
26
+ * `method` option, and adds `name`, the name of the async function, if it has one.
16
27
  */
17
- export function coroutine(generatorFunction) {
28
+ export function coroutine(generatorFunction, name) {
18
29
  const { Promise: NativePromise, promiseThen, promiseResolve } = store.intrinsics;
19
30
  return function asyncFunction(...args) {
20
31
  // The context of the call. The body can change it with AsyncLocalStorage.enterWith.
21
32
  let frame = store.current;
22
33
  const generator = generatorFunction.apply(this, args);
23
34
  return new NativePromise((resolve, reject) => {
24
- const step = (resume, argument) => {
35
+ /** `resumed` is `true` for a step after an `await`. Only these steps start the hook methods. */
36
+ const step = (resume, argument, resumed) => {
25
37
  const previous = store.current;
26
38
  store.current = frame;
27
39
  let result;
28
40
  let awaited;
29
41
  try {
30
- result = resume(argument);
42
+ const hooks = resumed ? store.hooks : undefined;
43
+ result = hooks === undefined
44
+ ? resume(argument)
45
+ : applyWithHooks(hooks, namedForHooks(generatorFunction, name), "await", resume, undefined, [argument]);
31
46
  if (result.done) {
32
47
  frame = store.current;
33
48
  store.current = previous;
@@ -48,9 +63,9 @@ export function coroutine(generatorFunction) {
48
63
  };
49
64
  const next = (value) => generator.next(value);
50
65
  const throwInto = (error) => generator.throw(error);
51
- const onFulfilled = (value) => step(next, value);
52
- const onRejected = (error) => step(throwInto, error);
53
- step(next, undefined);
66
+ const onFulfilled = (value) => step(next, value, true);
67
+ const onRejected = (error) => step(throwInto, error, true);
68
+ step(next, undefined, false);
54
69
  });
55
70
  };
56
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"coroutine.js","sourceRoot":"","sources":["../../src/core/coroutine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAA4B,iBAA6E;IAC9H,MAAM,EAAE,OAAO,EAAG,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC;IAClF,OAAO,SAAS,aAAa,CAAW,GAAG,IAAQ;QAC/C,oFAAoF;QACpF,IAAI,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC;QAClC,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACtD,OAAO,IAAI,aAAa,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC5C,MAAM,IAAI,GAAG,CAAC,MAA2D,EAAE,QAAkB,EAAS,EAAE;gBACpG,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;gBAC/B,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;gBACtB,IAAI,MAAmC,CAAC;gBACxC,IAAI,OAA0B,CAAC;gBAC/B,IAAI,CAAC;oBACD,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBAC1B,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;wBACd,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;wBACtB,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC;wBACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBACtB,OAAO;oBACX,CAAC;o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M,EAAE,QAAQ,EAAG,IAAI,EAAE,YAAY,EAAG,IAAI,EAAE;KAC5E,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type CallbackHook } from "./callback-hook.js";
2
+ export type { CallbackHook } from "./callback-hook.js";
3
+ /**
4
+ * This function adds a hook. The library starts its methods before and after each
5
+ * callback that it starts. These callbacks are the callbacks of the patched
6
+ * APIs and the step of each transformed async function after an `await`. The
7
+ * function gives a function that removes the hook.
8
+ *
9
+ * A tool can use the hook to measure the time of each callback, with the
10
+ * name of the callback and the values of its context. An error in a hook goes
11
+ * to `reportError()`, and the callback operates as usual. A callback that
12
+ * starts synchronously in a hook does not start the hook methods.
13
+ */
14
+ export declare function addCallbackHook(hook: CallbackHook): () => void;
15
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +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;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAG,YAAY,GAAI,MAAM,IAAI,CAahE"}
@@ -0,0 +1,28 @@
1
+ import { assertCallbackHook } from "./callback-hook.js";
2
+ import { store } from "./store.js";
3
+ /**
4
+ * This function adds a hook. The library starts its methods before and after each
5
+ * callback that it starts. These callbacks are the callbacks of the patched
6
+ * APIs and the step of each transformed async function after an `await`. The
7
+ * function gives a function that removes the hook.
8
+ *
9
+ * A tool can use the hook to measure the time of each callback, with the
10
+ * name of the callback and the values of its context. An error in a hook goes
11
+ * to `reportError()`, and the callback operates as usual. A callback that
12
+ * starts synchronously in a hook does not start the hook methods.
13
+ */
14
+ export function addCallbackHook(hook) {
15
+ assertCallbackHook(hook);
16
+ const entry = { hook };
17
+ store.hooks = [...(store.hooks ?? []), entry];
18
+ let removed = false;
19
+ return function removeCallbackHook() {
20
+ if (removed) {
21
+ return;
22
+ }
23
+ removed = true;
24
+ const remaining = (store.hooks ?? []).filter((other) => other !== entry);
25
+ store.hooks = remaining.length === 0 ? undefined : remaining;
26
+ };
27
+ }
28
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +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;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,IAAmB;IAC/C,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACzB,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,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,OAAO,SAAS,kBAAkB;QAC9B,IAAI,OAAO,EAAE,CAAC;YACV,OAAO;QACX,CAAC;QACD,OAAO,GAAG,IAAI,CAAC;QACf,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"}
@@ -31,6 +31,23 @@ export interface ContextStore {
31
31
  /** The original function of each patched function. `Function.prototype.toString` shows the original. */
32
32
  readonly originals: WeakMap<object, object>;
33
33
  readonly intrinsics: Intrinsics;
34
+ /**
35
+ * The callback hooks (`addCallbackHook`), or `undefined` if there are none. Each change
36
+ * makes a new array. The store of an older copy of the library does not
37
+ * have this property.
38
+ */
39
+ hooks?: readonly HookEntry[] | undefined;
40
+ /** `true` while a hook operates. Callbacks that start in a hook do not start the hook methods. */
41
+ inHook?: boolean | undefined;
42
+ }
43
+ /** The methods of a callback hook. The public type is `CallbackHook` in `hooks.ts`. */
44
+ export interface HookMethods {
45
+ before?(callback: Function, source: string): void;
46
+ after?(callback: Function, source: string): void;
47
+ }
48
+ /** One registration of a hook. Each `addCallbackHook` call makes a new entry. */
49
+ export interface HookEntry {
50
+ readonly hook: HookMethods;
34
51
  }
35
52
  /** The store of this global object. */
36
53
  export declare const store: ContextStore;
@@ -42,16 +59,24 @@ export declare const NOT_FOUND: unique symbol;
42
59
  export declare function createFrame(parent: Frame, variable: object, value: unknown): Frame;
43
60
  /** This function gives the value of `variable` in `frame`, or `NOT_FOUND` if no frame sets it. */
44
61
  export declare function findValue(frame: Frame, variable: object): unknown;
62
+ /**
63
+ * This function starts `fn` between the `before` and the `after` methods of
64
+ * the hooks. The current frame must be the frame of the callback. The hooks
65
+ * get `callback` and `source`. A callback that starts in a hook does not start
66
+ * the hooks again.
67
+ */
68
+ 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;
45
69
  /**
46
70
  * This function wraps `fn`. The wrapper starts `fn` in `frame`, with the `this`
47
71
  * value and the arguments of the call. After `fn` ends, also with an error, the
48
- * previous frame is current again.
72
+ * previous frame is current again. `source` is the name of the API that got
73
+ * `fn`, for the callback hooks.
49
74
  */
50
- export declare function bindToFrame<T, A extends unknown[], R>(frame: Frame, fn: (this: T, ...args: A) => R): (this: T, ...args: A) => R;
75
+ export declare function bindToFrame<T, A extends unknown[], R>(frame: Frame, fn: (this: T, ...args: A) => R, source: string): (this: T, ...args: A) => R;
51
76
  /**
52
77
  * This function wraps a callback that gets one argument, for example a `then` callback. This
53
78
  * wrapper does not make an array of the arguments, so it is faster than
54
79
  * `bindToFrame` on the hot path.
55
80
  */
56
- export declare function bindOneArgument<T, A, R>(frame: Frame, fn: (this: T, argument: A) => R): (this: T, argument: A) => R;
81
+ export declare function bindOneArgument<T, A, R>(frame: Frame, fn: (this: T, argument: A) => R, source: string): (this: T, argument: A) => R;
57
82
  //# sourceMappingURL=store.d.ts.map
@@ -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;CACpC;AAiCD,uCAAuC;AACvC,eAAO,MAAM,KAAK,EAAG,YAAiC,CAAC;AAEvD,iGAAiG;AACjG,wBAAgB,KAAK,CA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