mutts 1.0.13 → 1.0.14
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/BROWSER_ASYNC_POLYFILL.md +79 -0
- package/README.md +2 -2
- package/dist/browser.cjs +145 -26
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +42 -9
- package/dist/browser.dev.cjs +12 -2
- package/dist/browser.dev.cjs.map +1 -1
- package/dist/browser.dev.d.ts +2 -2
- package/dist/browser.dev.esm.js +2 -2
- package/dist/browser.esm.js +137 -28
- package/dist/browser.esm.js.map +1 -1
- package/dist/chunks/{index-CAdnMJev.cjs → index-BnTNC9eC.cjs} +158 -90
- package/dist/chunks/index-BnTNC9eC.cjs.map +1 -0
- package/dist/chunks/{index-XsYTUhHx.esm.js → index-CAWVZL7P.esm.js} +156 -88
- package/dist/chunks/index-CAWVZL7P.esm.js.map +1 -0
- package/dist/chunks/node-Df_5r_WA.cjs +187 -0
- package/dist/chunks/node-Df_5r_WA.cjs.map +1 -0
- package/dist/chunks/node-DuIduHw3.esm.js +185 -0
- package/dist/chunks/node-DuIduHw3.esm.js.map +1 -0
- package/dist/chunks/{proxy-BtmPFjSr.esm.js → proxy-C2lnvvbx.esm.js} +652 -222
- package/dist/chunks/proxy-C2lnvvbx.esm.js.map +1 -0
- package/dist/chunks/{proxy-DBHj3kGK.cjs → proxy-HA_QQnd5.cjs} +662 -223
- package/dist/chunks/proxy-HA_QQnd5.cjs.map +1 -0
- package/dist/debug.cjs +37 -10
- package/dist/debug.cjs.map +1 -1
- package/dist/debug.esm.js +37 -10
- package/dist/debug.esm.js.map +1 -1
- package/dist/mutts.umd.js +4086 -3469
- package/dist/mutts.umd.js.map +1 -1
- package/dist/mutts.umd.min.js +1 -1
- package/dist/mutts.umd.min.js.map +1 -1
- package/dist/node.cjs +13 -3
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.dev.cjs +13 -3
- package/dist/node.dev.cjs.map +1 -1
- package/dist/node.dev.d.ts +2 -2
- package/dist/node.dev.esm.js +3 -3
- package/dist/node.esm.js +3 -3
- package/dist/types.d.ts +30 -15
- package/docs/ai/api-reference.md +3 -1
- package/docs/ai/manual.md +17 -5
- package/docs/reactive/advanced.md +169 -10
- package/docs/reactive/debugging.md +15 -13
- package/docs/reactive.md +2 -1
- package/package.json +12 -7
- package/dist/chunks/index-CAdnMJev.cjs.map +0 -1
- package/dist/chunks/index-XsYTUhHx.esm.js.map +0 -1
- package/dist/chunks/node-DrrphEPf.cjs +0 -98
- package/dist/chunks/node-DrrphEPf.cjs.map +0 -1
- package/dist/chunks/node-NEZvVo4M.esm.js +0 -96
- package/dist/chunks/node-NEZvVo4M.esm.js.map +0 -1
- package/dist/chunks/proxy-BtmPFjSr.esm.js.map +0 -1
- package/dist/chunks/proxy-DBHj3kGK.cjs.map +0 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_async_hooks = require('node:async_hooks');
|
|
4
|
+
var proxy = require('./proxy-HA_QQnd5.cjs');
|
|
5
|
+
|
|
6
|
+
// 1. Generic async_hooks implementation for Hooks
|
|
7
|
+
// This maintains support for 'asyncHooks.addHook' for generic use cases.
|
|
8
|
+
const contexts = new Map();
|
|
9
|
+
const activeUndoers = new Map();
|
|
10
|
+
// Helper to capture current hooks state
|
|
11
|
+
function captureRestorers() {
|
|
12
|
+
if (proxy.hooks.size === 0)
|
|
13
|
+
return [];
|
|
14
|
+
const restorers = [];
|
|
15
|
+
for (const h of proxy.hooks) {
|
|
16
|
+
const r = h();
|
|
17
|
+
if (r)
|
|
18
|
+
restorers.push(r);
|
|
19
|
+
}
|
|
20
|
+
return restorers;
|
|
21
|
+
}
|
|
22
|
+
// Manual Wrap function to handle Promise callbacks
|
|
23
|
+
function wrap(fn) {
|
|
24
|
+
if (typeof fn !== 'function')
|
|
25
|
+
return fn;
|
|
26
|
+
const restorers = captureRestorers();
|
|
27
|
+
if (restorers.length === 0)
|
|
28
|
+
return fn;
|
|
29
|
+
return function (...args) {
|
|
30
|
+
const undoers = [];
|
|
31
|
+
for (const restore of restorers) {
|
|
32
|
+
const u = restore();
|
|
33
|
+
if (u)
|
|
34
|
+
undoers.push(u);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return fn.apply(this, args);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
for (let i = undoers.length - 1; i >= 0; i--)
|
|
41
|
+
undoers[i]();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const hook = node_async_hooks.createHook({
|
|
46
|
+
init(asyncId, _type, _triggerId, _resource) {
|
|
47
|
+
// Used for native resources like Timers
|
|
48
|
+
const restorers = captureRestorers();
|
|
49
|
+
if (restorers.length > 0)
|
|
50
|
+
contexts.set(asyncId, restorers);
|
|
51
|
+
},
|
|
52
|
+
before(asyncId) {
|
|
53
|
+
const restorers = contexts.get(asyncId);
|
|
54
|
+
if (!restorers)
|
|
55
|
+
return;
|
|
56
|
+
const undoers = [];
|
|
57
|
+
for (const restore of restorers) {
|
|
58
|
+
const u = restore();
|
|
59
|
+
if (u)
|
|
60
|
+
undoers.push(u);
|
|
61
|
+
}
|
|
62
|
+
if (undoers.length > 0)
|
|
63
|
+
activeUndoers.set(asyncId, undoers);
|
|
64
|
+
},
|
|
65
|
+
after(asyncId) {
|
|
66
|
+
const undoers = activeUndoers.get(asyncId);
|
|
67
|
+
if (!undoers)
|
|
68
|
+
return;
|
|
69
|
+
for (let i = undoers.length - 1; i >= 0; i--)
|
|
70
|
+
undoers[i]();
|
|
71
|
+
activeUndoers.delete(asyncId);
|
|
72
|
+
},
|
|
73
|
+
destroy(asyncId) {
|
|
74
|
+
contexts.delete(asyncId);
|
|
75
|
+
activeUndoers.delete(asyncId);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
hook.enable();
|
|
79
|
+
// 2. Shadow Promise Implementation
|
|
80
|
+
// Ensures V8 await resumptions are visible as .then callbacks, wrapping them to restore context.
|
|
81
|
+
const OriginalPromise = globalThis.Promise;
|
|
82
|
+
const originalMethods = {
|
|
83
|
+
// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching
|
|
84
|
+
then: OriginalPromise.prototype.then,
|
|
85
|
+
catch: OriginalPromise.prototype.catch,
|
|
86
|
+
finally: OriginalPromise.prototype.finally,
|
|
87
|
+
setTimeout: globalThis.setTimeout,
|
|
88
|
+
clearTimeout: globalThis.clearTimeout,
|
|
89
|
+
setInterval: globalThis.setInterval,
|
|
90
|
+
clearInterval: globalThis.clearInterval,
|
|
91
|
+
setImmediate: globalThis.setImmediate,
|
|
92
|
+
clearImmediate: globalThis.clearImmediate,
|
|
93
|
+
};
|
|
94
|
+
const pendingTimeouts = new Set();
|
|
95
|
+
const pendingIntervals = new Set();
|
|
96
|
+
const pendingImmediates = new Set();
|
|
97
|
+
let asyncSchedulersFrozen = false;
|
|
98
|
+
function clearPendingSchedulers() {
|
|
99
|
+
for (const handle of Array.from(pendingTimeouts))
|
|
100
|
+
originalMethods.clearTimeout.call(globalThis, handle);
|
|
101
|
+
for (const handle of Array.from(pendingIntervals))
|
|
102
|
+
originalMethods.clearInterval.call(globalThis, handle);
|
|
103
|
+
for (const handle of Array.from(pendingImmediates))
|
|
104
|
+
originalMethods.clearImmediate.call(globalThis, handle);
|
|
105
|
+
pendingTimeouts.clear();
|
|
106
|
+
pendingIntervals.clear();
|
|
107
|
+
pendingImmediates.clear();
|
|
108
|
+
}
|
|
109
|
+
function freezeAsyncSchedulers() {
|
|
110
|
+
if (asyncSchedulersFrozen)
|
|
111
|
+
return;
|
|
112
|
+
asyncSchedulersFrozen = true;
|
|
113
|
+
clearPendingSchedulers();
|
|
114
|
+
}
|
|
115
|
+
function resumeAsyncSchedulers() {
|
|
116
|
+
asyncSchedulersFrozen = false;
|
|
117
|
+
}
|
|
118
|
+
function canceledTimeoutHandle() {
|
|
119
|
+
const handle = originalMethods.setTimeout.call(globalThis, () => { }, 0);
|
|
120
|
+
originalMethods.clearTimeout.call(globalThis, handle);
|
|
121
|
+
return handle;
|
|
122
|
+
}
|
|
123
|
+
function canceledIntervalHandle() {
|
|
124
|
+
const handle = originalMethods.setInterval.call(globalThis, () => { }, 0);
|
|
125
|
+
originalMethods.clearInterval.call(globalThis, handle);
|
|
126
|
+
return handle;
|
|
127
|
+
}
|
|
128
|
+
function canceledImmediateHandle() {
|
|
129
|
+
const handle = originalMethods.setImmediate.call(globalThis, () => { });
|
|
130
|
+
originalMethods.clearImmediate.call(globalThis, handle);
|
|
131
|
+
return handle;
|
|
132
|
+
}
|
|
133
|
+
proxy.onReactiveBroken(freezeAsyncSchedulers);
|
|
134
|
+
proxy.onReactiveReset(resumeAsyncSchedulers);
|
|
135
|
+
globalThis.setTimeout = ((callback, ...args) => {
|
|
136
|
+
if (asyncSchedulersFrozen)
|
|
137
|
+
return canceledTimeoutHandle();
|
|
138
|
+
const handle = originalMethods.setTimeout.call(globalThis, (...callbackArgs) => {
|
|
139
|
+
pendingTimeouts.delete(handle);
|
|
140
|
+
callback(...callbackArgs);
|
|
141
|
+
}, ...args);
|
|
142
|
+
pendingTimeouts.add(handle);
|
|
143
|
+
return handle;
|
|
144
|
+
});
|
|
145
|
+
globalThis.clearTimeout = ((handle) => {
|
|
146
|
+
pendingTimeouts.delete(handle);
|
|
147
|
+
return originalMethods.clearTimeout.call(globalThis, handle);
|
|
148
|
+
});
|
|
149
|
+
globalThis.setInterval = ((callback, ...args) => {
|
|
150
|
+
if (asyncSchedulersFrozen)
|
|
151
|
+
return canceledIntervalHandle();
|
|
152
|
+
const handle = originalMethods.setInterval.call(globalThis, (...callbackArgs) => {
|
|
153
|
+
callback(...callbackArgs);
|
|
154
|
+
}, ...args);
|
|
155
|
+
pendingIntervals.add(handle);
|
|
156
|
+
return handle;
|
|
157
|
+
});
|
|
158
|
+
globalThis.clearInterval = ((handle) => {
|
|
159
|
+
pendingIntervals.delete(handle);
|
|
160
|
+
return originalMethods.clearInterval.call(globalThis, handle);
|
|
161
|
+
});
|
|
162
|
+
globalThis.setImmediate = ((callback, ...args) => {
|
|
163
|
+
if (asyncSchedulersFrozen)
|
|
164
|
+
return canceledImmediateHandle();
|
|
165
|
+
const handle = originalMethods.setImmediate.call(globalThis, (...callbackArgs) => {
|
|
166
|
+
pendingImmediates.delete(handle);
|
|
167
|
+
callback(...callbackArgs);
|
|
168
|
+
}, ...args);
|
|
169
|
+
pendingImmediates.add(handle);
|
|
170
|
+
return handle;
|
|
171
|
+
});
|
|
172
|
+
globalThis.clearImmediate = ((handle) => {
|
|
173
|
+
pendingImmediates.delete(handle);
|
|
174
|
+
return originalMethods.clearImmediate.call(globalThis, handle);
|
|
175
|
+
});
|
|
176
|
+
// Patch prototype
|
|
177
|
+
// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching
|
|
178
|
+
OriginalPromise.prototype.then = function (onFulfilled, onRejected) {
|
|
179
|
+
return originalMethods.then.call(this, wrap(onFulfilled), wrap(onRejected));
|
|
180
|
+
};
|
|
181
|
+
OriginalPromise.prototype.catch = function (onRejected) {
|
|
182
|
+
return originalMethods.catch.call(this, wrap(onRejected));
|
|
183
|
+
};
|
|
184
|
+
OriginalPromise.prototype.finally = function (onFinally) {
|
|
185
|
+
return originalMethods.finally.call(this, wrap(onFinally));
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=node-Df_5r_WA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-Df_5r_WA.cjs","sources":["../../src/async/node.ts"],"sourcesContent":["import { createHook } from 'node:async_hooks'\nimport { onReactiveBroken, onReactiveReset } from '../reactive/effects'\nimport { hooks, type Restorer } from '.'\n\n// 1. Generic async_hooks implementation for Hooks\n// This maintains support for 'asyncHooks.addHook' for generic use cases.\n\nconst contexts = new Map<number, Restorer[]>()\nconst activeUndoers = new Map<number, (() => void)[]>()\n\n// Helper to capture current hooks state\nfunction captureRestorers() {\n\tif (hooks.size === 0) return []\n\tconst restorers: Restorer[] = []\n\tfor (const h of hooks) {\n\t\tconst r = h()\n\t\tif (r) restorers.push(r)\n\t}\n\treturn restorers\n}\n\n// Manual Wrap function to handle Promise callbacks\nfunction wrap<Args extends any[], R>(fn: ((...args: Args) => R) | null | undefined) {\n\tif (typeof fn !== 'function') return fn\n\tconst restorers = captureRestorers()\n\tif (restorers.length === 0) return fn\n\n\treturn function (this: any, ...args: Args) {\n\t\tconst undoers: (() => void)[] = []\n\t\tfor (const restore of restorers) {\n\t\t\tconst u = restore()\n\t\t\tif (u) undoers.push(u)\n\t\t}\n\t\ttry {\n\t\t\treturn fn.apply(this, args)\n\t\t} finally {\n\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t}\n\t}\n}\n\nconst hook = createHook({\n\tinit(asyncId, _type, _triggerId, _resource) {\n\t\t// Used for native resources like Timers\n\t\tconst restorers = captureRestorers()\n\t\tif (restorers.length > 0) contexts.set(asyncId, restorers)\n\t},\n\tbefore(asyncId) {\n\t\tconst restorers = contexts.get(asyncId)\n\t\tif (!restorers) return\n\t\tconst undoers: (() => void)[] = []\n\t\tfor (const restore of restorers) {\n\t\t\tconst u = restore()\n\t\t\tif (u) undoers.push(u)\n\t\t}\n\t\tif (undoers.length > 0) activeUndoers.set(asyncId, undoers)\n\t},\n\tafter(asyncId) {\n\t\tconst undoers = activeUndoers.get(asyncId)\n\t\tif (!undoers) return\n\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\tactiveUndoers.delete(asyncId)\n\t},\n\tdestroy(asyncId) {\n\t\tcontexts.delete(asyncId)\n\t\tactiveUndoers.delete(asyncId)\n\t},\n})\nhook.enable()\n\n// 2. Shadow Promise Implementation\n// Ensures V8 await resumptions are visible as .then callbacks, wrapping them to restore context.\n\nconst OriginalPromise = globalThis.Promise\nconst originalMethods = {\n\t// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\n\tthen: OriginalPromise.prototype.then,\n\tcatch: OriginalPromise.prototype.catch,\n\tfinally: OriginalPromise.prototype.finally,\n\tresolve: OriginalPromise.resolve,\n\treject: OriginalPromise.reject,\n\tall: OriginalPromise.all,\n\tsetTimeout: globalThis.setTimeout,\n\tclearTimeout: globalThis.clearTimeout,\n\tsetInterval: globalThis.setInterval,\n\tclearInterval: globalThis.clearInterval,\n\tsetImmediate: globalThis.setImmediate,\n\tclearImmediate: globalThis.clearImmediate,\n}\n\nconst pendingTimeouts = new Set<unknown>()\nconst pendingIntervals = new Set<unknown>()\nconst pendingImmediates = new Set<unknown>()\nlet asyncSchedulersFrozen = false\n\nfunction clearPendingSchedulers() {\n\tfor (const handle of Array.from(pendingTimeouts))\n\t\toriginalMethods.clearTimeout.call(globalThis, handle)\n\tfor (const handle of Array.from(pendingIntervals))\n\t\toriginalMethods.clearInterval.call(globalThis, handle)\n\tfor (const handle of Array.from(pendingImmediates))\n\t\toriginalMethods.clearImmediate.call(globalThis, handle)\n\tpendingTimeouts.clear()\n\tpendingIntervals.clear()\n\tpendingImmediates.clear()\n}\n\nfunction freezeAsyncSchedulers() {\n\tif (asyncSchedulersFrozen) return\n\tasyncSchedulersFrozen = true\n\tclearPendingSchedulers()\n}\n\nfunction resumeAsyncSchedulers() {\n\tasyncSchedulersFrozen = false\n}\n\nfunction canceledTimeoutHandle() {\n\tconst handle = originalMethods.setTimeout.call(globalThis, () => {}, 0)\n\toriginalMethods.clearTimeout.call(globalThis, handle)\n\treturn handle\n}\n\nfunction canceledIntervalHandle() {\n\tconst handle = originalMethods.setInterval.call(globalThis, () => {}, 0)\n\toriginalMethods.clearInterval.call(globalThis, handle)\n\treturn handle\n}\n\nfunction canceledImmediateHandle() {\n\tconst handle = originalMethods.setImmediate.call(globalThis, () => {})\n\toriginalMethods.clearImmediate.call(globalThis, handle)\n\treturn handle\n}\n\nonReactiveBroken(freezeAsyncSchedulers)\nonReactiveReset(resumeAsyncSchedulers)\n\nglobalThis.setTimeout = ((callback: Function, ...args: any[]) => {\n\tif (asyncSchedulersFrozen) return canceledTimeoutHandle()\n\tconst handle = originalMethods.setTimeout.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\tpendingTimeouts.delete(handle)\n\t\t\tcallback(...callbackArgs)\n\t\t},\n\t\t...args\n\t)\n\tpendingTimeouts.add(handle)\n\treturn handle\n}) as typeof globalThis.setTimeout\n\nglobalThis.clearTimeout = ((handle?: unknown) => {\n\tpendingTimeouts.delete(handle)\n\treturn originalMethods.clearTimeout.call(globalThis, handle)\n}) as typeof globalThis.clearTimeout\n\nglobalThis.setInterval = ((callback: Function, ...args: any[]) => {\n\tif (asyncSchedulersFrozen) return canceledIntervalHandle()\n\tconst handle = originalMethods.setInterval.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\tcallback(...callbackArgs)\n\t\t},\n\t\t...args\n\t)\n\tpendingIntervals.add(handle)\n\treturn handle\n}) as typeof globalThis.setInterval\n\nglobalThis.clearInterval = ((handle?: unknown) => {\n\tpendingIntervals.delete(handle)\n\treturn originalMethods.clearInterval.call(globalThis, handle)\n}) as typeof globalThis.clearInterval\n\nglobalThis.setImmediate = ((callback: Function, ...args: any[]) => {\n\tif (asyncSchedulersFrozen) return canceledImmediateHandle()\n\tconst handle = originalMethods.setImmediate.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\tpendingImmediates.delete(handle)\n\t\t\tcallback(...callbackArgs)\n\t\t},\n\t\t...args\n\t)\n\tpendingImmediates.add(handle)\n\treturn handle\n}) as typeof globalThis.setImmediate\n\nglobalThis.clearImmediate = ((handle?: unknown) => {\n\tpendingImmediates.delete(handle)\n\treturn originalMethods.clearImmediate.call(globalThis, handle)\n}) as typeof globalThis.clearImmediate\n\n// Patch prototype\n// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\nOriginalPromise.prototype.then = function (onFulfilled, onRejected) {\n\treturn originalMethods.then.call(this, wrap(onFulfilled), wrap(onRejected))\n} as any\nOriginalPromise.prototype.catch = function (onRejected) {\n\treturn originalMethods.catch.call(this, wrap(onRejected))\n} as any\nOriginalPromise.prototype.finally = function (onFinally) {\n\treturn originalMethods.finally.call(this, wrap(onFinally))\n} as any\n"],"names":["hooks","createHook","onReactiveBroken","onReactiveReset"],"mappings":";;;;;AAIA;AACA;AAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAsB;AAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,EAA0B;AAEvD;AACA,SAAS,gBAAgB,GAAA;AACxB,IAAA,IAAIA,WAAK,CAAC,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE;IAC/B,MAAM,SAAS,GAAe,EAAE;AAChC,IAAA,KAAK,MAAM,CAAC,IAAIA,WAAK,EAAE;AACtB,QAAA,MAAM,CAAC,GAAG,CAAC,EAAE;AACb,QAAA,IAAI,CAAC;AAAE,YAAA,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACzB;AACA,IAAA,OAAO,SAAS;AACjB;AAEA;AACA,SAAS,IAAI,CAAwB,EAA6C,EAAA;IACjF,IAAI,OAAO,EAAE,KAAK,UAAU;AAAE,QAAA,OAAO,EAAE;AACvC,IAAA,MAAM,SAAS,GAAG,gBAAgB,EAAE;AACpC,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE;IAErC,OAAO,UAAqB,GAAG,IAAU,EAAA;QACxC,MAAM,OAAO,GAAmB,EAAE;AAClC,QAAA,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE;AAChC,YAAA,MAAM,CAAC,GAAG,OAAO,EAAE;AACnB,YAAA,IAAI,CAAC;AAAE,gBAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvB;AACA,QAAA,IAAI;YACH,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;QAC5B;gBAAU;AACT,YAAA,KAAK,IAAI,CAAC,GAAG,O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hooks implementation for Hooks
|
|
5
|
+
// This maintains support for 'asyncHooks.addHook' for generic use cases.
|
|
6
|
+
const contexts = new Map();
|
|
7
|
+
const activeUndoers = new Map();
|
|
8
|
+
// Helper to capture current hooks state
|
|
9
|
+
function captureRestorers() {
|
|
10
|
+
if (hooks.size === 0)
|
|
11
|
+
return [];
|
|
12
|
+
const restorers = [];
|
|
13
|
+
for (const h of hooks) {
|
|
14
|
+
const r = h();
|
|
15
|
+
if (r)
|
|
16
|
+
restorers.push(r);
|
|
17
|
+
}
|
|
18
|
+
return restorers;
|
|
19
|
+
}
|
|
20
|
+
// Manual Wrap function to handle Promise callbacks
|
|
21
|
+
function wrap(fn) {
|
|
22
|
+
if (typeof fn !== 'function')
|
|
23
|
+
return fn;
|
|
24
|
+
const restorers = captureRestorers();
|
|
25
|
+
if (restorers.length === 0)
|
|
26
|
+
return fn;
|
|
27
|
+
return function (...args) {
|
|
28
|
+
const undoers = [];
|
|
29
|
+
for (const restore of restorers) {
|
|
30
|
+
const u = restore();
|
|
31
|
+
if (u)
|
|
32
|
+
undoers.push(u);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return fn.apply(this, args);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
for (let i = undoers.length - 1; i >= 0; i--)
|
|
39
|
+
undoers[i]();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const hook = createHook({
|
|
44
|
+
init(asyncId, _type, _triggerId, _resource) {
|
|
45
|
+
// Used for native resources like Timers
|
|
46
|
+
const restorers = captureRestorers();
|
|
47
|
+
if (restorers.length > 0)
|
|
48
|
+
contexts.set(asyncId, restorers);
|
|
49
|
+
},
|
|
50
|
+
before(asyncId) {
|
|
51
|
+
const restorers = contexts.get(asyncId);
|
|
52
|
+
if (!restorers)
|
|
53
|
+
return;
|
|
54
|
+
const undoers = [];
|
|
55
|
+
for (const restore of restorers) {
|
|
56
|
+
const u = restore();
|
|
57
|
+
if (u)
|
|
58
|
+
undoers.push(u);
|
|
59
|
+
}
|
|
60
|
+
if (undoers.length > 0)
|
|
61
|
+
activeUndoers.set(asyncId, undoers);
|
|
62
|
+
},
|
|
63
|
+
after(asyncId) {
|
|
64
|
+
const undoers = activeUndoers.get(asyncId);
|
|
65
|
+
if (!undoers)
|
|
66
|
+
return;
|
|
67
|
+
for (let i = undoers.length - 1; i >= 0; i--)
|
|
68
|
+
undoers[i]();
|
|
69
|
+
activeUndoers.delete(asyncId);
|
|
70
|
+
},
|
|
71
|
+
destroy(asyncId) {
|
|
72
|
+
contexts.delete(asyncId);
|
|
73
|
+
activeUndoers.delete(asyncId);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
hook.enable();
|
|
77
|
+
// 2. Shadow Promise Implementation
|
|
78
|
+
// Ensures V8 await resumptions are visible as .then callbacks, wrapping them to restore context.
|
|
79
|
+
const OriginalPromise = globalThis.Promise;
|
|
80
|
+
const originalMethods = {
|
|
81
|
+
// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching
|
|
82
|
+
then: OriginalPromise.prototype.then,
|
|
83
|
+
catch: OriginalPromise.prototype.catch,
|
|
84
|
+
finally: OriginalPromise.prototype.finally,
|
|
85
|
+
setTimeout: globalThis.setTimeout,
|
|
86
|
+
clearTimeout: globalThis.clearTimeout,
|
|
87
|
+
setInterval: globalThis.setInterval,
|
|
88
|
+
clearInterval: globalThis.clearInterval,
|
|
89
|
+
setImmediate: globalThis.setImmediate,
|
|
90
|
+
clearImmediate: globalThis.clearImmediate,
|
|
91
|
+
};
|
|
92
|
+
const pendingTimeouts = new Set();
|
|
93
|
+
const pendingIntervals = new Set();
|
|
94
|
+
const pendingImmediates = new Set();
|
|
95
|
+
let asyncSchedulersFrozen = false;
|
|
96
|
+
function clearPendingSchedulers() {
|
|
97
|
+
for (const handle of Array.from(pendingTimeouts))
|
|
98
|
+
originalMethods.clearTimeout.call(globalThis, handle);
|
|
99
|
+
for (const handle of Array.from(pendingIntervals))
|
|
100
|
+
originalMethods.clearInterval.call(globalThis, handle);
|
|
101
|
+
for (const handle of Array.from(pendingImmediates))
|
|
102
|
+
originalMethods.clearImmediate.call(globalThis, handle);
|
|
103
|
+
pendingTimeouts.clear();
|
|
104
|
+
pendingIntervals.clear();
|
|
105
|
+
pendingImmediates.clear();
|
|
106
|
+
}
|
|
107
|
+
function freezeAsyncSchedulers() {
|
|
108
|
+
if (asyncSchedulersFrozen)
|
|
109
|
+
return;
|
|
110
|
+
asyncSchedulersFrozen = true;
|
|
111
|
+
clearPendingSchedulers();
|
|
112
|
+
}
|
|
113
|
+
function resumeAsyncSchedulers() {
|
|
114
|
+
asyncSchedulersFrozen = false;
|
|
115
|
+
}
|
|
116
|
+
function canceledTimeoutHandle() {
|
|
117
|
+
const handle = originalMethods.setTimeout.call(globalThis, () => { }, 0);
|
|
118
|
+
originalMethods.clearTimeout.call(globalThis, handle);
|
|
119
|
+
return handle;
|
|
120
|
+
}
|
|
121
|
+
function canceledIntervalHandle() {
|
|
122
|
+
const handle = originalMethods.setInterval.call(globalThis, () => { }, 0);
|
|
123
|
+
originalMethods.clearInterval.call(globalThis, handle);
|
|
124
|
+
return handle;
|
|
125
|
+
}
|
|
126
|
+
function canceledImmediateHandle() {
|
|
127
|
+
const handle = originalMethods.setImmediate.call(globalThis, () => { });
|
|
128
|
+
originalMethods.clearImmediate.call(globalThis, handle);
|
|
129
|
+
return handle;
|
|
130
|
+
}
|
|
131
|
+
onReactiveBroken(freezeAsyncSchedulers);
|
|
132
|
+
onReactiveReset(resumeAsyncSchedulers);
|
|
133
|
+
globalThis.setTimeout = ((callback, ...args) => {
|
|
134
|
+
if (asyncSchedulersFrozen)
|
|
135
|
+
return canceledTimeoutHandle();
|
|
136
|
+
const handle = originalMethods.setTimeout.call(globalThis, (...callbackArgs) => {
|
|
137
|
+
pendingTimeouts.delete(handle);
|
|
138
|
+
callback(...callbackArgs);
|
|
139
|
+
}, ...args);
|
|
140
|
+
pendingTimeouts.add(handle);
|
|
141
|
+
return handle;
|
|
142
|
+
});
|
|
143
|
+
globalThis.clearTimeout = ((handle) => {
|
|
144
|
+
pendingTimeouts.delete(handle);
|
|
145
|
+
return originalMethods.clearTimeout.call(globalThis, handle);
|
|
146
|
+
});
|
|
147
|
+
globalThis.setInterval = ((callback, ...args) => {
|
|
148
|
+
if (asyncSchedulersFrozen)
|
|
149
|
+
return canceledIntervalHandle();
|
|
150
|
+
const handle = originalMethods.setInterval.call(globalThis, (...callbackArgs) => {
|
|
151
|
+
callback(...callbackArgs);
|
|
152
|
+
}, ...args);
|
|
153
|
+
pendingIntervals.add(handle);
|
|
154
|
+
return handle;
|
|
155
|
+
});
|
|
156
|
+
globalThis.clearInterval = ((handle) => {
|
|
157
|
+
pendingIntervals.delete(handle);
|
|
158
|
+
return originalMethods.clearInterval.call(globalThis, handle);
|
|
159
|
+
});
|
|
160
|
+
globalThis.setImmediate = ((callback, ...args) => {
|
|
161
|
+
if (asyncSchedulersFrozen)
|
|
162
|
+
return canceledImmediateHandle();
|
|
163
|
+
const handle = originalMethods.setImmediate.call(globalThis, (...callbackArgs) => {
|
|
164
|
+
pendingImmediates.delete(handle);
|
|
165
|
+
callback(...callbackArgs);
|
|
166
|
+
}, ...args);
|
|
167
|
+
pendingImmediates.add(handle);
|
|
168
|
+
return handle;
|
|
169
|
+
});
|
|
170
|
+
globalThis.clearImmediate = ((handle) => {
|
|
171
|
+
pendingImmediates.delete(handle);
|
|
172
|
+
return originalMethods.clearImmediate.call(globalThis, handle);
|
|
173
|
+
});
|
|
174
|
+
// Patch prototype
|
|
175
|
+
// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching
|
|
176
|
+
OriginalPromise.prototype.then = function (onFulfilled, onRejected) {
|
|
177
|
+
return originalMethods.then.call(this, wrap(onFulfilled), wrap(onRejected));
|
|
178
|
+
};
|
|
179
|
+
OriginalPromise.prototype.catch = function (onRejected) {
|
|
180
|
+
return originalMethods.catch.call(this, wrap(onRejected));
|
|
181
|
+
};
|
|
182
|
+
OriginalPromise.prototype.finally = function (onFinally) {
|
|
183
|
+
return originalMethods.finally.call(this, wrap(onFinally));
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=node-DuIduHw3.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-DuIduHw3.esm.js","sources":["../../src/async/node.ts"],"sourcesContent":["import { createHook } from 'node:async_hooks'\nimport { onReactiveBroken, onReactiveReset } from '../reactive/effects'\nimport { hooks, type Restorer } from '.'\n\n// 1. Generic async_hooks implementation for Hooks\n// This maintains support for 'asyncHooks.addHook' for generic use cases.\n\nconst contexts = new Map<number, Restorer[]>()\nconst activeUndoers = new Map<number, (() => void)[]>()\n\n// Helper to capture current hooks state\nfunction captureRestorers() {\n\tif (hooks.size === 0) return []\n\tconst restorers: Restorer[] = []\n\tfor (const h of hooks) {\n\t\tconst r = h()\n\t\tif (r) restorers.push(r)\n\t}\n\treturn restorers\n}\n\n// Manual Wrap function to handle Promise callbacks\nfunction wrap<Args extends any[], R>(fn: ((...args: Args) => R) | null | undefined) {\n\tif (typeof fn !== 'function') return fn\n\tconst restorers = captureRestorers()\n\tif (restorers.length === 0) return fn\n\n\treturn function (this: any, ...args: Args) {\n\t\tconst undoers: (() => void)[] = []\n\t\tfor (const restore of restorers) {\n\t\t\tconst u = restore()\n\t\t\tif (u) undoers.push(u)\n\t\t}\n\t\ttry {\n\t\t\treturn fn.apply(this, args)\n\t\t} finally {\n\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t}\n\t}\n}\n\nconst hook = createHook({\n\tinit(asyncId, _type, _triggerId, _resource) {\n\t\t// Used for native resources like Timers\n\t\tconst restorers = captureRestorers()\n\t\tif (restorers.length > 0) contexts.set(asyncId, restorers)\n\t},\n\tbefore(asyncId) {\n\t\tconst restorers = contexts.get(asyncId)\n\t\tif (!restorers) return\n\t\tconst undoers: (() => void)[] = []\n\t\tfor (const restore of restorers) {\n\t\t\tconst u = restore()\n\t\t\tif (u) undoers.push(u)\n\t\t}\n\t\tif (undoers.length > 0) activeUndoers.set(asyncId, undoers)\n\t},\n\tafter(asyncId) {\n\t\tconst undoers = activeUndoers.get(asyncId)\n\t\tif (!undoers) return\n\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\tactiveUndoers.delete(asyncId)\n\t},\n\tdestroy(asyncId) {\n\t\tcontexts.delete(asyncId)\n\t\tactiveUndoers.delete(asyncId)\n\t},\n})\nhook.enable()\n\n// 2. Shadow Promise Implementation\n// Ensures V8 await resumptions are visible as .then callbacks, wrapping them to restore context.\n\nconst OriginalPromise = globalThis.Promise\nconst originalMethods = {\n\t// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\n\tthen: OriginalPromise.prototype.then,\n\tcatch: OriginalPromise.prototype.catch,\n\tfinally: OriginalPromise.prototype.finally,\n\tresolve: OriginalPromise.resolve,\n\treject: OriginalPromise.reject,\n\tall: OriginalPromise.all,\n\tsetTimeout: globalThis.setTimeout,\n\tclearTimeout: globalThis.clearTimeout,\n\tsetInterval: globalThis.setInterval,\n\tclearInterval: globalThis.clearInterval,\n\tsetImmediate: globalThis.setImmediate,\n\tclearImmediate: globalThis.clearImmediate,\n}\n\nconst pendingTimeouts = new Set<unknown>()\nconst pendingIntervals = new Set<unknown>()\nconst pendingImmediates = new Set<unknown>()\nlet asyncSchedulersFrozen = false\n\nfunction clearPendingSchedulers() {\n\tfor (const handle of Array.from(pendingTimeouts))\n\t\toriginalMethods.clearTimeout.call(globalThis, handle)\n\tfor (const handle of Array.from(pendingIntervals))\n\t\toriginalMethods.clearInterval.call(globalThis, handle)\n\tfor (const handle of Array.from(pendingImmediates))\n\t\toriginalMethods.clearImmediate.call(globalThis, handle)\n\tpendingTimeouts.clear()\n\tpendingIntervals.clear()\n\tpendingImmediates.clear()\n}\n\nfunction freezeAsyncSchedulers() {\n\tif (asyncSchedulersFrozen) return\n\tasyncSchedulersFrozen = true\n\tclearPendingSchedulers()\n}\n\nfunction resumeAsyncSchedulers() {\n\tasyncSchedulersFrozen = false\n}\n\nfunction canceledTimeoutHandle() {\n\tconst handle = originalMethods.setTimeout.call(globalThis, () => {}, 0)\n\toriginalMethods.clearTimeout.call(globalThis, handle)\n\treturn handle\n}\n\nfunction canceledIntervalHandle() {\n\tconst handle = originalMethods.setInterval.call(globalThis, () => {}, 0)\n\toriginalMethods.clearInterval.call(globalThis, handle)\n\treturn handle\n}\n\nfunction canceledImmediateHandle() {\n\tconst handle = originalMethods.setImmediate.call(globalThis, () => {})\n\toriginalMethods.clearImmediate.call(globalThis, handle)\n\treturn handle\n}\n\nonReactiveBroken(freezeAsyncSchedulers)\nonReactiveReset(resumeAsyncSchedulers)\n\nglobalThis.setTimeout = ((callback: Function, ...args: any[]) => {\n\tif (asyncSchedulersFrozen) return canceledTimeoutHandle()\n\tconst handle = originalMethods.setTimeout.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\tpendingTimeouts.delete(handle)\n\t\t\tcallback(...callbackArgs)\n\t\t},\n\t\t...args\n\t)\n\tpendingTimeouts.add(handle)\n\treturn handle\n}) as typeof globalThis.setTimeout\n\nglobalThis.clearTimeout = ((handle?: unknown) => {\n\tpendingTimeouts.delete(handle)\n\treturn originalMethods.clearTimeout.call(globalThis, handle)\n}) as typeof globalThis.clearTimeout\n\nglobalThis.setInterval = ((callback: Function, ...args: any[]) => {\n\tif (asyncSchedulersFrozen) return canceledIntervalHandle()\n\tconst handle = originalMethods.setInterval.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\tcallback(...callbackArgs)\n\t\t},\n\t\t...args\n\t)\n\tpendingIntervals.add(handle)\n\treturn handle\n}) as typeof globalThis.setInterval\n\nglobalThis.clearInterval = ((handle?: unknown) => {\n\tpendingIntervals.delete(handle)\n\treturn originalMethods.clearInterval.call(globalThis, handle)\n}) as typeof globalThis.clearInterval\n\nglobalThis.setImmediate = ((callback: Function, ...args: any[]) => {\n\tif (asyncSchedulersFrozen) return canceledImmediateHandle()\n\tconst handle = originalMethods.setImmediate.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\tpendingImmediates.delete(handle)\n\t\t\tcallback(...callbackArgs)\n\t\t},\n\t\t...args\n\t)\n\tpendingImmediates.add(handle)\n\treturn handle\n}) as typeof globalThis.setImmediate\n\nglobalThis.clearImmediate = ((handle?: unknown) => {\n\tpendingImmediates.delete(handle)\n\treturn originalMethods.clearImmediate.call(globalThis, handle)\n}) as typeof globalThis.clearImmediate\n\n// Patch prototype\n// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\nOriginalPromise.prototype.then = function (onFulfilled, onRejected) {\n\treturn originalMethods.then.call(this, wrap(onFulfilled), wrap(onRejected))\n} as any\nOriginalPromise.prototype.catch = function (onRejected) {\n\treturn originalMethods.catch.call(this, wrap(onRejected))\n} as any\nOriginalPromise.prototype.finally = function (onFinally) {\n\treturn originalMethods.finally.call(this, wrap(onFinally))\n} as any\n"],"names":[],"mappings":";;;AAIA;AACA;AAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAsB;AAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,EAA0B;AAEvD;AACA,SAAS,gBAAgB,GAAA;AACxB,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE;IAC/B,MAAM,SAAS,GAAe,EAAE;AAChC,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AACtB,QAAA,MAAM,CAAC,GAAG,CAAC,EAAE;AACb,QAAA,IAAI,CAAC;AAAE,YAAA,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACzB;AACA,IAAA,OAAO,SAAS;AACjB;AAEA;AACA,SAAS,IAAI,CAAwB,EAA6C,EAAA;IACjF,IAAI,OAAO,EAAE,KAAK,UAAU;AAAE,QAAA,OAAO,EAAE;AACvC,IAAA,MAAM,SAAS,GAAG,g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