mutts 1.0.8 → 1.0.9

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 (226) hide show
  1. package/README.md +19 -2
  2. package/dist/browser.cjs +1030 -4406
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.ts +310 -573
  5. package/dist/browser.esm.js +18 -24
  6. package/dist/browser.esm.js.map +1 -1
  7. package/dist/chunks/{async-browser-CA0jPWIi.cjs → async-browser-lvzLOCgk.cjs} +17 -24
  8. package/dist/chunks/async-browser-lvzLOCgk.cjs.map +1 -0
  9. package/dist/chunks/{async-core-UqHzvJ-S.cjs → async-core-CRLKP3l-.cjs} +8 -4
  10. package/dist/chunks/async-core-CRLKP3l-.cjs.map +1 -0
  11. package/dist/chunks/{async-node-BYHuGTni.cjs → async-node-C3DeIb0y.cjs} +5 -12
  12. package/dist/chunks/async-node-C3DeIb0y.cjs.map +1 -0
  13. package/dist/chunks/index-2vea86wD.esm.js +3011 -0
  14. package/dist/chunks/index-2vea86wD.esm.js.map +1 -0
  15. package/dist/chunks/index-CtA2AWl3.esm.js +4376 -0
  16. package/dist/chunks/index-CtA2AWl3.esm.js.map +1 -0
  17. package/dist/chunks/index-VTO-b2vR.cjs +4461 -0
  18. package/dist/chunks/index-VTO-b2vR.cjs.map +1 -0
  19. package/dist/{reactive → debug}/debug.d.ts +19 -8
  20. package/dist/debug/debug.d.ts.map +1 -0
  21. package/dist/debug/index.d.ts +4 -0
  22. package/dist/debug/index.d.ts.map +1 -0
  23. package/dist/debug/lineage-panel.d.ts +5 -0
  24. package/dist/debug/lineage-panel.d.ts.map +1 -0
  25. package/dist/debug/lineage.d.ts +79 -0
  26. package/dist/debug/lineage.d.ts.map +1 -0
  27. package/dist/debug.cjs +35 -0
  28. package/dist/debug.cjs.map +1 -0
  29. package/dist/debug.d.ts +209 -0
  30. package/dist/debug.esm.js +2 -0
  31. package/dist/debug.esm.js.map +1 -0
  32. package/dist/index.d.ts +1 -13
  33. package/dist/mutts.umd.js +1 -1
  34. package/dist/mutts.umd.js.map +1 -1
  35. package/dist/mutts.umd.min.js +1 -1
  36. package/dist/mutts.umd.min.js.map +1 -1
  37. package/dist/node.cjs +65 -63
  38. package/dist/node.cjs.map +1 -1
  39. package/dist/node.d.ts +2 -1
  40. package/dist/node.esm.js +5 -11
  41. package/dist/node.esm.js.map +1 -1
  42. package/dist/{async → src/async}/browser.d.ts.map +1 -1
  43. package/dist/{async → src/async}/index.d.ts +2 -1
  44. package/dist/src/async/index.d.ts.map +1 -0
  45. package/dist/{async → src/async}/node.d.ts.map +1 -1
  46. package/dist/src/decorator.d.ts.map +1 -0
  47. package/dist/src/destroyable.d.ts.map +1 -0
  48. package/dist/src/entry-browser.d.ts.map +1 -0
  49. package/dist/src/entry-node.d.ts.map +1 -0
  50. package/dist/src/eventful.d.ts +20 -0
  51. package/dist/src/eventful.d.ts.map +1 -0
  52. package/dist/src/flavored.d.ts +33 -0
  53. package/dist/src/flavored.d.ts.map +1 -0
  54. package/dist/src/index.d.ts +14 -0
  55. package/dist/src/index.d.ts.map +1 -0
  56. package/dist/src/indexable.d.ts.map +1 -0
  57. package/dist/{introspection.d.ts → src/introspection.d.ts} +1 -1
  58. package/dist/src/introspection.d.ts.map +1 -0
  59. package/dist/src/iterableWeak.d.ts.map +1 -0
  60. package/dist/src/mixins.d.ts.map +1 -0
  61. package/dist/src/promiseChain.d.ts.map +1 -0
  62. package/dist/{reactive → src/reactive}/array.d.ts +9 -10
  63. package/dist/src/reactive/array.d.ts.map +1 -0
  64. package/dist/src/reactive/buffer.d.ts +120 -0
  65. package/dist/src/reactive/buffer.d.ts.map +1 -0
  66. package/dist/{reactive → src/reactive}/change.d.ts +2 -2
  67. package/dist/src/reactive/change.d.ts.map +1 -0
  68. package/dist/src/reactive/deep-touch.d.ts.map +1 -0
  69. package/dist/{reactive → src/reactive}/deep-watch-state.d.ts +3 -3
  70. package/dist/src/reactive/deep-watch-state.d.ts.map +1 -0
  71. package/dist/{reactive → src/reactive}/deep-watch.d.ts +2 -1
  72. package/dist/src/reactive/deep-watch.d.ts.map +1 -0
  73. package/dist/src/reactive/describe.d.ts +12 -0
  74. package/dist/src/reactive/describe.d.ts.map +1 -0
  75. package/dist/src/reactive/effect-context.d.ts +34 -0
  76. package/dist/src/reactive/effect-context.d.ts.map +1 -0
  77. package/dist/{reactive → src/reactive}/effects.d.ts +31 -18
  78. package/dist/src/reactive/effects.d.ts.map +1 -0
  79. package/dist/src/reactive/index.d.ts +19 -0
  80. package/dist/src/reactive/index.d.ts.map +1 -0
  81. package/dist/{reactive → src/reactive}/map.d.ts +0 -2
  82. package/dist/src/reactive/map.d.ts.map +1 -0
  83. package/dist/src/reactive/memoize.d.ts +28 -0
  84. package/dist/src/reactive/memoize.d.ts.map +1 -0
  85. package/dist/src/reactive/non-reactive-state.d.ts.map +1 -0
  86. package/dist/src/reactive/non-reactive.d.ts.map +1 -0
  87. package/dist/{reactive → src/reactive}/project.d.ts +1 -2
  88. package/dist/src/reactive/project.d.ts.map +1 -0
  89. package/dist/src/reactive/proxy-state.d.ts.map +1 -0
  90. package/dist/src/reactive/proxy.d.ts.map +1 -0
  91. package/dist/{reactive → src/reactive}/record.d.ts +2 -3
  92. package/dist/src/reactive/record.d.ts.map +1 -0
  93. package/dist/{reactive → src/reactive}/register.d.ts +61 -0
  94. package/dist/src/reactive/register.d.ts.map +1 -0
  95. package/dist/{reactive → src/reactive}/registry.d.ts +6 -5
  96. package/dist/src/reactive/registry.d.ts.map +1 -0
  97. package/dist/{reactive → src/reactive}/set.d.ts +0 -2
  98. package/dist/src/reactive/set.d.ts.map +1 -0
  99. package/dist/src/reactive/tracking.d.ts.map +1 -0
  100. package/dist/{reactive → src/reactive}/types.d.ts +69 -21
  101. package/dist/src/reactive/types.d.ts.map +1 -0
  102. package/dist/{reactive/interface.d.ts → src/reactive/watch.d.ts} +7 -23
  103. package/dist/src/reactive/watch.d.ts.map +1 -0
  104. package/dist/{std-decorators.d.ts → src/std-decorators.d.ts} +1 -6
  105. package/dist/src/std-decorators.d.ts.map +1 -0
  106. package/dist/src/utils.d.ts.map +1 -0
  107. package/dist/{zone.d.ts → src/zone.d.ts} +2 -2
  108. package/dist/src/zone.d.ts.map +1 -0
  109. package/dist/types-DaHFfhlN.d.ts +414 -0
  110. package/docs/ai/api-reference.md +1 -1
  111. package/docs/ai/manual.md +443 -17
  112. package/docs/events.md +57 -2
  113. package/docs/flavored.md +210 -0
  114. package/docs/reactive/advanced.md +2 -3
  115. package/docs/reactive/attend.md +143 -0
  116. package/docs/reactive/collections.md +55 -0
  117. package/docs/reactive/core.md +120 -4
  118. package/docs/reactive/debugging.md +8 -10
  119. package/docs/reactive/describe.md +85 -0
  120. package/docs/reactive/error-handling.md +121 -0
  121. package/docs/reactive/project.md +1 -1
  122. package/docs/reactive/scan.md +215 -0
  123. package/docs/reactive.md +2 -0
  124. package/docs/std-decorators.md +102 -51
  125. package/docs/zone.md +3 -7
  126. package/package.json +6 -1
  127. package/src/async/browser.ts +110 -106
  128. package/src/async/index.ts +15 -11
  129. package/src/async/node.ts +5 -17
  130. package/src/eventful.ts +82 -49
  131. package/src/flavored.ts +106 -0
  132. package/src/index.d.ts +12 -12
  133. package/src/index.ts +2 -2
  134. package/src/introspection.ts +1 -1
  135. package/src/reactive/array.ts +29 -36
  136. package/src/reactive/buffer.ts +187 -27
  137. package/src/reactive/change.ts +16 -23
  138. package/src/reactive/deep-touch.ts +19 -14
  139. package/src/reactive/deep-watch-state.ts +3 -3
  140. package/src/reactive/deep-watch.ts +7 -4
  141. package/src/reactive/describe.ts +39 -0
  142. package/src/reactive/effect-context.ts +69 -4
  143. package/src/reactive/effects.ts +445 -393
  144. package/src/reactive/index.ts +12 -15
  145. package/src/reactive/map.ts +9 -25
  146. package/src/reactive/memoize.ts +26 -3
  147. package/src/reactive/project.md +107 -0
  148. package/src/reactive/project.ts +48 -71
  149. package/src/reactive/proxy.ts +21 -3
  150. package/src/reactive/record.ts +30 -45
  151. package/src/reactive/register.ts +138 -19
  152. package/src/reactive/registry.ts +22 -9
  153. package/src/reactive/set.ts +8 -21
  154. package/src/reactive/tracking.ts +9 -12
  155. package/src/reactive/types.ts +104 -24
  156. package/src/reactive/{interface.ts → watch.ts} +29 -59
  157. package/src/std-decorators.ts +56 -17
  158. package/src/utils.ts +2 -3
  159. package/src/zone.ts +28 -24
  160. package/dist/async/index.d.ts.map +0 -1
  161. package/dist/chunks/async-browser-CA0jPWIi.cjs.map +0 -1
  162. package/dist/chunks/async-core-UqHzvJ-S.cjs.map +0 -1
  163. package/dist/chunks/async-node-BYHuGTni.cjs.map +0 -1
  164. package/dist/chunks/index-DhaOVusv.esm.js +0 -6411
  165. package/dist/chunks/index-DhaOVusv.esm.js.map +0 -1
  166. package/dist/decorator.d.ts.map +0 -1
  167. package/dist/destroyable.d.ts.map +0 -1
  168. package/dist/entry-browser.d.ts.map +0 -1
  169. package/dist/entry-node.d.ts.map +0 -1
  170. package/dist/eventful.d.ts +0 -18
  171. package/dist/eventful.d.ts.map +0 -1
  172. package/dist/index.d.ts.map +0 -1
  173. package/dist/indexable.d.ts.map +0 -1
  174. package/dist/introspection.d.ts.map +0 -1
  175. package/dist/iterableWeak.d.ts.map +0 -1
  176. package/dist/mixins.d.ts.map +0 -1
  177. package/dist/promiseChain.d.ts.map +0 -1
  178. package/dist/reactive/array.d.ts.map +0 -1
  179. package/dist/reactive/buffer.d.ts +0 -44
  180. package/dist/reactive/buffer.d.ts.map +0 -1
  181. package/dist/reactive/change.d.ts.map +0 -1
  182. package/dist/reactive/debug.d.ts.map +0 -1
  183. package/dist/reactive/deep-touch.d.ts.map +0 -1
  184. package/dist/reactive/deep-watch-state.d.ts.map +0 -1
  185. package/dist/reactive/deep-watch.d.ts.map +0 -1
  186. package/dist/reactive/effect-context.d.ts +0 -7
  187. package/dist/reactive/effect-context.d.ts.map +0 -1
  188. package/dist/reactive/effects.d.ts.map +0 -1
  189. package/dist/reactive/index.d.ts +0 -20
  190. package/dist/reactive/index.d.ts.map +0 -1
  191. package/dist/reactive/interface.d.ts.map +0 -1
  192. package/dist/reactive/map.d.ts.map +0 -1
  193. package/dist/reactive/memoize.d.ts +0 -5
  194. package/dist/reactive/memoize.d.ts.map +0 -1
  195. package/dist/reactive/non-reactive-state.d.ts.map +0 -1
  196. package/dist/reactive/non-reactive.d.ts.map +0 -1
  197. package/dist/reactive/project.d.ts.map +0 -1
  198. package/dist/reactive/proxy-state.d.ts.map +0 -1
  199. package/dist/reactive/proxy.d.ts.map +0 -1
  200. package/dist/reactive/record.d.ts.map +0 -1
  201. package/dist/reactive/register.d.ts.map +0 -1
  202. package/dist/reactive/registry.d.ts.map +0 -1
  203. package/dist/reactive/set.d.ts.map +0 -1
  204. package/dist/reactive/tracking.d.ts.map +0 -1
  205. package/dist/reactive/types.d.ts.map +0 -1
  206. package/dist/std-decorators.d.ts.map +0 -1
  207. package/dist/utils.d.ts.map +0 -1
  208. package/dist/zone.d.ts.map +0 -1
  209. package/src/reactive/debug.ts +0 -517
  210. /package/dist/{async → src/async}/browser.d.ts +0 -0
  211. /package/dist/{async → src/async}/node.d.ts +0 -0
  212. /package/dist/{decorator.d.ts → src/decorator.d.ts} +0 -0
  213. /package/dist/{destroyable.d.ts → src/destroyable.d.ts} +0 -0
  214. /package/dist/{entry-browser.d.ts → src/entry-browser.d.ts} +0 -0
  215. /package/dist/{entry-node.d.ts → src/entry-node.d.ts} +0 -0
  216. /package/dist/{indexable.d.ts → src/indexable.d.ts} +0 -0
  217. /package/dist/{iterableWeak.d.ts → src/iterableWeak.d.ts} +0 -0
  218. /package/dist/{mixins.d.ts → src/mixins.d.ts} +0 -0
  219. /package/dist/{promiseChain.d.ts → src/promiseChain.d.ts} +0 -0
  220. /package/dist/{reactive → src/reactive}/deep-touch.d.ts +0 -0
  221. /package/dist/{reactive → src/reactive}/non-reactive-state.d.ts +0 -0
  222. /package/dist/{reactive → src/reactive}/non-reactive.d.ts +0 -0
  223. /package/dist/{reactive → src/reactive}/proxy-state.d.ts +0 -0
  224. /package/dist/{reactive → src/reactive}/proxy.d.ts +0 -0
  225. /package/dist/{reactive → src/reactive}/tracking.d.ts +0 -0
  226. /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
@@ -1,14 +1,8 @@
1
- import { a as asyncHooks } from './chunks/index-DhaOVusv.esm.js';
2
- export { A as AZone, b as ArrayReadForward, D as DecoratorError, c as Destroyable, d as DestructionError, E as Eventful, F as FoolProof, I as Indexable, e as IterableWeakMap, f as IterableWeakSet, R as ReactiveBase, g as ReactiveError, h as ReactiveErrorCode, i as Register, Z as Zone, j as ZoneAggregator, k as ZoneHistory, l as addBatchCleanup, m as allocated, n as allocatedValues, o as arrayEquals, p as asyncHook, q as asyncZone, r as atomic, s as biDi, t as buildReactivityGraph, u as cache, v as cached, w as callOnGC, x as chainPromise, y as cleanedBy, z as cleanup, B as contentRef, C as debounce, G as decorator, H as deepCompare, J as deepWatch, K as defer, L as deprecated, M as derived, N as describe, O as destructor, P as effect, Q as effectAggregator, S as enableDevTools, T as forwardArray, U as getActivationLog, V as getActiveEffect, W as getActiveProjection, X as getAt, Y as getState, _ as immutables, $ as isCached, a0 as isConstructor, a1 as isDevtoolsEnabled, a2 as isNonReactive, a3 as isOwnAccessor, a4 as isReactive, a5 as legacyDecorator, a6 as memoize, a7 as mixin, a8 as modernDecorator, a9 as named, aa as organize, ab as organized, ac as profileInfo, ad as project, ae as reactive, af as reactiveOptions, ag as register, ah as registerEffectForDebug, ai as registerNativeReactivity, aj as registerObjectForDebug, ak as renamed, al as resolve, am as root, an as scan, ao as setAt, ap as setEffectName, aq as setObjectName, ar as tag, as as throttle, at as touched, au as touched1, av as trackEffect, aw as unreactive, ax as untracked, ay as unwrap, az as watch, aA as zip } from './chunks/index-DhaOVusv.esm.js';
1
+ import { h as hooks, a as asyncHooks } from './chunks/index-CtA2AWl3.esm.js';
2
+ export { A as AZone, D as DecoratorError, F as FoolProof, I as IterableWeakMap, b as IterableWeakSet, R as ReactiveBase, c as ReactiveError, d as ReactiveErrorCode, Z as Zone, e as ZoneAggregator, f as ZoneHistory, g as addBatchCleanup, i as arrayEquals, j as asyncHook, k as asyncZone, l as atomic, m as biDi, n as cleanedBy, o as cleanup, p as contentRef, q as createFlavor, r as decorator, s as deepCompare, t as defer, u as derived, v as effect, w as effectAggregator, x as flavorOptions, y as flavored, z as getActivationLog, B as getActiveEffect, C as getState, E as immutables, G as isConstructor, H as isNonReactive, J as isOwnAccessor, K as isReactive, L as legacyDecorator, M as mixin, N as modernDecorator, O as named, P as onEffectThrow, Q as onEffectTrigger, S as reactive, T as reactiveOptions, U as registerNativeReactivity, V as renamed, W as reset, X as root, Y as tag, _ as touched, $ as touched1, a0 as untracked, a1 as unwrap, a2 as zip } from './chunks/index-CtA2AWl3.esm.js';
3
+ export { A as ArrayReadForward, D as Destroyable, a as DestructionError, E as Eventful, I as Indexable, R as Register, b as allocated, c as allocatedValues, d as attend, e as cache, f as cached, g as callOnGC, h as chainPromise, i as debounce, j as deepWatch, k as deprecated, l as describe, m as descriptor, n as destructor, o as forwardArray, p as getActiveProjection, q as getAt, r as isCached, s as lift, t as memoize, u as organize, v as organized, w as profileInfo, x as project, y as register, z as scan, B as setAt, C as throttle, F as unreactive, G as watch } from './chunks/index-2vea86wD.esm.js';
3
4
 
4
- const hooks = new Set();
5
5
  const promiseContexts = new WeakMap();
6
- asyncHooks.addHook = function (hook) {
7
- hooks.add(hook);
8
- return () => {
9
- hooks.delete(hook);
10
- };
11
- };
12
6
  // [HACK]: Sanitization
13
7
  // If a Promise is created inside the zone, it carries the "Sticky" zone context.
14
8
  // If returned to the outer scope, that context leaks. We wrap it in a new Promise
@@ -119,7 +113,7 @@ function patchOnProperties(proto) {
119
113
  ...desc,
120
114
  set: function (fn) {
121
115
  nativeSet.call(this, wrap(fn));
122
- }
116
+ },
123
117
  });
124
118
  }
125
119
  }
@@ -220,49 +214,49 @@ function PatchedPromise(executor) {
220
214
  Object.assign(PatchedPromise, OriginalPromise);
221
215
  // Inherit prototype for instanceof checks
222
216
  PatchedPromise.prototype = OriginalPromise.prototype;
223
- PatchedPromise.resolve = function (value) {
217
+ PatchedPromise.resolve = ((value) => {
224
218
  const p = originals.resolve.call(OriginalPromise, value);
225
219
  const context = captureRestorers();
226
220
  // Ensure we don't overwrite if it already has context (e.g. from constructor)
227
221
  if (context.size > 0 && !promiseContexts.has(p))
228
222
  promiseContexts.set(p, context);
229
223
  return p;
230
- };
231
- PatchedPromise.reject = function (reason) {
224
+ });
225
+ PatchedPromise.reject = ((reason) => {
232
226
  const p = originals.reject.call(OriginalPromise, reason);
233
227
  const context = captureRestorers();
234
228
  if (context.size > 0)
235
229
  promiseContexts.set(p, context);
236
230
  return p;
237
- };
238
- PatchedPromise.all = function (values) {
231
+ });
232
+ PatchedPromise.all = ((values) => {
239
233
  const p = originals.all.call(OriginalPromise, values);
240
234
  const context = captureRestorers();
241
235
  if (context.size > 0)
242
236
  promiseContexts.set(p, context);
243
237
  return p;
244
- };
245
- PatchedPromise.allSettled = function (values) {
238
+ });
239
+ PatchedPromise.allSettled = ((values) => {
246
240
  const p = originals.allSettled.call(OriginalPromise, values);
247
241
  const context = captureRestorers();
248
242
  if (context.size > 0)
249
243
  promiseContexts.set(p, context);
250
244
  return p;
251
- };
252
- PatchedPromise.race = function (values) {
245
+ });
246
+ PatchedPromise.race = ((values) => {
253
247
  const p = originals.race.call(OriginalPromise, values);
254
248
  const context = captureRestorers();
255
249
  if (context.size > 0)
256
250
  promiseContexts.set(p, context);
257
251
  return p;
258
- };
259
- PatchedPromise.any = function (values) {
252
+ });
253
+ PatchedPromise.any = ((values) => {
260
254
  const p = originals.any.call(OriginalPromise, values);
261
255
  const context = captureRestorers();
262
256
  if (context.size > 0)
263
257
  promiseContexts.set(p, context);
264
258
  return p;
265
- };
259
+ });
266
260
  // Only apply patches if not already applied (or re-apply safely)
267
261
  // Note: OriginalPromise.prototype might be shared if we used the global one.
268
262
  // We must ensure we don't patch it twice if it's the SAME object.
@@ -274,7 +268,7 @@ if (OriginalPromise.prototype.then !== patchedThen) {
274
268
  try {
275
269
  Object.defineProperty(OriginalPromise, Symbol.species, {
276
270
  get: () => PatchedPromise,
277
- configurable: true
271
+ configurable: true,
278
272
  });
279
273
  }
280
274
  catch (e) { }
@@ -301,5 +295,5 @@ if (originals.queueMicrotask) {
301
295
  };
302
296
  }
303
297
 
304
- export { asyncHooks };
298
+ export { asyncHooks, hooks };
305
299
  //# sourceMappingURL=browser.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.esm.js","sources":["../src/async/browser.ts"],"sourcesContent":["import { Hook, Restorer, asyncHooks } from '.'\n\nconst hooks = new Set<Hook>()\nconst promiseContexts = new WeakMap<Promise<any>, Set<Restorer>>()\n\nasyncHooks.addHook = function (hook: Hook) {\n\thooks.add(hook)\n\treturn () => {\n\t\thooks.delete(hook)\n\t}\n}\n\n// [HACK]: Sanitization\n// If a Promise is created inside the zone, it carries the \"Sticky\" zone context.\n// If returned to the outer scope, that context leaks. We wrap it in a new Promise\n// created here (in the outer scope) to break the chain and sanitize the return value.\n// See BROWSER_ASYNC_POLYFILL.md for full details.\nasyncHooks.sanitizePromise = (res: any) => {\n if (res && typeof (res as any).then === 'function') {\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n (res as any).then(resolve, reject)\n }, 0)\n })\n }\n return res\n}\n\nfunction captureRestorers() {\n\tconst restorers = new Set<Restorer>()\n\tfor (const hook of hooks) {\n\t\tconst restorer = hook()\n\t\tif (restorer) restorers.add(restorer)\n\t}\n\treturn restorers\n}\n\nfunction wrap<Args extends any[], R>(fn: ((...args: Args) => R) | null | undefined, capturedRestorers?: Set<Restorer>) {\n\tif (typeof fn !== 'function') return fn\n\tconst restorers = capturedRestorers || captureRestorers()\n\treturn function (this: any, ...args: Args) {\n\t\tconst undoers: (() => void)[] = []\n\t\tfor (const restore of restorers) undoers.push(restore())\n\t\ttry {\n\t\t\treturn fn.apply(this, args)\n\t\t} finally {\n\t\t\tif (originals.queueMicrotask) {\n\t\t\t\t// Double microtask ensures we run after the first await resumption microtask\n\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst targetWrappers = new WeakMap<any, Map<string, WeakMap<Function, Function>>>()\n\nfunction patchEventTarget(proto: any) {\n\tif (!proto || !proto.addEventListener || !proto.removeEventListener) return\n\tconst nativeAdd = proto.addEventListener\n\tconst nativeRemove = proto.removeEventListener\n\n\tproto.addEventListener = function (this: any, type: string, listener: any, options: any) {\n\t\tif (typeof listener !== 'function') {\n\t\t\treturn nativeAdd.call(this, type, listener, options)\n\t\t}\n\n\t\tlet types = targetWrappers.get(this)\n\t\tif (!types) {\n\t\t\ttypes = new Map()\n\t\t\ttargetWrappers.set(this, types)\n\t\t}\n\t\tlet listeners = types.get(type)\n\t\tif (!listeners) {\n\t\t\tlisteners = new WeakMap()\n\t\t\ttypes.set(type, listeners)\n\t\t}\n\n\t\tlet wrapped = listeners.get(listener)\n\t\tif (!wrapped) {\n\t\t\twrapped = wrap(listener)\n\t\t\tlisteners.set(listener, wrapped)\n\t\t}\n\t\t\n\t\treturn nativeAdd.call(this, type, wrapped, options)\n\t}\n\n\tproto.removeEventListener = function (this: any, type: string, listener: any, options: any) {\n\t\tif (typeof listener !== 'function') {\n\t\t\treturn nativeRemove.call(this, type, listener, options)\n\t\t}\n\n\t\tconst types = targetWrappers.get(this)\n\t\tif (types) {\n\t\t\tconst listeners = types.get(type)\n\t\t\tif (listeners) {\n\t\t\t\tconst wrapped = listeners.get(listener)\n\t\t\t\tif (wrapped) {\n\t\t\t\t\treturn nativeRemove.call(this, type, wrapped, options)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn nativeRemove.call(this, type, listener, options)\n\t}\n}\n\nfunction patchOnProperties(proto: any) {\n\tif (!proto) return\n\tfor (const prop of Object.getOwnPropertyNames(proto)) {\n\t\tif (prop.startsWith('on')) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\t\tif (desc && desc.set && desc.configurable) {\n\t\t\t\tconst nativeSet = desc.set\n\t\t\t\tObject.defineProperty(proto, prop, {\n\t\t\t\t\t...desc,\n\t\t\t\t\tset: function (this: any, fn: any) {\n\t\t\t\t\t\tnativeSet.call(this, wrap(fn))\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\nif (typeof EventTarget !== 'undefined') {\n\tpatchEventTarget(EventTarget.prototype)\n}\n\nconst prototypesToPatch = [\n\ttypeof EventTarget !== 'undefined' && EventTarget.prototype,\n\ttypeof HTMLElement !== 'undefined' && HTMLElement.prototype,\n\ttypeof Window !== 'undefined' && Window.prototype,\n\ttypeof Document !== 'undefined' && Document.prototype,\n\ttypeof MessagePort !== 'undefined' && MessagePort.prototype,\n\ttypeof XMLHttpRequest !== 'undefined' && XMLHttpRequest.prototype,\n\ttypeof IDBRequest !== 'undefined' && IDBRequest.prototype,\n\ttypeof IDBTransaction !== 'undefined' && IDBTransaction.prototype,\n\ttypeof IDBDatabase !== 'undefined' && IDBDatabase.prototype,\n\ttypeof FileReader !== 'undefined' && FileReader.prototype,\n\ttypeof AbortSignal !== 'undefined' && AbortSignal.prototype,\n]\n\nfor (const proto of prototypesToPatch) {\n\tif (proto) {\n\t\tpatchOnProperties(proto)\n\t}\n}\n\nconst GLOBAL_ORIGINALS = Symbol.for('mutts.originals');\nconst GLOBAL_PROMISE = Symbol.for('mutts.OriginalPromise');\n\nlet originals: any;\nlet OriginalPromise: any;\n\nif ((globalThis as any)[GLOBAL_ORIGINALS]) {\n originals = (globalThis as any)[GLOBAL_ORIGINALS];\n OriginalPromise = (globalThis as any)[GLOBAL_PROMISE];\n} else {\n OriginalPromise = globalThis.Promise;\n originals = {\n then: OriginalPromise.prototype.then,\n catch: OriginalPromise.prototype.catch,\n finally: OriginalPromise.prototype.finally,\n resolve: OriginalPromise.resolve,\n reject: OriginalPromise.reject,\n all: OriginalPromise.all,\n allSettled: (OriginalPromise as any).allSettled,\n race: OriginalPromise.race,\n any: (OriginalPromise as any).any,\n setTimeout: globalThis.setTimeout,\n setInterval: globalThis.setInterval,\n setImmediate: (globalThis as any).setImmediate,\n requestAnimationFrame: (globalThis as any).requestAnimationFrame,\n queueMicrotask: globalThis.queueMicrotask,\n };\n (globalThis as any)[GLOBAL_ORIGINALS] = originals;\n (globalThis as any)[GLOBAL_PROMISE] = OriginalPromise;\n}\n\n// Ensure modern statics are captured even if originals was cached from an older version\nif (!originals.allSettled) originals.allSettled = (OriginalPromise as any).allSettled\nif (!originals.any) originals.any = (OriginalPromise as any).any\nif (!originals.race) originals.race = OriginalPromise.race\n\nfunction patchedThen(this: any, onFulfilled: any, onRejected: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.then.call(this, wrap(onFulfilled, context), wrap(onRejected, context))\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction patchedCatch(this: any, onRejected: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.catch.call(this, wrap(onRejected, context))\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction patchedFinally(this: any, onFinally: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.finally.call(this, wrap(onFinally, context))\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction PatchedPromise<T>(this: any, executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) {\n if (typeof executor === 'function') {\n const p = new OriginalPromise((resolve, reject) => {\n const wrappedResolve = wrap(resolve)\n const wrappedReject = wrap(reject)\n executor(wrappedResolve, wrappedReject)\n })\n const context = captureRestorers()\n promiseContexts.set(p, context) // Always set, even if empty (Sticky Root)\n return p\n }\n return new OriginalPromise(executor)\n}\n\n// Copy statics\nObject.assign(PatchedPromise, (OriginalPromise as any))\n\n// Inherit prototype for instanceof checks\nPatchedPromise.prototype = OriginalPromise.prototype\n\nPatchedPromise.resolve = function<T>(value?: T | PromiseLike<T>): Promise<T> {\n const p = originals.resolve.call(OriginalPromise, value) as Promise<T>\n const context = captureRestorers()\n // Ensure we don't overwrite if it already has context (e.g. from constructor)\n if (context.size > 0 && !promiseContexts.has(p)) promiseContexts.set(p, context)\n return p\n} as any\n\nPatchedPromise.reject = function<T = never>(reason?: any): Promise<T> {\n const p = originals.reject.call(OriginalPromise, reason) as Promise<T>\n const context = captureRestorers()\n if (context.size > 0) promiseContexts.set(p, context)\n return p\n} as any\n\nPatchedPromise.all = function<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]> {\n const p = originals.all.call(OriginalPromise, values) as Promise<Awaited<T>[]>\n const context = captureRestorers()\n if (context.size > 0) promiseContexts.set(p, context)\n return p\n} as any\n\nPatchedPromise.allSettled = function<T>(values: Iterable<T | PromiseLike<T>>): Promise<PromiseSettledResult<Awaited<T>>[]> {\n const p = (originals.allSettled as any).call(OriginalPromise, values)\n const context = captureRestorers()\n if (context.size > 0) promiseContexts.set(p, context)\n return p\n} as any\n\nPatchedPromise.race = function<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>> {\n const p = originals.race.call(OriginalPromise, values) as Promise<Awaited<T>>\n const context = captureRestorers()\n if (context.size > 0) promiseContexts.set(p, context)\n return p\n} as any\n\nPatchedPromise.any = function<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>> {\n const p = (originals.any as any).call(OriginalPromise, values)\n const context = captureRestorers()\n if (context.size > 0) promiseContexts.set(p, context)\n return p\n} as any\n\n// Only apply patches if not already applied (or re-apply safely)\n// Note: OriginalPromise.prototype might be shared if we used the global one.\n// We must ensure we don't patch it twice if it's the SAME object.\nif (OriginalPromise.prototype.then !== patchedThen) {\n OriginalPromise.prototype.then = patchedThen as any\n OriginalPromise.prototype.catch = patchedCatch as any\n OriginalPromise.prototype.finally = patchedFinally as any\n}\n\ntry {\n\tObject.defineProperty(OriginalPromise, Symbol.species, {\n\t\tget: () => PatchedPromise,\n\t\tconfigurable: true\n\t})\n} catch (e) {}\n\n;(globalThis as any).Promise = PatchedPromise\n\nglobalThis.setTimeout = ((callback: Function, ...args: any[]) => {\n\treturn originals.setTimeout.call(globalThis, wrap(callback as any), ...args)\n}) as any\n\nglobalThis.setInterval = ((callback: Function, ...args: any[]) => {\n\treturn originals.setInterval.call(globalThis, wrap(callback as any), ...args)\n}) as any\n\nif (originals.setImmediate) {\n\t;(globalThis as any).setImmediate = ((callback: Function, ...args: any[]) => {\n\t\treturn originals.setImmediate.call(globalThis, wrap(callback as any), ...args)\n\t}) as any\n}\n\nif (originals.requestAnimationFrame) {\n\tglobalThis.requestAnimationFrame = (callback: FrameRequestCallback) => {\n\t\treturn originals.requestAnimationFrame.call(globalThis, wrap(callback))\n\t}\n}\n\nif (originals.queueMicrotask) {\n\tglobalThis.queueMicrotask = (callback: VoidFunction): void => {\n\t\toriginals.queueMicrotask.call(globalThis, wrap(callback))\n\t}\n}\n"],"names":[],"mappings":";;;AAEA,MAAM,KAAK,GAAG,IAAI,GAAG,EAAQ;AAC7B,MAAM,eAAe,GAAG,IAAI,OAAO,EAA+B;AAElE,UAAU,CAAC,OAAO,GAAG,UAAU,IAAU,EAAA;AACxC,IAAA,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;AACf,IAAA,OAAO,MAAK;AACX,QAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;AACnB,IAAA,CAAC;AACF,CAAC;AAED;AACA;AACA;AACA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U,CAAC,WAAW,IAAI,CAAC,QAAkB,EAAE,GAAG,IAAW,KAAI;AAChE,IAAA,OAAO,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAe,CAAC,EAAE,GAAG,IAAI,CAAC;AAC9E,CAAC,CAAQ;AAET,IAAI,SAAS,CAAC,YAAY,EAAE;IACzB,UAAkB,CAAC,YAAY,IAAI,CAAC,QAAkB,EAAE,GAAG,IAAW,KAAI;AAC3E,QAAA,OAAO,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAe,CAAC,EAAE,GAAG,IAAI,CAAC;AAC/E,IAAA,CAAC,CAAQ;AACV;AAEA,IAAI,SAAS,CAAC,qBAAqB,EAAE;AACpC,IAAA,UAAU,CAAC,qBAAqB,GAAG,CAAC,QAA8B,KAAI;AACrE,QAAA,OAAO,SAAS,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxE,IAAA,CAAC;AACF;AAEA,IAAI,SAAS,CAAC,cAAc,EAAE;AAC7B,IAAA,UAAU,CAAC,cAAc,GAAG,CAAC,QAAsB,KAAU;AAC5D,QAAA,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1D,IAAA,CAAC;AACF;;;;"}
1
+ {"version":3,"file":"browser.esm.js","sources":["../src/async/browser.ts"],"sourcesContent":["import { asyncHooks, hooks, type Restorer } from '.'\n\nconst promiseContexts = new WeakMap<Promise<any>, Set<Restorer>>()\n\n// [HACK]: Sanitization\n// If a Promise is created inside the zone, it carries the \"Sticky\" zone context.\n// If returned to the outer scope, that context leaks. We wrap it in a new Promise\n// created here (in the outer scope) to break the chain and sanitize the return value.\n// See BROWSER_ASYNC_POLYFILL.md for full details.\nasyncHooks.sanitizePromise = (res: any) => {\n\tif (res && typeof (res as any).then === 'function') {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tsetTimeout(() => {\n\t\t\t\t;(res as any).then(resolve, reject)\n\t\t\t}, 0)\n\t\t})\n\t}\n\treturn res\n}\n\nfunction captureRestorers() {\n\tconst restorers = new Set<Restorer>()\n\tfor (const hook of hooks) {\n\t\tconst restorer = hook()\n\t\tif (restorer) restorers.add(restorer)\n\t}\n\treturn restorers\n}\n\nfunction wrap<Args extends any[], R>(\n\tfn: ((...args: Args) => R) | null | undefined,\n\tcapturedRestorers?: Set<Restorer>\n) {\n\tif (typeof fn !== 'function') return fn\n\tconst restorers = capturedRestorers || captureRestorers()\n\treturn function (this: any, ...args: Args) {\n\t\tconst undoers: (() => void)[] = []\n\t\tfor (const restore of restorers) undoers.push(restore())\n\t\ttry {\n\t\t\treturn fn.apply(this, args)\n\t\t} finally {\n\t\t\tif (originals.queueMicrotask) {\n\t\t\t\t// Double microtask ensures we run after the first await resumption microtask\n\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst targetWrappers = new WeakMap<any, Map<string, WeakMap<Function, Function>>>()\n\nfunction patchEventTarget(proto: any) {\n\tif (!proto || !proto.addEventListener || !proto.removeEventListener) return\n\tconst nativeAdd = proto.addEventListener\n\tconst nativeRemove = proto.removeEventListener\n\n\tproto.addEventListener = function (this: any, type: string, listener: any, options: any) {\n\t\tif (typeof listener !== 'function') {\n\t\t\treturn nativeAdd.call(this, type, listener, options)\n\t\t}\n\n\t\tlet types = targetWrappers.get(this)\n\t\tif (!types) {\n\t\t\ttypes = new Map()\n\t\t\ttargetWrappers.set(this, types)\n\t\t}\n\t\tlet listeners = types.get(type)\n\t\tif (!listeners) {\n\t\t\tlisteners = new WeakMap()\n\t\t\ttypes.set(type, listeners)\n\t\t}\n\n\t\tlet wrapped = listeners.get(listener)\n\t\tif (!wrapped) {\n\t\t\twrapped = wrap(listener)\n\t\t\tlisteners.set(listener, wrapped)\n\t\t}\n\n\t\treturn nativeAdd.call(this, type, wrapped, options)\n\t}\n\n\tproto.removeEventListener = function (this: any, type: string, listener: any, options: any) {\n\t\tif (typeof listener !== 'function') {\n\t\t\treturn nativeRemove.call(this, type, listener, options)\n\t\t}\n\n\t\tconst types = targetWrappers.get(this)\n\t\tif (types) {\n\t\t\tconst listeners = types.get(type)\n\t\t\tif (listeners) {\n\t\t\t\tconst wrapped = listeners.get(listener)\n\t\t\t\tif (wrapped) {\n\t\t\t\t\treturn nativeRemove.call(this, type, wrapped, options)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nativeRemove.call(this, type, listener, options)\n\t}\n}\n\nfunction patchOnProperties(proto: any) {\n\tif (!proto) return\n\tfor (const prop of Object.getOwnPropertyNames(proto)) {\n\t\tif (prop.startsWith('on')) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\t\tif (desc && desc.set && desc.configurable) {\n\t\t\t\tconst nativeSet = desc.set\n\t\t\t\tObject.defineProperty(proto, prop, {\n\t\t\t\t\t...desc,\n\t\t\t\t\tset: function (this: any, fn: any) {\n\t\t\t\t\t\tnativeSet.call(this, wrap(fn))\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\nif (typeof EventTarget !== 'undefined') {\n\tpatchEventTarget(EventTarget.prototype)\n}\n\nconst prototypesToPatch = [\n\ttypeof EventTarget !== 'undefined' && EventTarget.prototype,\n\ttypeof HTMLElement !== 'undefined' && HTMLElement.prototype,\n\ttypeof Window !== 'undefined' && Window.prototype,\n\ttypeof Document !== 'undefined' && Document.prototype,\n\ttypeof MessagePort !== 'undefined' && MessagePort.prototype,\n\ttypeof XMLHttpRequest !== 'undefined' && XMLHttpRequest.prototype,\n\ttypeof IDBRequest !== 'undefined' && IDBRequest.prototype,\n\ttypeof IDBTransaction !== 'undefined' && IDBTransaction.prototype,\n\ttypeof IDBDatabase !== 'undefined' && IDBDatabase.prototype,\n\ttypeof FileReader !== 'undefined' && FileReader.prototype,\n\ttypeof AbortSignal !== 'undefined' && AbortSignal.prototype,\n]\n\nfor (const proto of prototypesToPatch) {\n\tif (proto) {\n\t\tpatchOnProperties(proto)\n\t}\n}\n\nconst GLOBAL_ORIGINALS = Symbol.for('mutts.originals')\nconst GLOBAL_PROMISE = Symbol.for('mutts.OriginalPromise')\n\nlet originals: any\nlet OriginalPromise: any\n\nif ((globalThis as any)[GLOBAL_ORIGINALS]) {\n\toriginals = (globalThis as any)[GLOBAL_ORIGINALS]\n\tOriginalPromise = (globalThis as any)[GLOBAL_PROMISE]\n} else {\n\tOriginalPromise = globalThis.Promise\n\toriginals = {\n\t\tthen: OriginalPromise.prototype.then,\n\t\tcatch: OriginalPromise.prototype.catch,\n\t\tfinally: OriginalPromise.prototype.finally,\n\t\tresolve: OriginalPromise.resolve,\n\t\treject: OriginalPromise.reject,\n\t\tall: OriginalPromise.all,\n\t\tallSettled: (OriginalPromise as any).allSettled,\n\t\trace: OriginalPromise.race,\n\t\tany: (OriginalPromise as any).any,\n\t\tsetTimeout: globalThis.setTimeout,\n\t\tsetInterval: globalThis.setInterval,\n\t\tsetImmediate: (globalThis as any).setImmediate,\n\t\trequestAnimationFrame: (globalThis as any).requestAnimationFrame,\n\t\tqueueMicrotask: globalThis.queueMicrotask,\n\t}\n\t;(globalThis as any)[GLOBAL_ORIGINALS] = originals\n\t;(globalThis as any)[GLOBAL_PROMISE] = OriginalPromise\n}\n\n// Ensure modern statics are captured even if originals was cached from an older version\nif (!originals.allSettled) originals.allSettled = (OriginalPromise as any).allSettled\nif (!originals.any) originals.any = (OriginalPromise as any).any\nif (!originals.race) originals.race = OriginalPromise.race\n\nfunction patchedThen(this: any, onFulfilled: any, onRejected: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.then.call(\n\t\tthis,\n\t\twrap(onFulfilled, context),\n\t\twrap(onRejected, context)\n\t)\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction patchedCatch(this: any, onRejected: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.catch.call(this, wrap(onRejected, context))\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction patchedFinally(this: any, onFinally: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.finally.call(this, wrap(onFinally, context))\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction PatchedPromise<T>(\n\tthis: any,\n\texecutor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void\n) {\n\tif (typeof executor === 'function') {\n\t\tconst p = new OriginalPromise((resolve, reject) => {\n\t\t\tconst wrappedResolve = wrap(resolve)\n\t\t\tconst wrappedReject = wrap(reject)\n\t\t\texecutor(wrappedResolve, wrappedReject)\n\t\t})\n\t\tconst context = captureRestorers()\n\t\tpromiseContexts.set(p, context) // Always set, even if empty (Sticky Root)\n\t\treturn p\n\t}\n\treturn new OriginalPromise(executor)\n}\n\n// Copy statics\nObject.assign(PatchedPromise, OriginalPromise as any)\n\n// Inherit prototype for instanceof checks\nPatchedPromise.prototype = OriginalPromise.prototype\n\nPatchedPromise.resolve = (<T>(value?: T | PromiseLike<T>): Promise<T> => {\n\tconst p = originals.resolve.call(OriginalPromise, value) as Promise<T>\n\tconst context = captureRestorers()\n\t// Ensure we don't overwrite if it already has context (e.g. from constructor)\n\tif (context.size > 0 && !promiseContexts.has(p)) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.reject = (<T = never>(reason?: any): Promise<T> => {\n\tconst p = originals.reject.call(OriginalPromise, reason) as Promise<T>\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.all = (<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]> => {\n\tconst p = originals.all.call(OriginalPromise, values) as Promise<Awaited<T>[]>\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.allSettled = (<T>(\n\tvalues: Iterable<T | PromiseLike<T>>\n): Promise<PromiseSettledResult<Awaited<T>>[]> => {\n\tconst p = (originals.allSettled as any).call(OriginalPromise, values)\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.race = (<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>> => {\n\tconst p = originals.race.call(OriginalPromise, values) as Promise<Awaited<T>>\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.any = (<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>> => {\n\tconst p = (originals.any as any).call(OriginalPromise, values)\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\n// Only apply patches if not already applied (or re-apply safely)\n// Note: OriginalPromise.prototype might be shared if we used the global one.\n// We must ensure we don't patch it twice if it's the SAME object.\nif (OriginalPromise.prototype.then !== patchedThen) {\n\tOriginalPromise.prototype.then = patchedThen as any\n\tOriginalPromise.prototype.catch = patchedCatch as any\n\tOriginalPromise.prototype.finally = patchedFinally as any\n}\n\ntry {\n\tObject.defineProperty(OriginalPromise, Symbol.species, {\n\t\tget: () => PatchedPromise,\n\t\tconfigurable: true,\n\t})\n} catch (e) {}\n\n;(globalThis as any).Promise = PatchedPromise\n\nglobalThis.setTimeout = ((callback: Function, ...args: any[]) => {\n\treturn originals.setTimeout.call(globalThis, wrap(callback as any), ...args)\n}) as any\n\nglobalThis.setInterval = ((callback: Function, ...args: any[]) => {\n\treturn originals.setInterval.call(globalThis, wrap(callback as any), ...args)\n}) as any\n\nif (originals.setImmediate) {\n\t;(globalThis as any).setImmediate = ((callback: Function, ...args: any[]) => {\n\t\treturn originals.setImmediate.call(globalThis, wrap(callback as any), ...args)\n\t}) as any\n}\n\nif (originals.requestAnimationFrame) {\n\tglobalThis.requestAnimationFrame = (callback: FrameRequestCallback) => {\n\t\treturn originals.requestAnimationFrame.call(globalThis, wrap(callback))\n\t}\n}\n\nif (originals.queueMicrotask) {\n\tglobalThis.queueMicrotask = (callback: VoidFunction): void => {\n\t\toriginals.queueMicrotask.call(globalThis, wrap(callback))\n\t}\n}\n"],"names":[],"mappings":";;;;AAEA,MAAM,eAAe,GAAG,IAAI,OAAO,EAA+B;AAElE;AACA;AACA;AACA;AACA;AACA,UAAU,CAAC,eAAe,GAAG,CAAC,GAAQ,KAAI;IACzC,IAAI,GAAG,IAAI,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU,EAAE;QACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;YACtC,UAAU,CAAC,MAAK;AACb,gBAAA,GAAW,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;YACpC,CAAC,EAAE,CAAC,CAAC;AACN,QAAA,CAAC,CAAC;IACH;AACA,IAAA,OAAO,GAAG;AACX,CAAC;AAED,SAAS,gBAAgB,GAAA;AACxB,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAY;AACrC,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACzB,QAAA,MAAM,QAAQ,GAAG,IAAI,EAAE;AACvB,QAAA,IAAI,QAAQ;AAAE,YAAA,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtC;AACA,IAAA,OAAO,SAAS;AACjB;AAEA,SAAS,IAAI,CACZ,EAA6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AC,QAAQ,CAAC,CAAC;AACxE,IAAA,CAAC;AACF;AAEA,IAAI,SAAS,CAAC,cAAc,EAAE;AAC7B,IAAA,UAAU,CAAC,cAAc,GAAG,CAAC,QAAsB,KAAU;AAC5D,QAAA,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1D,IAAA,CAAC;AACF;;;;"}
@@ -1,15 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var asyncCore = require('./async-core-UqHzvJ-S.cjs');
3
+ var asyncCore = require('./async-core-CRLKP3l-.cjs');
4
4
 
5
- const hooks = new Set();
6
5
  const promiseContexts = new WeakMap();
7
- asyncCore.asyncHooks.addHook = function (hook) {
8
- hooks.add(hook);
9
- return () => {
10
- hooks.delete(hook);
11
- };
12
- };
13
6
  // [HACK]: Sanitization
14
7
  // If a Promise is created inside the zone, it carries the "Sticky" zone context.
15
8
  // If returned to the outer scope, that context leaks. We wrap it in a new Promise
@@ -27,7 +20,7 @@ asyncCore.asyncHooks.sanitizePromise = (res) => {
27
20
  };
28
21
  function captureRestorers() {
29
22
  const restorers = new Set();
30
- for (const hook of hooks) {
23
+ for (const hook of asyncCore.hooks) {
31
24
  const restorer = hook();
32
25
  if (restorer)
33
26
  restorers.add(restorer);
@@ -120,7 +113,7 @@ function patchOnProperties(proto) {
120
113
  ...desc,
121
114
  set: function (fn) {
122
115
  nativeSet.call(this, wrap(fn));
123
- }
116
+ },
124
117
  });
125
118
  }
126
119
  }
@@ -221,49 +214,49 @@ function PatchedPromise(executor) {
221
214
  Object.assign(PatchedPromise, OriginalPromise);
222
215
  // Inherit prototype for instanceof checks
223
216
  PatchedPromise.prototype = OriginalPromise.prototype;
224
- PatchedPromise.resolve = function (value) {
217
+ PatchedPromise.resolve = ((value) => {
225
218
  const p = originals.resolve.call(OriginalPromise, value);
226
219
  const context = captureRestorers();
227
220
  // Ensure we don't overwrite if it already has context (e.g. from constructor)
228
221
  if (context.size > 0 && !promiseContexts.has(p))
229
222
  promiseContexts.set(p, context);
230
223
  return p;
231
- };
232
- PatchedPromise.reject = function (reason) {
224
+ });
225
+ PatchedPromise.reject = ((reason) => {
233
226
  const p = originals.reject.call(OriginalPromise, reason);
234
227
  const context = captureRestorers();
235
228
  if (context.size > 0)
236
229
  promiseContexts.set(p, context);
237
230
  return p;
238
- };
239
- PatchedPromise.all = function (values) {
231
+ });
232
+ PatchedPromise.all = ((values) => {
240
233
  const p = originals.all.call(OriginalPromise, values);
241
234
  const context = captureRestorers();
242
235
  if (context.size > 0)
243
236
  promiseContexts.set(p, context);
244
237
  return p;
245
- };
246
- PatchedPromise.allSettled = function (values) {
238
+ });
239
+ PatchedPromise.allSettled = ((values) => {
247
240
  const p = originals.allSettled.call(OriginalPromise, values);
248
241
  const context = captureRestorers();
249
242
  if (context.size > 0)
250
243
  promiseContexts.set(p, context);
251
244
  return p;
252
- };
253
- PatchedPromise.race = function (values) {
245
+ });
246
+ PatchedPromise.race = ((values) => {
254
247
  const p = originals.race.call(OriginalPromise, values);
255
248
  const context = captureRestorers();
256
249
  if (context.size > 0)
257
250
  promiseContexts.set(p, context);
258
251
  return p;
259
- };
260
- PatchedPromise.any = function (values) {
252
+ });
253
+ PatchedPromise.any = ((values) => {
261
254
  const p = originals.any.call(OriginalPromise, values);
262
255
  const context = captureRestorers();
263
256
  if (context.size > 0)
264
257
  promiseContexts.set(p, context);
265
258
  return p;
266
- };
259
+ });
267
260
  // Only apply patches if not already applied (or re-apply safely)
268
261
  // Note: OriginalPromise.prototype might be shared if we used the global one.
269
262
  // We must ensure we don't patch it twice if it's the SAME object.
@@ -275,7 +268,7 @@ if (OriginalPromise.prototype.then !== patchedThen) {
275
268
  try {
276
269
  Object.defineProperty(OriginalPromise, Symbol.species, {
277
270
  get: () => PatchedPromise,
278
- configurable: true
271
+ configurable: true,
279
272
  });
280
273
  }
281
274
  catch (e) { }
@@ -301,4 +294,4 @@ if (originals.queueMicrotask) {
301
294
  originals.queueMicrotask.call(globalThis, wrap(callback));
302
295
  };
303
296
  }
304
- //# sourceMappingURL=async-browser-CA0jPWIi.cjs.map
297
+ //# sourceMappingURL=async-browser-lvzLOCgk.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-browser-lvzLOCgk.cjs","sources":["../../src/async/browser.ts"],"sourcesContent":["import { asyncHooks, hooks, type Restorer } from '.'\n\nconst promiseContexts = new WeakMap<Promise<any>, Set<Restorer>>()\n\n// [HACK]: Sanitization\n// If a Promise is created inside the zone, it carries the \"Sticky\" zone context.\n// If returned to the outer scope, that context leaks. We wrap it in a new Promise\n// created here (in the outer scope) to break the chain and sanitize the return value.\n// See BROWSER_ASYNC_POLYFILL.md for full details.\nasyncHooks.sanitizePromise = (res: any) => {\n\tif (res && typeof (res as any).then === 'function') {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tsetTimeout(() => {\n\t\t\t\t;(res as any).then(resolve, reject)\n\t\t\t}, 0)\n\t\t})\n\t}\n\treturn res\n}\n\nfunction captureRestorers() {\n\tconst restorers = new Set<Restorer>()\n\tfor (const hook of hooks) {\n\t\tconst restorer = hook()\n\t\tif (restorer) restorers.add(restorer)\n\t}\n\treturn restorers\n}\n\nfunction wrap<Args extends any[], R>(\n\tfn: ((...args: Args) => R) | null | undefined,\n\tcapturedRestorers?: Set<Restorer>\n) {\n\tif (typeof fn !== 'function') return fn\n\tconst restorers = capturedRestorers || captureRestorers()\n\treturn function (this: any, ...args: Args) {\n\t\tconst undoers: (() => void)[] = []\n\t\tfor (const restore of restorers) undoers.push(restore())\n\t\ttry {\n\t\t\treturn fn.apply(this, args)\n\t\t} finally {\n\t\t\tif (originals.queueMicrotask) {\n\t\t\t\t// Double microtask ensures we run after the first await resumption microtask\n\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\t\toriginals.queueMicrotask.call(globalThis, () => {\n\t\t\t\t\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tfor (let i = undoers.length - 1; i >= 0; i--) undoers[i]()\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst targetWrappers = new WeakMap<any, Map<string, WeakMap<Function, Function>>>()\n\nfunction patchEventTarget(proto: any) {\n\tif (!proto || !proto.addEventListener || !proto.removeEventListener) return\n\tconst nativeAdd = proto.addEventListener\n\tconst nativeRemove = proto.removeEventListener\n\n\tproto.addEventListener = function (this: any, type: string, listener: any, options: any) {\n\t\tif (typeof listener !== 'function') {\n\t\t\treturn nativeAdd.call(this, type, listener, options)\n\t\t}\n\n\t\tlet types = targetWrappers.get(this)\n\t\tif (!types) {\n\t\t\ttypes = new Map()\n\t\t\ttargetWrappers.set(this, types)\n\t\t}\n\t\tlet listeners = types.get(type)\n\t\tif (!listeners) {\n\t\t\tlisteners = new WeakMap()\n\t\t\ttypes.set(type, listeners)\n\t\t}\n\n\t\tlet wrapped = listeners.get(listener)\n\t\tif (!wrapped) {\n\t\t\twrapped = wrap(listener)\n\t\t\tlisteners.set(listener, wrapped)\n\t\t}\n\n\t\treturn nativeAdd.call(this, type, wrapped, options)\n\t}\n\n\tproto.removeEventListener = function (this: any, type: string, listener: any, options: any) {\n\t\tif (typeof listener !== 'function') {\n\t\t\treturn nativeRemove.call(this, type, listener, options)\n\t\t}\n\n\t\tconst types = targetWrappers.get(this)\n\t\tif (types) {\n\t\t\tconst listeners = types.get(type)\n\t\t\tif (listeners) {\n\t\t\t\tconst wrapped = listeners.get(listener)\n\t\t\t\tif (wrapped) {\n\t\t\t\t\treturn nativeRemove.call(this, type, wrapped, options)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nativeRemove.call(this, type, listener, options)\n\t}\n}\n\nfunction patchOnProperties(proto: any) {\n\tif (!proto) return\n\tfor (const prop of Object.getOwnPropertyNames(proto)) {\n\t\tif (prop.startsWith('on')) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\t\tif (desc && desc.set && desc.configurable) {\n\t\t\t\tconst nativeSet = desc.set\n\t\t\t\tObject.defineProperty(proto, prop, {\n\t\t\t\t\t...desc,\n\t\t\t\t\tset: function (this: any, fn: any) {\n\t\t\t\t\t\tnativeSet.call(this, wrap(fn))\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n}\n\nif (typeof EventTarget !== 'undefined') {\n\tpatchEventTarget(EventTarget.prototype)\n}\n\nconst prototypesToPatch = [\n\ttypeof EventTarget !== 'undefined' && EventTarget.prototype,\n\ttypeof HTMLElement !== 'undefined' && HTMLElement.prototype,\n\ttypeof Window !== 'undefined' && Window.prototype,\n\ttypeof Document !== 'undefined' && Document.prototype,\n\ttypeof MessagePort !== 'undefined' && MessagePort.prototype,\n\ttypeof XMLHttpRequest !== 'undefined' && XMLHttpRequest.prototype,\n\ttypeof IDBRequest !== 'undefined' && IDBRequest.prototype,\n\ttypeof IDBTransaction !== 'undefined' && IDBTransaction.prototype,\n\ttypeof IDBDatabase !== 'undefined' && IDBDatabase.prototype,\n\ttypeof FileReader !== 'undefined' && FileReader.prototype,\n\ttypeof AbortSignal !== 'undefined' && AbortSignal.prototype,\n]\n\nfor (const proto of prototypesToPatch) {\n\tif (proto) {\n\t\tpatchOnProperties(proto)\n\t}\n}\n\nconst GLOBAL_ORIGINALS = Symbol.for('mutts.originals')\nconst GLOBAL_PROMISE = Symbol.for('mutts.OriginalPromise')\n\nlet originals: any\nlet OriginalPromise: any\n\nif ((globalThis as any)[GLOBAL_ORIGINALS]) {\n\toriginals = (globalThis as any)[GLOBAL_ORIGINALS]\n\tOriginalPromise = (globalThis as any)[GLOBAL_PROMISE]\n} else {\n\tOriginalPromise = globalThis.Promise\n\toriginals = {\n\t\tthen: OriginalPromise.prototype.then,\n\t\tcatch: OriginalPromise.prototype.catch,\n\t\tfinally: OriginalPromise.prototype.finally,\n\t\tresolve: OriginalPromise.resolve,\n\t\treject: OriginalPromise.reject,\n\t\tall: OriginalPromise.all,\n\t\tallSettled: (OriginalPromise as any).allSettled,\n\t\trace: OriginalPromise.race,\n\t\tany: (OriginalPromise as any).any,\n\t\tsetTimeout: globalThis.setTimeout,\n\t\tsetInterval: globalThis.setInterval,\n\t\tsetImmediate: (globalThis as any).setImmediate,\n\t\trequestAnimationFrame: (globalThis as any).requestAnimationFrame,\n\t\tqueueMicrotask: globalThis.queueMicrotask,\n\t}\n\t;(globalThis as any)[GLOBAL_ORIGINALS] = originals\n\t;(globalThis as any)[GLOBAL_PROMISE] = OriginalPromise\n}\n\n// Ensure modern statics are captured even if originals was cached from an older version\nif (!originals.allSettled) originals.allSettled = (OriginalPromise as any).allSettled\nif (!originals.any) originals.any = (OriginalPromise as any).any\nif (!originals.race) originals.race = OriginalPromise.race\n\nfunction patchedThen(this: any, onFulfilled: any, onRejected: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.then.call(\n\t\tthis,\n\t\twrap(onFulfilled, context),\n\t\twrap(onRejected, context)\n\t)\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction patchedCatch(this: any, onRejected: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.catch.call(this, wrap(onRejected, context))\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction patchedFinally(this: any, onFinally: any) {\n\tconst context = promiseContexts.get(this) || captureRestorers()\n\tconst nextPromise = originals.finally.call(this, wrap(onFinally, context))\n\tif (context.size > 0) promiseContexts.set(nextPromise, context)\n\treturn nextPromise\n}\n\nfunction PatchedPromise<T>(\n\tthis: any,\n\texecutor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void\n) {\n\tif (typeof executor === 'function') {\n\t\tconst p = new OriginalPromise((resolve, reject) => {\n\t\t\tconst wrappedResolve = wrap(resolve)\n\t\t\tconst wrappedReject = wrap(reject)\n\t\t\texecutor(wrappedResolve, wrappedReject)\n\t\t})\n\t\tconst context = captureRestorers()\n\t\tpromiseContexts.set(p, context) // Always set, even if empty (Sticky Root)\n\t\treturn p\n\t}\n\treturn new OriginalPromise(executor)\n}\n\n// Copy statics\nObject.assign(PatchedPromise, OriginalPromise as any)\n\n// Inherit prototype for instanceof checks\nPatchedPromise.prototype = OriginalPromise.prototype\n\nPatchedPromise.resolve = (<T>(value?: T | PromiseLike<T>): Promise<T> => {\n\tconst p = originals.resolve.call(OriginalPromise, value) as Promise<T>\n\tconst context = captureRestorers()\n\t// Ensure we don't overwrite if it already has context (e.g. from constructor)\n\tif (context.size > 0 && !promiseContexts.has(p)) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.reject = (<T = never>(reason?: any): Promise<T> => {\n\tconst p = originals.reject.call(OriginalPromise, reason) as Promise<T>\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.all = (<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]> => {\n\tconst p = originals.all.call(OriginalPromise, values) as Promise<Awaited<T>[]>\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.allSettled = (<T>(\n\tvalues: Iterable<T | PromiseLike<T>>\n): Promise<PromiseSettledResult<Awaited<T>>[]> => {\n\tconst p = (originals.allSettled as any).call(OriginalPromise, values)\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.race = (<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>> => {\n\tconst p = originals.race.call(OriginalPromise, values) as Promise<Awaited<T>>\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\nPatchedPromise.any = (<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>> => {\n\tconst p = (originals.any as any).call(OriginalPromise, values)\n\tconst context = captureRestorers()\n\tif (context.size > 0) promiseContexts.set(p, context)\n\treturn p\n}) as any\n\n// Only apply patches if not already applied (or re-apply safely)\n// Note: OriginalPromise.prototype might be shared if we used the global one.\n// We must ensure we don't patch it twice if it's the SAME object.\nif (OriginalPromise.prototype.then !== patchedThen) {\n\tOriginalPromise.prototype.then = patchedThen as any\n\tOriginalPromise.prototype.catch = patchedCatch as any\n\tOriginalPromise.prototype.finally = patchedFinally as any\n}\n\ntry {\n\tObject.defineProperty(OriginalPromise, Symbol.species, {\n\t\tget: () => PatchedPromise,\n\t\tconfigurable: true,\n\t})\n} catch (e) {}\n\n;(globalThis as any).Promise = PatchedPromise\n\nglobalThis.setTimeout = ((callback: Function, ...args: any[]) => {\n\treturn originals.setTimeout.call(globalThis, wrap(callback as any), ...args)\n}) as any\n\nglobalThis.setInterval = ((callback: Function, ...args: any[]) => {\n\treturn originals.setInterval.call(globalThis, wrap(callback as any), ...args)\n}) as any\n\nif (originals.setImmediate) {\n\t;(globalThis as any).setImmediate = ((callback: Function, ...args: any[]) => {\n\t\treturn originals.setImmediate.call(globalThis, wrap(callback as any), ...args)\n\t}) as any\n}\n\nif (originals.requestAnimationFrame) {\n\tglobalThis.requestAnimationFrame = (callback: FrameRequestCallback) => {\n\t\treturn originals.requestAnimationFrame.call(globalThis, wrap(callback))\n\t}\n}\n\nif (originals.queueMicrotask) {\n\tglobalThis.queueMicrotask = (callback: VoidFunction): void => {\n\t\toriginals.queueMicrotask.call(globalThis, wrap(callback))\n\t}\n}\n"],"names":["asyncHooks","hooks"],"mappings":";;;;AAEA,MAAM,eAAe,GAAG,IAAI,OAAO,EAA+B;AAElE;AACA;AACA;AACA;AACA;AACAA,oBAAU,CAAC,eAAe,GAAG,CAAC,GAAQ,KAAI;IACzC,IAAI,GAAG,IAAI,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU,EAAE;QACnD,OAAO,IA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AW,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAe,CAAC,EAAE,GAAG,IAAI,CAAC;AAC9E,CAAC,CAAQ;AAET,IAAI,SAAS,CAAC,YAAY,EAAE;IACzB,UAAkB,CAAC,YAAY,IAAI,CAAC,QAAkB,EAAE,GAAG,IAAW,KAAI;AAC3E,QAAA,OAAO,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAe,CAAC,EAAE,GAAG,IAAI,CAAC;AAC/E,IAAA,CAAC,CAAQ;AACV;AAEA,IAAI,SAAS,CAAC,qBAAqB,EAAE;AACpC,IAAA,UAAU,CAAC,qBAAqB,GAAG,CAAC,QAA8B,KAAI;AACrE,QAAA,OAAO,SAAS,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxE,IAAA,CAAC;AACF;AAEA,IAAI,SAAS,CAAC,cAAc,EAAE;AAC7B,IAAA,UAAU,CAAC,cAAc,GAAG,CAAC,QAAsB,KAAU;AAC5D,QAAA,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1D,IAAA,CAAC;AACF;;"}
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ // Queue for hooks registered before the environment is ready (circular dependency fix)
4
+ const hooks = new Set();
3
5
  const asyncHooks = {
4
- addHook(_hook) {
5
- throw 'One must import the library from the server or the client side';
6
+ addHook(hook) {
7
+ hooks.add(hook);
8
+ return () => hooks.delete(hook);
6
9
  },
7
10
  /**
8
11
  * [Hack] Sanitize a promise (or value) to prevent context leaks.
@@ -11,7 +14,7 @@ const asyncHooks = {
11
14
  */
12
15
  sanitizePromise(p) {
13
16
  return p;
14
- }
17
+ },
15
18
  };
16
19
  /**
17
20
  * Register a hook that will be called whenever an asynchronous operation is initiated.
@@ -22,4 +25,5 @@ const asyncHook = (hook) => asyncHooks.addHook(hook);
22
25
 
23
26
  exports.asyncHook = asyncHook;
24
27
  exports.asyncHooks = asyncHooks;
25
- //# sourceMappingURL=async-core-UqHzvJ-S.cjs.map
28
+ exports.hooks = hooks;
29
+ //# sourceMappingURL=async-core-CRLKP3l-.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-core-CRLKP3l-.cjs","sources":["../../src/async/index.ts"],"sourcesContent":["export type Restorer = () => () => void\nexport type Hook = () => Restorer\n\n// Queue for hooks registered before the environment is ready (circular dependency fix)\nexport const hooks = new Set<Hook>()\n\nexport const asyncHooks = {\n\taddHook(hook: Hook): () => void {\n\t\thooks.add(hook)\n\t\treturn () => hooks.delete(hook)\n\t},\n\t/**\n\t * [Hack] Sanitize a promise (or value) to prevent context leaks.\n\t * Default: Identity function.\n\t * Browser: Uses Macrotask wrapping to break microtask chains.\n\t */\n\tsanitizePromise(p: any): any {\n\t\treturn p\n\t},\n}\n\n/**\n * Register a hook that will be called whenever an asynchronous operation is initiated.\n * The hook should return a restorer function which will be called just before the async callback runs.\n * That restorer should in turn return an undoer function which will be called just after the async callback finishes.\n */\nexport const asyncHook = (hook: Hook) => asyncHooks.addHook(hook)\n"],"names":[],"mappings":";;AAGA;AACO,MAAM,KAAK,GAAG,IAAI,GAAG;AAErB,MAAM,UAAU,GAAG;AACzB,IAAA,OAAO,CAAC,IAAU,EAAA;AACjB,QAAA,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QACf,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;IAChC,CAAC;AACD;;;;AAIG;AACH,IAAA,eAAe,CAAC,CAAM,EAAA;AACrB,QAAA,OAAO,CAAC;IACT,CAAC;;AAGF;;;;AAIG;AACI,MAAM,SAAS,GAAG,CAAC,IAAU,KAAK,UAAU,CAAC,OAAO,CAAC,IAAI;;;;;;"}
@@ -1,25 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  var node_async_hooks = require('node:async_hooks');
4
- var asyncCore = require('./async-core-UqHzvJ-S.cjs');
4
+ var asyncCore = require('./async-core-CRLKP3l-.cjs');
5
5
 
6
6
  // 1. Generic async_hooks implementation for Hooks
7
7
  // This maintains support for 'asyncHooks.addHook' for generic use cases.
8
- const hooks = new Set();
9
- asyncCore.asyncHooks.addHook = function (hook) {
10
- hooks.add(hook);
11
- return () => {
12
- hooks.delete(hook);
13
- };
14
- };
15
8
  const contexts = new Map();
16
9
  const activeUndoers = new Map();
17
10
  // Helper to capture current hooks state
18
11
  function captureRestorers() {
19
- if (hooks.size === 0)
12
+ if (asyncCore.hooks.size === 0)
20
13
  return [];
21
14
  const restorers = [];
22
- for (const h of hooks) {
15
+ for (const h of asyncCore.hooks) {
23
16
  const r = h();
24
17
  if (r)
25
18
  restorers.push(r);
@@ -50,7 +43,7 @@ function wrap(fn) {
50
43
  };
51
44
  }
52
45
  const hook = node_async_hooks.createHook({
53
- init(asyncId, type, triggerId, resource) {
46
+ init(asyncId, _type, _triggerId, _resource) {
54
47
  // Used for native resources like Timers
55
48
  const restorers = captureRestorers();
56
49
  if (restorers.length > 0)
@@ -100,4 +93,4 @@ OriginalPromise.prototype.catch = function (onRejected) {
100
93
  OriginalPromise.prototype.finally = function (onFinally) {
101
94
  return originalMethods.finally.call(this, wrap(onFinally));
102
95
  };
103
- //# sourceMappingURL=async-node-BYHuGTni.cjs.map
96
+ //# sourceMappingURL=async-node-C3DeIb0y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-node-C3DeIb0y.cjs","sources":["../../src/async/node.ts"],"sourcesContent":["import { createHook } from 'node:async_hooks'\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\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}\n\n// Patch prototype\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"],"mappings":";;;;;AAGA;AACA;AAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAsB;AAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,EAA0B;AAEvD;AACA,SAAS,gBAAgB,GAAA;AACxB,IAAA,IAAIA,eAAK,CAAC,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE;IAC/B,MAAM,SAAS,GAAe,EAAE;AAChC,IAAA,KAAK,MAAM,CAAC,IAAIA,eAAK,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,C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