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.
Files changed (54) hide show
  1. package/BROWSER_ASYNC_POLYFILL.md +79 -0
  2. package/README.md +2 -2
  3. package/dist/browser.cjs +145 -26
  4. package/dist/browser.cjs.map +1 -1
  5. package/dist/browser.d.ts +42 -9
  6. package/dist/browser.dev.cjs +12 -2
  7. package/dist/browser.dev.cjs.map +1 -1
  8. package/dist/browser.dev.d.ts +2 -2
  9. package/dist/browser.dev.esm.js +2 -2
  10. package/dist/browser.esm.js +137 -28
  11. package/dist/browser.esm.js.map +1 -1
  12. package/dist/chunks/{index-CAdnMJev.cjs → index-BnTNC9eC.cjs} +158 -90
  13. package/dist/chunks/index-BnTNC9eC.cjs.map +1 -0
  14. package/dist/chunks/{index-XsYTUhHx.esm.js → index-CAWVZL7P.esm.js} +156 -88
  15. package/dist/chunks/index-CAWVZL7P.esm.js.map +1 -0
  16. package/dist/chunks/node-Df_5r_WA.cjs +187 -0
  17. package/dist/chunks/node-Df_5r_WA.cjs.map +1 -0
  18. package/dist/chunks/node-DuIduHw3.esm.js +185 -0
  19. package/dist/chunks/node-DuIduHw3.esm.js.map +1 -0
  20. package/dist/chunks/{proxy-BtmPFjSr.esm.js → proxy-C2lnvvbx.esm.js} +652 -222
  21. package/dist/chunks/proxy-C2lnvvbx.esm.js.map +1 -0
  22. package/dist/chunks/{proxy-DBHj3kGK.cjs → proxy-HA_QQnd5.cjs} +662 -223
  23. package/dist/chunks/proxy-HA_QQnd5.cjs.map +1 -0
  24. package/dist/debug.cjs +37 -10
  25. package/dist/debug.cjs.map +1 -1
  26. package/dist/debug.esm.js +37 -10
  27. package/dist/debug.esm.js.map +1 -1
  28. package/dist/mutts.umd.js +4086 -3469
  29. package/dist/mutts.umd.js.map +1 -1
  30. package/dist/mutts.umd.min.js +1 -1
  31. package/dist/mutts.umd.min.js.map +1 -1
  32. package/dist/node.cjs +13 -3
  33. package/dist/node.cjs.map +1 -1
  34. package/dist/node.d.ts +2 -2
  35. package/dist/node.dev.cjs +13 -3
  36. package/dist/node.dev.cjs.map +1 -1
  37. package/dist/node.dev.d.ts +2 -2
  38. package/dist/node.dev.esm.js +3 -3
  39. package/dist/node.esm.js +3 -3
  40. package/dist/types.d.ts +30 -15
  41. package/docs/ai/api-reference.md +3 -1
  42. package/docs/ai/manual.md +17 -5
  43. package/docs/reactive/advanced.md +169 -10
  44. package/docs/reactive/debugging.md +15 -13
  45. package/docs/reactive.md +2 -1
  46. package/package.json +12 -7
  47. package/dist/chunks/index-CAdnMJev.cjs.map +0 -1
  48. package/dist/chunks/index-XsYTUhHx.esm.js.map +0 -1
  49. package/dist/chunks/node-DrrphEPf.cjs +0 -98
  50. package/dist/chunks/node-DrrphEPf.cjs.map +0 -1
  51. package/dist/chunks/node-NEZvVo4M.esm.js +0 -96
  52. package/dist/chunks/node-NEZvVo4M.esm.js.map +0 -1
  53. package/dist/chunks/proxy-BtmPFjSr.esm.js.map +0 -1
  54. package/dist/chunks/proxy-DBHj3kGK.cjs.map +0 -1
@@ -1,2 +1,2 @@
1
- export { A as AZone, C as CleanupReason, c as EffectAccess, b as EffectCleanup, d as EffectCloser, g as EffectOptions, E as EffectTrigger, a as Evolution, G as GetterWrapper, H as HistoryValue, P as PropTrigger, R as ReactiveError, h as ReactiveErrorCode, S as ScopedCallback, i as Zone, Z as ZoneAggregator, j as ZoneHistory, k as asyncZone, l as debugPreset, m as devPreset, n as formatCleanupReason, o as isReactive, p as objectToProxy, q as prodPreset, r as proxyToObject, s as reactiveOptions, u as unwrap } from './types.js';
2
- export { ArrayDiffResult, ArrayReadForward, Captioned, CompareSymbol, ContextManager, Decorator, DecoratorDescription, DecoratorError, DecoratorFactory, Destroyable, DestructionError, EffectContext, Eventful, EventsBase, GenericClassDecorator, Hook, Indexable, IterableWeakMap, IterableWeakSet, LegacyClassDecorator, LegacyPropertyDecorator, Memoizable, MemoizableArgument, MixinClass, MixinFunction, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, PromiseChain, ReactiveBase, Resource, Restorer, addBatchCleanup, addUnreactiveProps, allocated, allocatedValues, arrayDiff, arrayEquals, assertUntracked, asyncHook, asyncHooks, atom, atomic, attend, biDi, cache, cached, callOnGC, captioned, captured, caught, chainPromise, createFlavor, debounce, decorator, deepCompare, deepWatch, defer, deprecated, descriptor, destructor, effect, effectAggregator, effectContext, flavorOptions, flavored, forwardArray, getActivationLog, getActiveEffect, getAt, getState, hooks, inheritCaption, isCached, isConstructor, isDev, isNonReactive, isObject, isProd, isTest, legacyDecorator, lift, link, memoize, mixin, modernDecorator, morph, named, onEffectThrow, organize, organized, profileInfo, reactive, reset, resource, root, setAt, tag, throttle, touched, touched1, unlink, unreactive, untracked, watch, when, withEffectContext, zip } from './browser.js';
1
+ export { A as AZone, C as CleanupReason, h as CycleHandlingMode, D as DeprecatedCycleHandlingMode, c as EffectAccess, b as EffectCleanup, d as EffectCloser, g as EffectOptions, E as EffectTrigger, a as Evolution, G as GetterWrapper, H as HistoryValue, P as PropTrigger, R as ReactiveError, i as ReactiveErrorCode, j as SchedulerMode, S as ScopedCallback, k as Zone, Z as ZoneAggregator, l as ZoneHistory, m as asyncZone, n as debugPreset, o as devPreset, p as formatCleanupReason, q as isReactive, r as objectToProxy, s as prodPreset, t as proxyToObject, u as reactiveOptions, v as toRaw, w as unwrap } from './types.js';
2
+ export { ArrayDiffResult, ArrayReadForward, Captioned, CompareSymbol, ContextManager, Decorator, DecoratorDescription, DecoratorError, DecoratorFactory, Destroyable, DestructionError, EffectContext, Eventful, EventsBase, GenericClassDecorator, Hook, Indexable, IterableWeakMap, IterableWeakSet, LegacyClassDecorator, LegacyPropertyDecorator, Memoizable, MemoizableArgument, MixinClass, MixinFunction, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, MorphPosition, PromiseChain, ReactiveBase, Resource, Restorer, addBatchCleanup, addUnreactiveProps, allocated, allocatedValues, arrayDiff, arrayEquals, assertUntracked, asyncHook, asyncHooks, atom, atomic, attend, biDi, cache, cached, callOnGC, captioned, captured, caught, chainPromise, createFlavor, debounce, decorator, deepCompare, deepWatch, defer, deprecated, descriptor, destructor, effect, effectAggregator, effectContext, flavorOptions, flavored, forwardArray, getActivationLog, getActiveEffect, getAt, getState, hooks, inert, inheritCaption, isCached, isConstructor, isDev, isNonReactive, isObject, isProd, isReactiveBroken, isTest, legacyDecorator, lift, link, markRaw, markRawProps, memoize, mixin, modernDecorator, morph, named, onEffectThrow, onReactiveBroken, onReactiveReset, organize, organized, profileInfo, reactive, readonlyReactive, reset, resource, root, setAt, shallowReactive, tag, throttle, touched, touched1, unlink, unreactive, untracked, watch, when, withEffectContext, wrapInert, zip } from './browser.js';
@@ -1,5 +1,5 @@
1
1
  import './debug.esm.js';
2
2
  import './browser.esm.js';
3
- export { A as ArrayReadForward, D as Destroyable, a as DestructionError, E as Eventful, I as Indexable, b as allocated, c as allocatedValues, d as arrayDiff, e as attend, f as cache, g as cached, h as callOnGC, i as chainPromise, j as debounce, k as deepWatch, l as deprecated, m as descriptor, n as destructor, o as forwardArray, p as getAt, q as isCached, r as lift, s as memoize, t as morph, u as organize, v as organized, w as profileInfo, x as resource, y as setAt, z as throttle, B as unreactive, C as watch, F as when } from './chunks/index-XsYTUhHx.esm.js';
4
- export { A as AZone, C as CompareSymbol, D as DecoratorError, I as IterableWeakMap, a as IterableWeakSet, R as ReactiveBase, b as ReactiveError, c as ReactiveErrorCode, Z as Zone, d as ZoneAggregator, e as ZoneHistory, f as addBatchCleanup, g as addUnreactiveProps, h as arrayEquals, i as assertUntracked, j as asyncHook, k as asyncHooks, l as asyncZone, m as atom, n as atomic, o as biDi, p as captioned, q as captured, r as caught, s as createFlavor, t as debugPreset, u as decorator, v as deepCompare, w as defer, x as devPreset, y as effect, z as effectAggregator, B as effectContext, E as flavorOptions, F as flavored, G as formatCleanupReason, H as getActivationLog, J as getActiveEffect, K as getState, L as hooks, M as inheritCaption, N as isConstructor, O as isDev, P as isNonReactive, Q as isObject, S as isProd, T as isReactive, U as isTest, V as legacyDecorator, W as link, X as mixin, Y as modernDecorator, _ as named, $ as objectToProxy, a0 as onEffectThrow, a1 as prodPreset, a2 as proxyToObject, a3 as reactive, a4 as reactiveOptions, a5 as reset, a6 as root, a7 as tag, a8 as touched, a9 as touched1, aa as unlink, ab as untracked, ac as unwrap, ad as withEffectContext, ae as zip } from './chunks/proxy-BtmPFjSr.esm.js';
3
+ export { A as ArrayReadForward, D as Destroyable, a as DestructionError, E as Eventful, I as Indexable, b as allocated, c as allocatedValues, d as arrayDiff, e as attend, f as cache, g as cached, h as callOnGC, i as chainPromise, j as debounce, k as deepWatch, l as deprecated, m as descriptor, n as destructor, o as forwardArray, p as getAt, q as isCached, r as lift, s as memoize, t as morph, u as organize, v as organized, w as profileInfo, x as resource, y as setAt, z as throttle, B as unreactive, C as watch, F as when } from './chunks/index-CAWVZL7P.esm.js';
4
+ export { A as AZone, C as CompareSymbol, D as DecoratorError, I as IterableWeakMap, a as IterableWeakSet, R as ReactiveBase, b as ReactiveError, c as ReactiveErrorCode, Z as Zone, d as ZoneAggregator, e as ZoneHistory, f as addBatchCleanup, g as addUnreactiveProps, h as arrayEquals, i as assertUntracked, j as asyncHook, k as asyncHooks, l as asyncZone, m as atom, n as atomic, o as biDi, p as captioned, q as captured, r as caught, s as createFlavor, t as debugPreset, u as decorator, v as deepCompare, w as defer, x as devPreset, y as effect, z as effectAggregator, B as effectContext, E as flavorOptions, F as flavored, G as formatCleanupReason, H as getActivationLog, J as getActiveEffect, K as getState, L as hooks, M as inert, N as inheritCaption, O as isConstructor, P as isDev, Q as isNonReactive, S as isObject, T as isProd, U as isReactive, V as isReactiveBroken, W as isTest, X as legacyDecorator, Y as link, _ as markRaw, $ as markRawProps, a0 as mixin, a1 as modernDecorator, a2 as named, a3 as objectToProxy, a4 as onEffectThrow, a5 as onReactiveBroken, a6 as onReactiveReset, a7 as prodPreset, a8 as proxyToObject, a9 as reactive, aa as reactiveOptions, ab as readonlyReactive, ac as reset, ad as root, ae as shallowReactive, af as tag, ag as toRaw, ah as touched, ai as touched1, aj as unlink, ak as untracked, al as unwrap, am as withEffectContext, an as wrapInert, ao as zip } from './chunks/proxy-C2lnvvbx.esm.js';
5
5
  //# sourceMappingURL=browser.dev.esm.js.map
@@ -1,6 +1,6 @@
1
- import { L as hooks, k as asyncHooks } from './chunks/proxy-BtmPFjSr.esm.js';
2
- export { A as AZone, C as CompareSymbol, D as DecoratorError, I as IterableWeakMap, a as IterableWeakSet, R as ReactiveBase, b as ReactiveError, c as ReactiveErrorCode, Z as Zone, d as ZoneAggregator, e as ZoneHistory, f as addBatchCleanup, g as addUnreactiveProps, h as arrayEquals, i as assertUntracked, j as asyncHook, l as asyncZone, m as atom, n as atomic, o as biDi, p as captioned, q as captured, r as caught, s as createFlavor, t as debugPreset, u as decorator, v as deepCompare, w as defer, x as devPreset, y as effect, z as effectAggregator, B as effectContext, E as flavorOptions, F as flavored, G as formatCleanupReason, H as getActivationLog, J as getActiveEffect, K as getState, M as inheritCaption, N as isConstructor, O as isDev, P as isNonReactive, Q as isObject, S as isProd, T as isReactive, U as isTest, V as legacyDecorator, W as link, X as mixin, Y as modernDecorator, _ as named, $ as objectToProxy, a0 as onEffectThrow, a1 as prodPreset, a2 as proxyToObject, a3 as reactive, a4 as reactiveOptions, a5 as reset, a6 as root, a7 as tag, a8 as touched, a9 as touched1, aa as unlink, ab as untracked, ac as unwrap, ad as withEffectContext, ae as zip } from './chunks/proxy-BtmPFjSr.esm.js';
3
- export { A as ArrayReadForward, D as Destroyable, a as DestructionError, E as Eventful, I as Indexable, b as allocated, c as allocatedValues, d as arrayDiff, e as attend, f as cache, g as cached, h as callOnGC, i as chainPromise, j as debounce, k as deepWatch, l as deprecated, m as descriptor, n as destructor, o as forwardArray, p as getAt, q as isCached, r as lift, s as memoize, t as morph, u as organize, v as organized, w as profileInfo, x as resource, y as setAt, z as throttle, B as unreactive, C as watch, F as when } from './chunks/index-XsYTUhHx.esm.js';
1
+ import { k as asyncHooks, a5 as onReactiveBroken, a6 as onReactiveReset, L as hooks } from './chunks/proxy-C2lnvvbx.esm.js';
2
+ export { A as AZone, C as CompareSymbol, D as DecoratorError, I as IterableWeakMap, a as IterableWeakSet, R as ReactiveBase, b as ReactiveError, c as ReactiveErrorCode, Z as Zone, d as ZoneAggregator, e as ZoneHistory, f as addBatchCleanup, g as addUnreactiveProps, h as arrayEquals, i as assertUntracked, j as asyncHook, l as asyncZone, m as atom, n as atomic, o as biDi, p as captioned, q as captured, r as caught, s as createFlavor, t as debugPreset, u as decorator, v as deepCompare, w as defer, x as devPreset, y as effect, z as effectAggregator, B as effectContext, E as flavorOptions, F as flavored, G as formatCleanupReason, H as getActivationLog, J as getActiveEffect, K as getState, M as inert, N as inheritCaption, O as isConstructor, P as isDev, Q as isNonReactive, S as isObject, T as isProd, U as isReactive, V as isReactiveBroken, W as isTest, X as legacyDecorator, Y as link, _ as markRaw, $ as markRawProps, a0 as mixin, a1 as modernDecorator, a2 as named, a3 as objectToProxy, a4 as onEffectThrow, a7 as prodPreset, a8 as proxyToObject, a9 as reactive, aa as reactiveOptions, ab as readonlyReactive, ac as reset, ad as root, ae as shallowReactive, af as tag, ag as toRaw, ah as touched, ai as touched1, aj as unlink, ak as untracked, al as unwrap, am as withEffectContext, an as wrapInert, ao as zip } from './chunks/proxy-C2lnvvbx.esm.js';
3
+ export { A as ArrayReadForward, D as Destroyable, a as DestructionError, E as Eventful, I as Indexable, b as allocated, c as allocatedValues, d as arrayDiff, e as attend, f as cache, g as cached, h as callOnGC, i as chainPromise, j as debounce, k as deepWatch, l as deprecated, m as descriptor, n as destructor, o as forwardArray, p as getAt, q as isCached, r as lift, s as memoize, t as morph, u as organize, v as organized, w as profileInfo, x as resource, y as setAt, z as throttle, B as unreactive, C as watch, F as when } from './chunks/index-CAWVZL7P.esm.js';
4
4
 
5
5
  const promiseContexts = new WeakMap();
6
6
  // [HACK]: Sanitization
@@ -39,28 +39,14 @@ function wrap(fn, capturedRestorers) {
39
39
  return fn.apply(this, args);
40
40
  }
41
41
  finally {
42
- /* cf BROWSER_ASYNC_POLYFILL.md
43
- // Note: my fear about this code: in between 2~3~4 microtask waits, some other microtasks might have started, stopped, ...
44
- // We might be in the middle of another promise hook trying to setup the zone
45
- // TODO We might wish to have a flag :asyncZone.acquired - like a semaphore - that we falsify here and set back when we setup the zone
46
- // - but this might perhaps be an overkill creating more problems than it solves
47
- if (originals.queueMicrotask) {
48
- // Double microtask ensures we run after the first await resumption microtask
49
- originals.queueMicrotask.call(globalThis, () => {
50
- originals.queueMicrotask.call(globalThis, () => {
51
- originals.queueMicrotask.call(globalThis, () => {
52
- for (let i = undoers.length - 1; i >= 0; i--) undoers[i]()
53
- })
54
- })
55
- })
56
- } else {
57
- for (let i = undoers.length - 1; i >= 0; i--) undoers[i]()
58
- }*/
42
+ // Browser async context is backed by sticky Promise metadata. Running undoers here
43
+ // breaks await propagation and can orphan reactive resource observers.
59
44
  }
60
45
  };
61
46
  }
62
47
  const GLOBAL_ORIGINALS = Symbol.for('mutts.originals');
63
48
  const GLOBAL_PROMISE = Symbol.for('mutts.OriginalPromise');
49
+ const schedulerGlobal = globalThis;
64
50
  let originals;
65
51
  let OriginalPromise;
66
52
  if (globalThis[GLOBAL_ORIGINALS]) {
@@ -81,9 +67,13 @@ else {
81
67
  race: OriginalPromise.race,
82
68
  any: OriginalPromise.any,
83
69
  setTimeout: globalThis.setTimeout,
70
+ clearTimeout: globalThis.clearTimeout,
84
71
  setInterval: globalThis.setInterval,
85
- setImmediate: globalThis.setImmediate,
86
- requestAnimationFrame: globalThis.requestAnimationFrame,
72
+ clearInterval: globalThis.clearInterval,
73
+ setImmediate: schedulerGlobal.setImmediate,
74
+ clearImmediate: schedulerGlobal.clearImmediate,
75
+ requestAnimationFrame: schedulerGlobal.requestAnimationFrame,
76
+ cancelAnimationFrame: schedulerGlobal.cancelAnimationFrame,
87
77
  queueMicrotask: globalThis.queueMicrotask,
88
78
  };
89
79
  globalThis[GLOBAL_ORIGINALS] = originals;
@@ -96,6 +86,74 @@ if (!originals.any)
96
86
  originals.any = OriginalPromise.any;
97
87
  if (!originals.race)
98
88
  originals.race = OriginalPromise.race;
89
+ if (!originals.clearTimeout)
90
+ originals.clearTimeout = globalThis.clearTimeout;
91
+ if (!originals.clearInterval)
92
+ originals.clearInterval = globalThis.clearInterval;
93
+ if (!originals.clearImmediate)
94
+ originals.clearImmediate = schedulerGlobal.clearImmediate;
95
+ if (!originals.cancelAnimationFrame)
96
+ originals.cancelAnimationFrame = schedulerGlobal.cancelAnimationFrame;
97
+ const pendingTimeouts = new Set();
98
+ const pendingIntervals = new Set();
99
+ const pendingImmediates = new Set();
100
+ const pendingAnimationFrames = new Set();
101
+ let asyncSchedulersFrozen = false;
102
+ function clearPendingSchedulers() {
103
+ for (const handle of Array.from(pendingTimeouts))
104
+ originals.clearTimeout.call(globalThis, handle);
105
+ for (const handle of Array.from(pendingIntervals))
106
+ originals.clearInterval.call(globalThis, handle);
107
+ if (originals.clearImmediate) {
108
+ for (const handle of Array.from(pendingImmediates)) {
109
+ originals.clearImmediate.call(globalThis, handle);
110
+ }
111
+ }
112
+ if (originals.cancelAnimationFrame) {
113
+ for (const handle of Array.from(pendingAnimationFrames)) {
114
+ originals.cancelAnimationFrame.call(globalThis, handle);
115
+ }
116
+ }
117
+ pendingTimeouts.clear();
118
+ pendingIntervals.clear();
119
+ pendingImmediates.clear();
120
+ pendingAnimationFrames.clear();
121
+ }
122
+ function freezeAsyncSchedulers() {
123
+ if (asyncSchedulersFrozen)
124
+ return;
125
+ asyncSchedulersFrozen = true;
126
+ clearPendingSchedulers();
127
+ }
128
+ function resumeAsyncSchedulers() {
129
+ asyncSchedulersFrozen = false;
130
+ }
131
+ function canceledTimeoutHandle() {
132
+ const handle = originals.setTimeout.call(globalThis, () => { }, 0);
133
+ originals.clearTimeout.call(globalThis, handle);
134
+ return handle;
135
+ }
136
+ function canceledIntervalHandle() {
137
+ const handle = originals.setInterval.call(globalThis, () => { }, 0);
138
+ originals.clearInterval.call(globalThis, handle);
139
+ return handle;
140
+ }
141
+ function canceledImmediateHandle() {
142
+ if (!originals.setImmediate || !originals.clearImmediate)
143
+ return undefined;
144
+ const handle = originals.setImmediate.call(globalThis, () => { });
145
+ originals.clearImmediate.call(globalThis, handle);
146
+ return handle;
147
+ }
148
+ function canceledAnimationFrameHandle() {
149
+ if (!originals.requestAnimationFrame || !originals.cancelAnimationFrame)
150
+ return 0;
151
+ const handle = originals.requestAnimationFrame.call(globalThis, () => { });
152
+ originals.cancelAnimationFrame.call(globalThis, handle);
153
+ return handle;
154
+ }
155
+ onReactiveBroken(freezeAsyncSchedulers);
156
+ onReactiveReset(resumeAsyncSchedulers);
99
157
  function patchedThen(onFulfilled, onRejected) {
100
158
  const context = promiseContexts.get(this) || captureRestorers();
101
159
  const nextPromise = originals.then.call(this, wrap(onFulfilled, context), wrap(onRejected, context));
@@ -195,19 +253,70 @@ try {
195
253
  catch (_e) { }
196
254
  globalThis.Promise = PatchedPromise;
197
255
  globalThis.setTimeout = ((callback, ...args) => {
198
- return originals.setTimeout.call(globalThis, wrap(callback), ...args);
256
+ if (asyncSchedulersFrozen)
257
+ return canceledTimeoutHandle();
258
+ const wrapped = wrap(callback);
259
+ const handle = originals.setTimeout.call(globalThis, (...callbackArgs) => {
260
+ pendingTimeouts.delete(handle);
261
+ wrapped(...callbackArgs);
262
+ }, ...args);
263
+ pendingTimeouts.add(handle);
264
+ return handle;
265
+ });
266
+ globalThis.clearTimeout = ((handle) => {
267
+ pendingTimeouts.delete(handle);
268
+ return originals.clearTimeout.call(globalThis, handle);
199
269
  });
200
270
  globalThis.setInterval = ((callback, ...args) => {
201
- return originals.setInterval.call(globalThis, wrap(callback), ...args);
271
+ if (asyncSchedulersFrozen)
272
+ return canceledIntervalHandle();
273
+ const wrapped = wrap(callback);
274
+ const handle = originals.setInterval.call(globalThis, (...callbackArgs) => {
275
+ wrapped(...callbackArgs);
276
+ }, ...args);
277
+ pendingIntervals.add(handle);
278
+ return handle;
279
+ });
280
+ globalThis.clearInterval = ((handle) => {
281
+ pendingIntervals.delete(handle);
282
+ return originals.clearInterval.call(globalThis, handle);
202
283
  });
203
284
  if (originals.setImmediate) {
204
- globalThis.setImmediate = ((callback, ...args) => {
205
- return originals.setImmediate.call(globalThis, wrap(callback), ...args);
285
+ schedulerGlobal.setImmediate = ((callback, ...args) => {
286
+ if (asyncSchedulersFrozen)
287
+ return canceledImmediateHandle();
288
+ const wrapped = wrap(callback);
289
+ const handle = originals.setImmediate.call(globalThis, (...callbackArgs) => {
290
+ pendingImmediates.delete(handle);
291
+ wrapped(...callbackArgs);
292
+ }, ...args);
293
+ pendingImmediates.add(handle);
294
+ return handle;
295
+ });
296
+ }
297
+ if (originals.clearImmediate) {
298
+ schedulerGlobal.clearImmediate = ((handle) => {
299
+ pendingImmediates.delete(handle);
300
+ return originals.clearImmediate.call(globalThis, handle);
206
301
  });
207
302
  }
208
303
  if (originals.requestAnimationFrame) {
209
304
  globalThis.requestAnimationFrame = (callback) => {
210
- return originals.requestAnimationFrame.call(globalThis, wrap(callback));
305
+ if (asyncSchedulersFrozen)
306
+ return canceledAnimationFrameHandle();
307
+ const wrapped = wrap(callback);
308
+ const handle = originals.requestAnimationFrame.call(globalThis, (time) => {
309
+ pendingAnimationFrames.delete(handle);
310
+ wrapped(time);
311
+ });
312
+ pendingAnimationFrames.add(handle);
313
+ return handle;
314
+ };
315
+ }
316
+ if (originals.cancelAnimationFrame) {
317
+ globalThis.cancelAnimationFrame = (handle) => {
318
+ pendingAnimationFrames.delete(handle);
319
+ return originals.cancelAnimationFrame.call(globalThis, handle);
211
320
  };
212
321
  }
213
322
  if (originals.queueMicrotask) {
@@ -216,5 +325,5 @@ if (originals.queueMicrotask) {
216
325
  };
217
326
  }
218
327
 
219
- export { asyncHooks, hooks };
328
+ export { asyncHooks, hooks, onReactiveBroken, onReactiveReset };
220
329
  //# sourceMappingURL=browser.esm.js.map
@@ -1 +1 @@
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\t/* cf BROWSER_ASYNC_POLYFILL.md\n\t\t\t// Note: my fear about this code: in between 2~3~4 microtask waits, some other microtasks might have started, stopped, ...\n\t\t\t// We might be in the middle of another promise hook trying to setup the zone\n\t\t\t// TODO We might wish to have a flag :asyncZone.acquired - like a semaphore - that we falsify here and set back when we setup the zone\n\t\t\t// - but this might perhaps be an overkill creating more problems than it solves\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 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\t// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\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\t// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\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,C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"sourcesContent":["import { onReactiveBroken, onReactiveReset } from '../reactive/effects'\nimport { 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\t// Browser async context is backed by sticky Promise metadata. Running undoers here\n\t\t\t// breaks await propagation and can orphan reactive resource observers.\n\t\t}\n\t}\n}\n\nconst GLOBAL_ORIGINALS = Symbol.for('mutts.originals')\nconst GLOBAL_PROMISE = Symbol.for('mutts.OriginalPromise')\n\ntype SchedulerGlobal = typeof globalThis & {\n\tsetImmediate?: typeof setImmediate\n\tclearImmediate?: typeof clearImmediate\n\trequestAnimationFrame?: typeof requestAnimationFrame\n\tcancelAnimationFrame?: typeof cancelAnimationFrame\n}\n\nconst schedulerGlobal = globalThis as SchedulerGlobal\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\t// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\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\tclearTimeout: globalThis.clearTimeout,\n\t\tsetInterval: globalThis.setInterval,\n\t\tclearInterval: globalThis.clearInterval,\n\t\tsetImmediate: schedulerGlobal.setImmediate,\n\t\tclearImmediate: schedulerGlobal.clearImmediate,\n\t\trequestAnimationFrame: schedulerGlobal.requestAnimationFrame,\n\t\tcancelAnimationFrame: schedulerGlobal.cancelAnimationFrame,\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\nif (!originals.clearTimeout) originals.clearTimeout = globalThis.clearTimeout\nif (!originals.clearInterval) originals.clearInterval = globalThis.clearInterval\nif (!originals.clearImmediate) originals.clearImmediate = schedulerGlobal.clearImmediate\nif (!originals.cancelAnimationFrame)\n\toriginals.cancelAnimationFrame = schedulerGlobal.cancelAnimationFrame\n\nconst pendingTimeouts = new Set<unknown>()\nconst pendingIntervals = new Set<unknown>()\nconst pendingImmediates = new Set<unknown>()\nconst pendingAnimationFrames = new Set<unknown>()\nlet asyncSchedulersFrozen = false\n\nfunction clearPendingSchedulers() {\n\tfor (const handle of Array.from(pendingTimeouts)) originals.clearTimeout.call(globalThis, handle)\n\tfor (const handle of Array.from(pendingIntervals))\n\t\toriginals.clearInterval.call(globalThis, handle)\n\tif (originals.clearImmediate) {\n\t\tfor (const handle of Array.from(pendingImmediates)) {\n\t\t\toriginals.clearImmediate.call(globalThis, handle)\n\t\t}\n\t}\n\tif (originals.cancelAnimationFrame) {\n\t\tfor (const handle of Array.from(pendingAnimationFrames)) {\n\t\t\toriginals.cancelAnimationFrame.call(globalThis, handle)\n\t\t}\n\t}\n\tpendingTimeouts.clear()\n\tpendingIntervals.clear()\n\tpendingImmediates.clear()\n\tpendingAnimationFrames.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 = originals.setTimeout.call(globalThis, () => {}, 0)\n\toriginals.clearTimeout.call(globalThis, handle)\n\treturn handle\n}\n\nfunction canceledIntervalHandle() {\n\tconst handle = originals.setInterval.call(globalThis, () => {}, 0)\n\toriginals.clearInterval.call(globalThis, handle)\n\treturn handle\n}\n\nfunction canceledImmediateHandle() {\n\tif (!originals.setImmediate || !originals.clearImmediate) return undefined\n\tconst handle = originals.setImmediate.call(globalThis, () => {})\n\toriginals.clearImmediate.call(globalThis, handle)\n\treturn handle\n}\n\nfunction canceledAnimationFrameHandle() {\n\tif (!originals.requestAnimationFrame || !originals.cancelAnimationFrame) return 0\n\tconst handle = originals.requestAnimationFrame.call(globalThis, () => {})\n\toriginals.cancelAnimationFrame.call(globalThis, handle)\n\treturn handle\n}\n\nonReactiveBroken(freezeAsyncSchedulers)\nonReactiveReset(resumeAsyncSchedulers)\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\t// biome-ignore lint/suspicious/noThenProperty: Intentional Promise.prototype patching\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\tif (asyncSchedulersFrozen) return canceledTimeoutHandle()\n\tconst wrapped = wrap(callback as any)\n\tconst handle = originals.setTimeout.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\tpendingTimeouts.delete(handle)\n\t\t\twrapped(...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 originals.clearTimeout.call(globalThis, handle)\n}) as typeof globalThis.clearTimeout\n\nglobalThis.setInterval = ((callback: Function, ...args: any[]) => {\n\tif (asyncSchedulersFrozen) return canceledIntervalHandle()\n\tconst wrapped = wrap(callback as any)\n\tconst handle = originals.setInterval.call(\n\t\tglobalThis,\n\t\t(...callbackArgs: any[]) => {\n\t\t\twrapped(...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 originals.clearInterval.call(globalThis, handle)\n}) as typeof globalThis.clearInterval\n\nif (originals.setImmediate) {\n\tschedulerGlobal.setImmediate = ((callback: Function, ...args: any[]) => {\n\t\tif (asyncSchedulersFrozen) return canceledImmediateHandle()\n\t\tconst wrapped = wrap(callback as any)\n\t\tconst handle = originals.setImmediate.call(\n\t\t\tglobalThis,\n\t\t\t(...callbackArgs: any[]) => {\n\t\t\t\tpendingImmediates.delete(handle)\n\t\t\t\twrapped(...callbackArgs)\n\t\t\t},\n\t\t\t...args\n\t\t)\n\t\tpendingImmediates.add(handle)\n\t\treturn handle\n\t}) as typeof setImmediate\n}\n\nif (originals.clearImmediate) {\n\tschedulerGlobal.clearImmediate = ((handle?: unknown) => {\n\t\tpendingImmediates.delete(handle)\n\t\treturn originals.clearImmediate.call(globalThis, handle)\n\t}) as typeof clearImmediate\n}\n\nif (originals.requestAnimationFrame) {\n\tglobalThis.requestAnimationFrame = (callback: FrameRequestCallback) => {\n\t\tif (asyncSchedulersFrozen) return canceledAnimationFrameHandle()\n\t\tconst wrapped = wrap(callback)\n\t\tconst handle = originals.requestAnimationFrame.call(globalThis, (time: DOMHighResTimeStamp) => {\n\t\t\tpendingAnimationFrames.delete(handle)\n\t\t\twrapped(time)\n\t\t})\n\t\tpendingAnimationFrames.add(handle)\n\t\treturn handle\n\t}\n}\n\nif (originals.cancelAnimationFrame) {\n\tglobalThis.cancelAnimationFrame = (handle: number) => {\n\t\tpendingAnimationFrames.delete(handle)\n\t\treturn originals.cancelAnimationFrame.call(globalThis, handle)\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":";;;;AAGA,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,C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