@bluelibs/runner 4.5.0-alpha.2 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4,12 +4,7 @@ var __defProp = Object.defineProperty;
4
4
  var __typeError = (msg) => {
5
5
  throw TypeError(msg);
6
6
  };
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
8
  var __export = (target, all) => {
14
9
  for (var name in all)
15
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -43,34 +38,34 @@ __export(defs_exports, {
43
38
  });
44
39
 
45
40
  // src/types/symbols.ts
46
- var symbolTask = Symbol("runner.task");
47
- var symbolResource = Symbol("runner.resource");
48
- var symbolResourceWithConfig = Symbol(
41
+ var symbolTask = Symbol.for("runner.task");
42
+ var symbolResource = Symbol.for("runner.resource");
43
+ var symbolResourceWithConfig = Symbol.for(
49
44
  "runner.resourceWithConfig"
50
45
  );
51
- var symbolEvent = Symbol("runner.event");
52
- var symbolMiddleware = Symbol("runner.middleware");
53
- var symbolTaskMiddleware = Symbol(
46
+ var symbolEvent = Symbol.for("runner.event");
47
+ var symbolMiddleware = Symbol.for("runner.middleware");
48
+ var symbolTaskMiddleware = Symbol.for(
54
49
  "runner.taskMiddleware"
55
50
  );
56
- var symbolResourceMiddleware = Symbol(
51
+ var symbolResourceMiddleware = Symbol.for(
57
52
  "runner.resourceMiddleware"
58
53
  );
59
- var symbolMiddlewareConfigured = Symbol(
54
+ var symbolMiddlewareConfigured = Symbol.for(
60
55
  "runner.middlewareConfigured"
61
56
  );
62
- var symbolHook = Symbol("runner.hook");
63
- var symbolTag = Symbol("runner.tag");
64
- var symbolTagConfigured = Symbol(
57
+ var symbolHook = Symbol.for("runner.hook");
58
+ var symbolTag = Symbol.for("runner.tag");
59
+ var symbolTagConfigured = Symbol.for(
65
60
  "runner.tagConfigured"
66
61
  );
67
- var symbolOptionalDependency = Symbol(
62
+ var symbolOptionalDependency = Symbol.for(
68
63
  "runner.optionalDependency"
69
64
  );
70
- var symbolFilePath = Symbol("runner.filePath");
71
- var symbolDispose = Symbol("runner.dispose");
72
- var symbolStore = Symbol("runner.store");
73
- var symbolIndexResource = Symbol(
65
+ var symbolFilePath = Symbol.for("runner.filePath");
66
+ var symbolDispose = Symbol.for("runner.dispose");
67
+ var symbolStore = Symbol.for("runner.store");
68
+ var symbolIndexResource = Symbol.for(
74
69
  "runner.indexResource"
75
70
  );
76
71
 
@@ -78,14 +73,16 @@ var symbolIndexResource = Symbol(
78
73
  function onAnyOf(...defs) {
79
74
  return defs;
80
75
  }
76
+ __name(onAnyOf, "onAnyOf");
81
77
  function isOneOf(emission, defs) {
82
78
  return defs.some((d) => d.id === emission.id);
83
79
  }
80
+ __name(isOneOf, "isOneOf");
84
81
  var cacheFactoryTask = defineTask({
85
82
  id: "globals.tasks.cacheFactory",
86
- run: async (options) => {
83
+ run: /* @__PURE__ */ __name(async (options) => {
87
84
  return new LRUCache(options);
88
- }
85
+ }, "run")
89
86
  });
90
87
  var cacheResource = defineResource({
91
88
  id: "globals.resources.cache",
@@ -93,7 +90,7 @@ var cacheResource = defineResource({
93
90
  dependencies: {
94
91
  cacheFactoryTask
95
92
  },
96
- init: async (config, { cacheFactoryTask: cacheFactoryTask2 }) => {
93
+ init: /* @__PURE__ */ __name(async (config, { cacheFactoryTask: cacheFactoryTask2 }) => {
97
94
  return {
98
95
  map: /* @__PURE__ */ new Map(),
99
96
  cacheFactoryTask: cacheFactoryTask2,
@@ -106,14 +103,14 @@ var cacheResource = defineResource({
106
103
  ...config.defaultOptions
107
104
  }
108
105
  };
109
- },
110
- dispose: async (cache) => {
106
+ }, "init"),
107
+ dispose: /* @__PURE__ */ __name(async (cache) => {
111
108
  for (const cacheInstance of cache.map.values()) {
112
109
  await cacheInstance.clear();
113
110
  }
114
- }
111
+ }, "dispose")
115
112
  });
116
- var defaultKeyBuilder = (taskId, input) => `${taskId}-${JSON.stringify(input)}`;
113
+ var defaultKeyBuilder = /* @__PURE__ */ __name((taskId, input) => `${taskId}-${JSON.stringify(input)}`, "defaultKeyBuilder");
117
114
  var cacheMiddleware = defineTaskMiddleware({
118
115
  id: "globals.middleware.cache",
119
116
  dependencies: { cache: cacheResource },
@@ -167,6 +164,7 @@ function getCallerFile() {
167
164
  Error.prepareStackTrace = originalFunc;
168
165
  }
169
166
  }
167
+ __name(getCallerFile, "getCallerFile");
170
168
 
171
169
  // src/definers/defineTask.ts
172
170
  function defineTask(taskConfig) {
@@ -192,6 +190,7 @@ function defineTask(taskConfig) {
192
190
  }
193
191
  };
194
192
  }
193
+ __name(defineTask, "defineTask");
195
194
 
196
195
  // src/definers/defineHook.ts
197
196
  function defineHook(hookDef) {
@@ -208,6 +207,7 @@ function defineHook(hookDef) {
208
207
  tags: hookDef.tags || []
209
208
  };
210
209
  }
210
+ __name(defineHook, "defineHook");
211
211
 
212
212
  // src/errors.ts
213
213
  var errors_exports = {};
@@ -229,13 +229,15 @@ __export(errors_exports, {
229
229
  UnknownItemTypeError: () => UnknownItemTypeError,
230
230
  ValidationError: () => ValidationError
231
231
  });
232
- var RuntimeError = class extends Error {
232
+ var _RuntimeError = class _RuntimeError extends Error {
233
233
  constructor(message) {
234
234
  super(message);
235
235
  this.name = "RuntimeError";
236
236
  }
237
237
  };
238
- var DuplicateRegistrationError = class extends RuntimeError {
238
+ __name(_RuntimeError, "RuntimeError");
239
+ var RuntimeError = _RuntimeError;
240
+ var _DuplicateRegistrationError = class _DuplicateRegistrationError extends RuntimeError {
239
241
  constructor(type, id2) {
240
242
  super(
241
243
  `${type} "${id2.toString()}" already registered. You might have used the same 'id' in two different components or you may have registered the same element twice.`
@@ -243,7 +245,9 @@ var DuplicateRegistrationError = class extends RuntimeError {
243
245
  this.name = "DuplicateRegistrationError";
244
246
  }
245
247
  };
246
- var DependencyNotFoundError = class extends RuntimeError {
248
+ __name(_DuplicateRegistrationError, "DuplicateRegistrationError");
249
+ var DuplicateRegistrationError = _DuplicateRegistrationError;
250
+ var _DependencyNotFoundError = class _DependencyNotFoundError extends RuntimeError {
247
251
  constructor(key) {
248
252
  super(
249
253
  `Dependency ${key.toString()} not found. Did you forget to register it through a resource?`
@@ -251,7 +255,9 @@ var DependencyNotFoundError = class extends RuntimeError {
251
255
  this.name = "DependencyNotFoundError";
252
256
  }
253
257
  };
254
- var UnknownItemTypeError = class extends RuntimeError {
258
+ __name(_DependencyNotFoundError, "DependencyNotFoundError");
259
+ var DependencyNotFoundError = _DependencyNotFoundError;
260
+ var _UnknownItemTypeError = class _UnknownItemTypeError extends RuntimeError {
255
261
  constructor(item) {
256
262
  super(
257
263
  `Unknown item type: ${item}. Please ensure you are not using different versions of '@bluelibs/runner'`
@@ -259,13 +265,17 @@ var UnknownItemTypeError = class extends RuntimeError {
259
265
  this.name = "UnknownItemTypeError";
260
266
  }
261
267
  };
262
- var ContextError = class extends Error {
268
+ __name(_UnknownItemTypeError, "UnknownItemTypeError");
269
+ var UnknownItemTypeError = _UnknownItemTypeError;
270
+ var _ContextError = class _ContextError extends Error {
263
271
  constructor(message) {
264
272
  super(message);
265
273
  this.name = "ContextError";
266
274
  }
267
275
  };
268
- var CircularDependenciesError = class extends RuntimeError {
276
+ __name(_ContextError, "ContextError");
277
+ var ContextError = _ContextError;
278
+ var _CircularDependenciesError = class _CircularDependenciesError extends RuntimeError {
269
279
  constructor(cycles) {
270
280
  const cycleDetails = cycles.map((cycle) => ` \u2022 ${cycle}`).join("\n");
271
281
  const hasMiddleware = cycles.some((cycle) => cycle.includes("middleware"));
@@ -281,13 +291,17 @@ ${cycleDetails}${guidance}`);
281
291
  this.name = "CircularDependenciesError";
282
292
  }
283
293
  };
284
- var EventNotFoundError = class extends RuntimeError {
294
+ __name(_CircularDependenciesError, "CircularDependenciesError");
295
+ var CircularDependenciesError = _CircularDependenciesError;
296
+ var _EventNotFoundError = class _EventNotFoundError extends RuntimeError {
285
297
  constructor(id2) {
286
298
  super(`Event "${id2.toString()}" not found. Did you forget to register it?`);
287
299
  this.name = "EventNotFoundError";
288
300
  }
289
301
  };
290
- var ResourceNotFoundError = class extends RuntimeError {
302
+ __name(_EventNotFoundError, "EventNotFoundError");
303
+ var EventNotFoundError = _EventNotFoundError;
304
+ var _ResourceNotFoundError = class _ResourceNotFoundError extends RuntimeError {
291
305
  constructor(id2) {
292
306
  super(
293
307
  `Resource "${id2.toString()}" not found. Did you forget to register it or are you using the correct id?`
@@ -295,7 +309,9 @@ var ResourceNotFoundError = class extends RuntimeError {
295
309
  this.name = "ResourceNotFoundError";
296
310
  }
297
311
  };
298
- var MiddlewareNotRegisteredError = class extends RuntimeError {
312
+ __name(_ResourceNotFoundError, "ResourceNotFoundError");
313
+ var ResourceNotFoundError = _ResourceNotFoundError;
314
+ var _MiddlewareNotRegisteredError = class _MiddlewareNotRegisteredError extends RuntimeError {
299
315
  constructor(type, source, middlewareId) {
300
316
  super(
301
317
  `Middleware inside ${type} "${source}" depends on "${middlewareId}" but it's not registered. Did you forget to register it?`
@@ -303,7 +319,9 @@ var MiddlewareNotRegisteredError = class extends RuntimeError {
303
319
  this.name = `MiddlewareNotRegisteredError: ${type} ${source} ${middlewareId}`;
304
320
  }
305
321
  };
306
- var TagNotFoundError = class extends RuntimeError {
322
+ __name(_MiddlewareNotRegisteredError, "MiddlewareNotRegisteredError");
323
+ var MiddlewareNotRegisteredError = _MiddlewareNotRegisteredError;
324
+ var _TagNotFoundError = class _TagNotFoundError extends RuntimeError {
307
325
  constructor(id2) {
308
326
  super(
309
327
  `Tag "${id2}" not registered. Did you forget to register it inside a resource?`
@@ -311,26 +329,34 @@ var TagNotFoundError = class extends RuntimeError {
311
329
  this.name = "TagNotRegisteredError";
312
330
  }
313
331
  };
314
- var LockedError = class extends RuntimeError {
332
+ __name(_TagNotFoundError, "TagNotFoundError");
333
+ var TagNotFoundError = _TagNotFoundError;
334
+ var _LockedError = class _LockedError extends RuntimeError {
315
335
  constructor(what) {
316
336
  super(`Cannot modify the ${what.toString()} when it is locked.`);
317
337
  this.name = "LockedError";
318
338
  }
319
339
  };
320
- var StoreAlreadyInitializedError = class extends RuntimeError {
340
+ __name(_LockedError, "LockedError");
341
+ var LockedError = _LockedError;
342
+ var _StoreAlreadyInitializedError = class _StoreAlreadyInitializedError extends RuntimeError {
321
343
  constructor() {
322
344
  super("Store already initialized. Cannot reinitialize.");
323
345
  this.name = "StoreAlreadyInitializedError";
324
346
  }
325
347
  };
326
- var ValidationError = class extends RuntimeError {
348
+ __name(_StoreAlreadyInitializedError, "StoreAlreadyInitializedError");
349
+ var StoreAlreadyInitializedError = _StoreAlreadyInitializedError;
350
+ var _ValidationError = class _ValidationError extends RuntimeError {
327
351
  constructor(type, id2, originalError) {
328
352
  const errorMessage = originalError instanceof Error ? originalError.message : String(originalError);
329
353
  super(`${type} validation failed for ${id2.toString()}: ${errorMessage}`);
330
354
  this.name = "ValidationError";
331
355
  }
332
356
  };
333
- var EventCycleError = class extends RuntimeError {
357
+ __name(_ValidationError, "ValidationError");
358
+ var ValidationError = _ValidationError;
359
+ var _EventCycleError = class _EventCycleError extends RuntimeError {
334
360
  constructor(path) {
335
361
  const chain = path.map((p) => `${p.id}\u2190${p.source}`).join(" -> ");
336
362
  super(
@@ -342,7 +368,9 @@ Break the cycle by changing hook logic (avoid mutual emits) or gate with conditi
342
368
  this.name = "EventCycleError";
343
369
  }
344
370
  };
345
- var EventEmissionCycleError = class extends RuntimeError {
371
+ __name(_EventCycleError, "EventCycleError");
372
+ var EventCycleError = _EventCycleError;
373
+ var _EventEmissionCycleError = class _EventEmissionCycleError extends RuntimeError {
346
374
  constructor(cycles) {
347
375
  const list = cycles.map((c) => ` \u2022 ${c}`).join("\n");
348
376
  super(
@@ -354,7 +382,9 @@ This was detected at compile time (dry-run). Break the cycle by avoiding mutual
354
382
  this.name = "EventEmissionCycleError";
355
383
  }
356
384
  };
357
- var PlatformUnsupportedFunction = class extends RuntimeError {
385
+ __name(_EventEmissionCycleError, "EventEmissionCycleError");
386
+ var EventEmissionCycleError = _EventEmissionCycleError;
387
+ var _PlatformUnsupportedFunction = class _PlatformUnsupportedFunction extends RuntimeError {
358
388
  constructor(functionName) {
359
389
  super(
360
390
  `Platform function not supported in this environment: ${functionName}`
@@ -362,6 +392,8 @@ var PlatformUnsupportedFunction = class extends RuntimeError {
362
392
  this.name = "PlatformUnsupportedFunction";
363
393
  }
364
394
  };
395
+ __name(_PlatformUnsupportedFunction, "PlatformUnsupportedFunction");
396
+ var PlatformUnsupportedFunction = _PlatformUnsupportedFunction;
365
397
 
366
398
  // src/definers/defineResource.ts
367
399
  function defineResource(constConfig) {
@@ -382,7 +414,7 @@ function defineResource(constConfig) {
382
414
  configSchema: constConfig.configSchema,
383
415
  resultSchema: constConfig.resultSchema,
384
416
  tags: constConfig.tags || [],
385
- with: function(config) {
417
+ with: /* @__PURE__ */ __name(function(config) {
386
418
  if (constConfig.configSchema) {
387
419
  try {
388
420
  config = constConfig.configSchema.parse(config);
@@ -400,7 +432,7 @@ function defineResource(constConfig) {
400
432
  resource: this,
401
433
  config
402
434
  };
403
- },
435
+ }, "with"),
404
436
  meta: constConfig.meta || {},
405
437
  middleware: constConfig.middleware || [],
406
438
  optional() {
@@ -411,6 +443,7 @@ function defineResource(constConfig) {
411
443
  }
412
444
  };
413
445
  }
446
+ __name(defineResource, "defineResource");
414
447
 
415
448
  // src/definers/defineEvent.ts
416
449
  function defineEvent(config) {
@@ -431,6 +464,7 @@ function defineEvent(config) {
431
464
  }
432
465
  };
433
466
  }
467
+ __name(defineEvent, "defineEvent");
434
468
 
435
469
  // src/definers/defineTaskMiddleware.ts
436
470
  function defineTaskMiddleware(middlewareDef) {
@@ -443,10 +477,10 @@ function defineTaskMiddleware(middlewareDef) {
443
477
  ...middlewareDef,
444
478
  dependencies: middlewareDef.dependencies || {}
445
479
  };
446
- const wrap = (obj) => {
480
+ const wrap = /* @__PURE__ */ __name((obj) => {
447
481
  return {
448
482
  ...obj,
449
- with: (config) => {
483
+ with: /* @__PURE__ */ __name((config) => {
450
484
  if (obj.configSchema) {
451
485
  try {
452
486
  config = obj.configSchema.parse(config);
@@ -466,11 +500,12 @@ function defineTaskMiddleware(middlewareDef) {
466
500
  ...config
467
501
  }
468
502
  });
469
- }
503
+ }, "with")
470
504
  };
471
- };
505
+ }, "wrap");
472
506
  return wrap(base);
473
507
  }
508
+ __name(defineTaskMiddleware, "defineTaskMiddleware");
474
509
 
475
510
  // src/definers/defineResourceMiddleware.ts
476
511
  function defineResourceMiddleware(middlewareDef) {
@@ -483,10 +518,10 @@ function defineResourceMiddleware(middlewareDef) {
483
518
  ...middlewareDef,
484
519
  dependencies: middlewareDef.dependencies || {}
485
520
  };
486
- const wrap = (obj) => {
521
+ const wrap = /* @__PURE__ */ __name((obj) => {
487
522
  return {
488
523
  ...obj,
489
- with: (config) => {
524
+ with: /* @__PURE__ */ __name((config) => {
490
525
  if (obj.configSchema) {
491
526
  try {
492
527
  config = obj.configSchema.parse(config);
@@ -506,11 +541,12 @@ function defineResourceMiddleware(middlewareDef) {
506
541
  ...config
507
542
  }
508
543
  });
509
- }
544
+ }, "with")
510
545
  };
511
- };
546
+ }, "wrap");
512
547
  return wrap(base);
513
548
  }
549
+ __name(defineResourceMiddleware, "defineResourceMiddleware");
514
550
 
515
551
  // src/definers/defineOverride.ts
516
552
  function defineOverride(base, patch) {
@@ -521,6 +557,7 @@ function defineOverride(base, patch) {
521
557
  id: base.id
522
558
  };
523
559
  }
560
+ __name(defineOverride, "defineOverride");
524
561
 
525
562
  // src/definers/defineTag.ts
526
563
  function defineTag(definition) {
@@ -608,35 +645,45 @@ function defineTag(definition) {
608
645
  }
609
646
  };
610
647
  }
648
+ __name(defineTag, "defineTag");
611
649
 
612
650
  // src/definers/tools.ts
613
651
  function isTask(definition) {
614
652
  return definition && definition[symbolTask];
615
653
  }
654
+ __name(isTask, "isTask");
616
655
  function isResource(definition) {
617
656
  return definition && definition[symbolResource];
618
657
  }
658
+ __name(isResource, "isResource");
619
659
  function isResourceWithConfig(definition) {
620
660
  return definition && definition[symbolResourceWithConfig];
621
661
  }
662
+ __name(isResourceWithConfig, "isResourceWithConfig");
622
663
  function isEvent(definition) {
623
664
  return definition && definition[symbolEvent];
624
665
  }
666
+ __name(isEvent, "isEvent");
625
667
  function isHook(definition) {
626
668
  return definition && definition[symbolHook];
627
669
  }
670
+ __name(isHook, "isHook");
628
671
  function isTaskMiddleware(definition) {
629
672
  return definition && definition[symbolTaskMiddleware];
630
673
  }
674
+ __name(isTaskMiddleware, "isTaskMiddleware");
631
675
  function isResourceMiddleware(definition) {
632
676
  return definition && definition[symbolResourceMiddleware];
633
677
  }
678
+ __name(isResourceMiddleware, "isResourceMiddleware");
634
679
  function isTag(definition) {
635
680
  return definition && definition[symbolTag];
636
681
  }
682
+ __name(isTag, "isTag");
637
683
  function isOptional(definition) {
638
684
  return definition && definition[symbolOptionalDependency];
639
685
  }
686
+ __name(isOptional, "isOptional");
640
687
 
641
688
  // src/platform/index.ts
642
689
  function detectEnvironment() {
@@ -648,14 +695,8 @@ function detectEnvironment() {
648
695
  }
649
696
  return "universal";
650
697
  }
651
- async function loadModule(path) {
652
- try {
653
- return await import(path);
654
- } catch (e) {
655
- return __require(path);
656
- }
657
- }
658
- var PlatformAdapter = class {
698
+ __name(detectEnvironment, "detectEnvironment");
699
+ var _PlatformAdapter = class _PlatformAdapter {
659
700
  constructor(env) {
660
701
  this.isInitialized = false;
661
702
  this.nodeALSClass = null;
@@ -666,7 +707,7 @@ var PlatformAdapter = class {
666
707
  }
667
708
  async init() {
668
709
  if (this.env === "node") {
669
- this.nodeALSClass = (await loadModule("node:async_hooks")).AsyncLocalStorage;
710
+ this.nodeALSClass = (await import('async_hooks')).AsyncLocalStorage;
670
711
  }
671
712
  }
672
713
  onUncaughtException(handler) {
@@ -677,14 +718,14 @@ var PlatformAdapter = class {
677
718
  }
678
719
  case "browser": {
679
720
  const target = globalThis.window ?? globalThis;
680
- const h = (e) => handler(e?.error ?? e);
721
+ const h = /* @__PURE__ */ __name((e) => handler(e?.error ?? e), "h");
681
722
  target.addEventListener?.("error", h);
682
723
  return () => target.removeEventListener?.("error", h);
683
724
  }
684
725
  default: {
685
726
  const tgt = globalThis;
686
727
  if (tgt.addEventListener) {
687
- const h = (e) => handler(e?.error ?? e);
728
+ const h = /* @__PURE__ */ __name((e) => handler(e?.error ?? e), "h");
688
729
  tgt.addEventListener("error", h);
689
730
  return () => tgt.removeEventListener("error", h);
690
731
  }
@@ -696,20 +737,20 @@ var PlatformAdapter = class {
696
737
  onUnhandledRejection(handler) {
697
738
  switch (this.env) {
698
739
  case "node": {
699
- const h = (reason) => handler(reason);
740
+ const h = /* @__PURE__ */ __name((reason) => handler(reason), "h");
700
741
  process.on("unhandledRejection", h);
701
742
  return () => process.off("unhandledRejection", h);
702
743
  }
703
744
  case "browser": {
704
- const target = globalThis.window ?? globalThis;
705
- const wrap = (e) => handler(e.reason);
745
+ const target = globalThis.window;
746
+ const wrap = /* @__PURE__ */ __name((e) => handler(e.reason), "wrap");
706
747
  target.addEventListener?.("unhandledrejection", wrap);
707
748
  return () => target.removeEventListener?.("unhandledrejection", wrap);
708
749
  }
709
750
  default: {
710
751
  const tgt = globalThis;
711
752
  if (tgt.addEventListener) {
712
- const wrap = (e) => handler(e.reason ?? e);
753
+ const wrap = /* @__PURE__ */ __name((e) => handler(e.reason ?? e), "wrap");
713
754
  tgt.addEventListener("unhandledrejection", wrap);
714
755
  return () => tgt.removeEventListener("unhandledrejection", wrap);
715
756
  }
@@ -729,7 +770,7 @@ var PlatformAdapter = class {
729
770
  };
730
771
  }
731
772
  case "browser": {
732
- const win = window ?? globalThis.window ?? globalThis;
773
+ const win = window;
733
774
  win.addEventListener?.("beforeunload", handler);
734
775
  return () => {
735
776
  win.removeEventListener?.("beforeunload", handler);
@@ -743,10 +784,10 @@ var PlatformAdapter = class {
743
784
  cleanup.push(
744
785
  () => tgt.removeEventListener?.("beforeunload", handler)
745
786
  );
746
- const vis = () => {
787
+ const vis = /* @__PURE__ */ __name(() => {
747
788
  const doc = globalThis.document;
748
789
  if (doc && doc.visibilityState === "hidden") handler();
749
- };
790
+ }, "vis");
750
791
  tgt.addEventListener("visibilitychange", vis);
751
792
  cleanup.push(
752
793
  () => tgt.removeEventListener?.("visibilitychange", vis)
@@ -801,7 +842,7 @@ var PlatformAdapter = class {
801
842
  switch (this.env) {
802
843
  case "node": {
803
844
  let instance;
804
- const get = () => {
845
+ const get = /* @__PURE__ */ __name(() => {
805
846
  if (!instance) {
806
847
  if (!this.nodeALSClass) {
807
848
  throw new PlatformUnsupportedFunction(
@@ -811,25 +852,27 @@ var PlatformAdapter = class {
811
852
  instance = new this.nodeALSClass();
812
853
  }
813
854
  return instance;
814
- };
855
+ }, "get");
815
856
  return {
816
- getStore: () => get().getStore(),
817
- run: (store2, callback) => get().run(store2, callback)
857
+ getStore: /* @__PURE__ */ __name(() => get().getStore(), "getStore"),
858
+ run: /* @__PURE__ */ __name((store2, callback) => get().run(store2, callback), "run")
818
859
  };
819
860
  }
820
861
  case "browser":
821
862
  default:
822
863
  return {
823
- getStore: () => {
864
+ getStore: /* @__PURE__ */ __name(() => {
824
865
  throw new PlatformUnsupportedFunction("createAsyncLocalStorage");
825
- },
826
- run: () => {
866
+ }, "getStore"),
867
+ run: /* @__PURE__ */ __name(() => {
827
868
  throw new PlatformUnsupportedFunction("createAsyncLocalStorage");
828
- }
869
+ }, "run")
829
870
  };
830
871
  }
831
872
  }
832
873
  };
874
+ __name(_PlatformAdapter, "PlatformAdapter");
875
+ var PlatformAdapter = _PlatformAdapter;
833
876
  var platformInstance = null;
834
877
  function getPlatform() {
835
878
  if (!platformInstance) {
@@ -838,6 +881,7 @@ function getPlatform() {
838
881
  }
839
882
  return platformInstance;
840
883
  }
884
+ __name(getPlatform, "getPlatform");
841
885
 
842
886
  // src/globals/middleware/requireContext.middleware.ts
843
887
  var requireContextTaskMiddleware = defineTaskMiddleware({
@@ -859,6 +903,7 @@ var storage = platform.createAsyncLocalStorage();
859
903
  function getCurrentStore() {
860
904
  return storage.getStore();
861
905
  }
906
+ __name(getCurrentStore, "getCurrentStore");
862
907
  function createContext(name = "runner.context") {
863
908
  if (!platform.hasAsyncLocalStorage()) {
864
909
  throw new PlatformUnsupportedFunction(
@@ -866,7 +911,7 @@ function createContext(name = "runner.context") {
866
911
  );
867
912
  }
868
913
  const ctxId = Symbol(name);
869
- const use = () => {
914
+ const use = /* @__PURE__ */ __name(() => {
870
915
  const store2 = getCurrentStore();
871
916
  if (!store2 || !store2.has(ctxId)) {
872
917
  throw new ContextError(
@@ -874,13 +919,13 @@ function createContext(name = "runner.context") {
874
919
  );
875
920
  }
876
921
  return store2.get(ctxId);
877
- };
878
- const provide = (value, fn) => {
922
+ }, "use");
923
+ const provide = /* @__PURE__ */ __name((value, fn) => {
879
924
  const currentStore = getCurrentStore();
880
925
  const map = currentStore ? new Map(currentStore) : /* @__PURE__ */ new Map();
881
926
  map.set(ctxId, value);
882
927
  return storage.run(map, fn);
883
- };
928
+ }, "provide");
884
929
  const api = {
885
930
  id: ctxId,
886
931
  use,
@@ -891,6 +936,7 @@ function createContext(name = "runner.context") {
891
936
  };
892
937
  return api;
893
938
  }
939
+ __name(createContext, "createContext");
894
940
 
895
941
  // src/globals/resources/debug/debug.tag.ts
896
942
  var debugTag = defineTag({
@@ -949,13 +995,14 @@ var globalEvents = {
949
995
  var globalEventsArray = [globalEvents.ready];
950
996
 
951
997
  // src/models/Queue.ts
952
- var Queue = class {
998
+ var _Queue = class _Queue {
953
999
  constructor() {
954
1000
  this.tail = Promise.resolve();
955
1001
  this.disposed = false;
956
1002
  this.abortController = new AbortController();
957
1003
  // true while inside a queued task → helps detect "queue in queue"
958
1004
  this.executionContext = getPlatform().createAsyncLocalStorage();
1005
+ this.hasAsyncLocalStorage = getPlatform().hasAsyncLocalStorage();
959
1006
  }
960
1007
  /**
961
1008
  * Schedule an asynchronous task.
@@ -965,7 +1012,7 @@ var Queue = class {
965
1012
  if (this.disposed) {
966
1013
  return Promise.reject(new Error("Queue has been disposed"));
967
1014
  }
968
- if (this.executionContext.getStore()) {
1015
+ if (this.hasAsyncLocalStorage && this.executionContext.getStore()) {
969
1016
  return Promise.reject(
970
1017
  new Error(
971
1018
  "Dead\u2011lock detected: a queued task attempted to queue another task"
@@ -974,7 +1021,7 @@ var Queue = class {
974
1021
  }
975
1022
  const { signal } = this.abortController;
976
1023
  const result = this.tail.then(
977
- () => this.executionContext.run(true, () => task(signal))
1024
+ () => this.hasAsyncLocalStorage ? this.executionContext.run(true, () => task(signal)) : task(signal)
978
1025
  );
979
1026
  this.tail = result.catch(() => {
980
1027
  });
@@ -995,28 +1042,30 @@ var Queue = class {
995
1042
  });
996
1043
  }
997
1044
  };
1045
+ __name(_Queue, "Queue");
1046
+ var Queue = _Queue;
998
1047
 
999
1048
  // src/globals/resources/queue.resource.ts
1000
1049
  var queueResource = defineResource({
1001
1050
  id: "globals.resources.queue",
1002
- context: () => ({
1051
+ context: /* @__PURE__ */ __name(() => ({
1003
1052
  map: /* @__PURE__ */ new Map()
1004
- }),
1005
- init: async (_, deps, context) => {
1053
+ }), "context"),
1054
+ init: /* @__PURE__ */ __name(async (_, deps, context) => {
1006
1055
  const map = context.map;
1007
1056
  return {
1008
1057
  map,
1009
- run: (id2, task) => {
1058
+ run: /* @__PURE__ */ __name((id2, task) => {
1010
1059
  if (!map.has(id2)) {
1011
1060
  map.set(id2, new Queue());
1012
1061
  }
1013
1062
  return map.get(id2).run(task);
1014
- }
1063
+ }, "run")
1015
1064
  };
1016
- },
1017
- dispose: async (value, _, deps, context) => {
1065
+ }, "init"),
1066
+ dispose: /* @__PURE__ */ __name(async (value, _, deps, context) => {
1018
1067
  context.map.forEach((queue) => queue.dispose());
1019
- },
1068
+ }, "dispose"),
1020
1069
  meta: {
1021
1070
  title: "Queue Map",
1022
1071
  description: "A global map that can be used to store and retrieve queues. You can run exclusive tasks based on using an id. queue.run(id, task) will run the task in the queue with the given id. If the queue does not exist, it will be created."
@@ -1193,7 +1242,7 @@ var globalMiddlewares = {
1193
1242
  };
1194
1243
 
1195
1244
  // src/models/TaskRunner.ts
1196
- var TaskRunner = class {
1245
+ var _TaskRunner = class _TaskRunner {
1197
1246
  constructor(store2, eventManager, logger) {
1198
1247
  this.store = store2;
1199
1248
  this.eventManager = eventManager;
@@ -1238,10 +1287,12 @@ var TaskRunner = class {
1238
1287
  return this.middlewareManager.composeTaskRunner(task);
1239
1288
  }
1240
1289
  };
1290
+ __name(_TaskRunner, "TaskRunner");
1291
+ var TaskRunner = _TaskRunner;
1241
1292
 
1242
1293
  // src/models/MiddlewareManager.ts
1243
1294
  var _isLocked;
1244
- var MiddlewareManager = class {
1295
+ var _MiddlewareManager = class _MiddlewareManager {
1245
1296
  constructor(store2, eventManager, logger) {
1246
1297
  this.store = store2;
1247
1298
  this.eventManager = eventManager;
@@ -1330,7 +1381,7 @@ var MiddlewareManager = class {
1330
1381
  for (let i = reversedInterceptors.length - 1; i >= 0; i--) {
1331
1382
  const interceptor = reversedInterceptors[i];
1332
1383
  const nextFunction = wrapped;
1333
- wrapped = async (input) => {
1384
+ wrapped = /* @__PURE__ */ __name(async (input) => {
1334
1385
  const executionInput = {
1335
1386
  task: {
1336
1387
  definition: null,
@@ -1339,11 +1390,11 @@ var MiddlewareManager = class {
1339
1390
  },
1340
1391
  next: nextFunction
1341
1392
  };
1342
- const wrappedNext = (i2) => {
1393
+ const wrappedNext = /* @__PURE__ */ __name((i2) => {
1343
1394
  return nextFunction(i2.task.input);
1344
- };
1395
+ }, "wrappedNext");
1345
1396
  return interceptor(wrappedNext, executionInput);
1346
- };
1397
+ }, "wrapped");
1347
1398
  }
1348
1399
  return wrapped;
1349
1400
  }
@@ -1359,7 +1410,7 @@ var MiddlewareManager = class {
1359
1410
  for (let i = reversedInterceptors.length - 1; i >= 0; i--) {
1360
1411
  const interceptor = reversedInterceptors[i];
1361
1412
  const nextFunction = wrapped;
1362
- wrapped = async (config) => {
1413
+ wrapped = /* @__PURE__ */ __name(async (config) => {
1363
1414
  const executionInput = {
1364
1415
  resource: {
1365
1416
  definition: null,
@@ -1368,11 +1419,11 @@ var MiddlewareManager = class {
1368
1419
  },
1369
1420
  next: nextFunction
1370
1421
  };
1371
- const wrappedNext = (input) => {
1422
+ const wrappedNext = /* @__PURE__ */ __name((input) => {
1372
1423
  return nextFunction(input.resource.config);
1373
- };
1424
+ }, "wrappedNext");
1374
1425
  return interceptor(wrappedNext, executionInput);
1375
- };
1426
+ }, "wrapped");
1376
1427
  }
1377
1428
  return wrapped;
1378
1429
  }
@@ -1382,7 +1433,7 @@ var MiddlewareManager = class {
1382
1433
  */
1383
1434
  composeTaskRunner(task) {
1384
1435
  const storeTask = this.store.tasks.get(task.id);
1385
- let next = async (input) => {
1436
+ let next = /* @__PURE__ */ __name(async (input) => {
1386
1437
  let rawInput = input;
1387
1438
  if (task.inputSchema) {
1388
1439
  try {
@@ -1405,36 +1456,36 @@ var MiddlewareManager = class {
1405
1456
  }
1406
1457
  }
1407
1458
  return rawResult;
1408
- };
1459
+ }, "next");
1409
1460
  if (storeTask.interceptors && storeTask.interceptors.length > 0) {
1410
1461
  for (let i = storeTask.interceptors.length - 1; i >= 0; i--) {
1411
1462
  const interceptor = storeTask.interceptors[i];
1412
1463
  const nextFunction = next;
1413
- next = async (input) => interceptor(nextFunction, input);
1464
+ next = /* @__PURE__ */ __name(async (input) => interceptor(nextFunction, input), "next");
1414
1465
  }
1415
1466
  }
1416
1467
  if (this.taskMiddlewareInterceptors.length > 0) {
1417
1468
  const reversedInterceptors = [
1418
1469
  ...this.taskMiddlewareInterceptors
1419
1470
  ].reverse();
1420
- const createExecutionInput = (input, nextFunc) => ({
1471
+ const createExecutionInput = /* @__PURE__ */ __name((input, nextFunc) => ({
1421
1472
  task: {
1422
1473
  definition: task,
1423
1474
  input
1424
1475
  },
1425
1476
  next: nextFunc
1426
- });
1477
+ }), "createExecutionInput");
1427
1478
  let currentNext = next;
1428
1479
  for (let i = reversedInterceptors.length - 1; i >= 0; i--) {
1429
1480
  const interceptor = reversedInterceptors[i];
1430
1481
  const nextFunction = currentNext;
1431
- currentNext = async (input) => {
1482
+ currentNext = /* @__PURE__ */ __name(async (input) => {
1432
1483
  const executionInput = createExecutionInput(input, nextFunction);
1433
- const wrappedNext = (i2) => {
1484
+ const wrappedNext = /* @__PURE__ */ __name((i2) => {
1434
1485
  return nextFunction(i2.task.input);
1435
- };
1486
+ }, "wrappedNext");
1436
1487
  return interceptor(wrappedNext, executionInput);
1437
- };
1488
+ }, "currentNext");
1438
1489
  }
1439
1490
  next = currentNext;
1440
1491
  }
@@ -1446,7 +1497,7 @@ var MiddlewareManager = class {
1446
1497
  const middleware = createdMiddlewares[i];
1447
1498
  const storeMiddleware = this.store.taskMiddlewares.get(middleware.id);
1448
1499
  const nextFunction = next;
1449
- const baseMiddlewareRunner = async (input) => {
1500
+ const baseMiddlewareRunner = /* @__PURE__ */ __name(async (input) => {
1450
1501
  return storeMiddleware.middleware.run(
1451
1502
  {
1452
1503
  task: {
@@ -1458,7 +1509,7 @@ var MiddlewareManager = class {
1458
1509
  storeMiddleware.computedDependencies,
1459
1510
  middleware.config
1460
1511
  );
1461
- };
1512
+ }, "baseMiddlewareRunner");
1462
1513
  const middlewareInterceptors = this.perMiddlewareInterceptors.get(middleware.id) || [];
1463
1514
  const wrappedMiddleware = this.wrapMiddlewareWithInterceptors(
1464
1515
  middleware,
@@ -1473,7 +1524,7 @@ var MiddlewareManager = class {
1473
1524
  * Run a resource init wrapped with its applicable middlewares.
1474
1525
  */
1475
1526
  async runResourceInit(resource, config, dependencies, context) {
1476
- let next = async (cfg) => {
1527
+ let next = /* @__PURE__ */ __name(async (cfg) => {
1477
1528
  if (!resource.init) return void 0;
1478
1529
  const rawValue = await resource.init.call(
1479
1530
  null,
@@ -1493,7 +1544,7 @@ var MiddlewareManager = class {
1493
1544
  }
1494
1545
  }
1495
1546
  return rawValue;
1496
- };
1547
+ }, "next");
1497
1548
  const createdMiddlewares = this.getApplicableResourceMiddlewares(resource);
1498
1549
  for (let i = createdMiddlewares.length - 1; i >= 0; i--) {
1499
1550
  const middleware = createdMiddlewares[i];
@@ -1501,7 +1552,7 @@ var MiddlewareManager = class {
1501
1552
  middleware.id
1502
1553
  );
1503
1554
  const nextFunction = next;
1504
- const baseMiddlewareRunner = async (cfg) => {
1555
+ const baseMiddlewareRunner = /* @__PURE__ */ __name(async (cfg) => {
1505
1556
  try {
1506
1557
  const result = await storeMiddleware.middleware.run(
1507
1558
  {
@@ -1526,7 +1577,7 @@ var MiddlewareManager = class {
1526
1577
  }
1527
1578
  throw error;
1528
1579
  }
1529
- };
1580
+ }, "baseMiddlewareRunner");
1530
1581
  const middlewareInterceptors = this.perResourceMiddlewareInterceptors.get(middleware.id) || [];
1531
1582
  const wrappedMiddleware = this.wrapResourceMiddlewareWithInterceptors(
1532
1583
  middleware,
@@ -1539,24 +1590,24 @@ var MiddlewareManager = class {
1539
1590
  const reversedInterceptors = [
1540
1591
  ...this.resourceMiddlewareInterceptors
1541
1592
  ].reverse();
1542
- const createExecutionInput = (config2, nextFunc) => ({
1593
+ const createExecutionInput = /* @__PURE__ */ __name((config2, nextFunc) => ({
1543
1594
  resource: {
1544
1595
  definition: resource,
1545
1596
  config: config2
1546
1597
  },
1547
1598
  next: nextFunc
1548
- });
1599
+ }), "createExecutionInput");
1549
1600
  let currentNext = next;
1550
1601
  for (let i = reversedInterceptors.length - 1; i >= 0; i--) {
1551
1602
  const interceptor = reversedInterceptors[i];
1552
1603
  const nextFunction = currentNext;
1553
- currentNext = async (cfg) => {
1604
+ currentNext = /* @__PURE__ */ __name(async (cfg) => {
1554
1605
  const executionInput = createExecutionInput(cfg, nextFunction);
1555
- const wrappedNext = (input) => {
1606
+ const wrappedNext = /* @__PURE__ */ __name((input) => {
1556
1607
  return nextFunction(input.resource.config);
1557
- };
1608
+ }, "wrappedNext");
1558
1609
  return interceptor(wrappedNext, executionInput);
1559
- };
1610
+ }, "currentNext");
1560
1611
  }
1561
1612
  next = currentNext;
1562
1613
  }
@@ -1603,9 +1654,11 @@ var MiddlewareManager = class {
1603
1654
  }
1604
1655
  };
1605
1656
  _isLocked = new WeakMap();
1657
+ __name(_MiddlewareManager, "MiddlewareManager");
1658
+ var MiddlewareManager = _MiddlewareManager;
1606
1659
 
1607
1660
  // src/models/ResourceInitializer.ts
1608
- var ResourceInitializer = class {
1661
+ var _ResourceInitializer = class _ResourceInitializer {
1609
1662
  constructor(store2, eventManager, logger) {
1610
1663
  this.store = store2;
1611
1664
  this.eventManager = eventManager;
@@ -1646,13 +1699,15 @@ var ResourceInitializer = class {
1646
1699
  );
1647
1700
  }
1648
1701
  };
1702
+ __name(_ResourceInitializer, "ResourceInitializer");
1703
+ var ResourceInitializer = _ResourceInitializer;
1649
1704
 
1650
1705
  // src/models/utils/safeStringify.ts
1651
1706
  function safeStringify(value, space, options) {
1652
1707
  const seen = /* @__PURE__ */ new WeakSet();
1653
1708
  const holderDepth = /* @__PURE__ */ new WeakMap();
1654
1709
  const maxDepth = typeof options?.maxDepth === "number" ? options.maxDepth : Infinity;
1655
- const replacer = function(_key, val) {
1710
+ const replacer = /* @__PURE__ */ __name(function(_key, val) {
1656
1711
  if (typeof val === "function") {
1657
1712
  return "function()";
1658
1713
  }
@@ -1671,7 +1726,7 @@ function safeStringify(value, space, options) {
1671
1726
  holderDepth.set(val, currentDepth);
1672
1727
  }
1673
1728
  return val;
1674
- };
1729
+ }, "replacer");
1675
1730
  try {
1676
1731
  return JSON.stringify(value, replacer, space);
1677
1732
  } catch {
@@ -1682,12 +1737,14 @@ function safeStringify(value, space, options) {
1682
1737
  }
1683
1738
  }
1684
1739
  }
1740
+ __name(safeStringify, "safeStringify");
1685
1741
 
1686
1742
  // src/models/LogPrinter.ts
1687
1743
  var ansiRegex = /[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
1688
1744
  function stripAnsi(str) {
1689
1745
  return str.replace(ansiRegex, "");
1690
1746
  }
1747
+ __name(stripAnsi, "stripAnsi");
1691
1748
  var COLORS = {
1692
1749
  trace: "\x1B[90m",
1693
1750
  debug: "\x1B[36m",
@@ -1847,11 +1904,12 @@ var _LogPrinter = class _LogPrinter {
1847
1904
  }
1848
1905
  static resetWriters() {
1849
1906
  _LogPrinter.writers = {
1850
- log: (msg) => console.log(msg),
1851
- error: (msg) => console.error?.(msg)
1907
+ log: /* @__PURE__ */ __name((msg) => console.log(msg), "log"),
1908
+ error: /* @__PURE__ */ __name((msg) => console.error?.(msg), "error")
1852
1909
  };
1853
1910
  }
1854
1911
  };
1912
+ __name(_LogPrinter, "LogPrinter");
1855
1913
  _LogPrinter.NO_COLORS = {
1856
1914
  trace: "",
1857
1915
  debug: "",
@@ -1868,9 +1926,9 @@ _LogPrinter.NO_COLORS = {
1868
1926
  };
1869
1927
  _LogPrinter.writers = {
1870
1928
  // eslint-disable-next-line no-console
1871
- log: (msg) => console.log(msg),
1929
+ log: /* @__PURE__ */ __name((msg) => console.log(msg), "log"),
1872
1930
  // eslint-disable-next-line no-console
1873
- error: (msg) => console.error?.(msg)
1931
+ error: /* @__PURE__ */ __name((msg) => console.error?.(msg), "error")
1874
1932
  };
1875
1933
  var LogPrinter = _LogPrinter;
1876
1934
 
@@ -2047,6 +2105,7 @@ var _Logger = class _Logger {
2047
2105
  }
2048
2106
  }
2049
2107
  };
2108
+ __name(_Logger, "Logger");
2050
2109
  _Logger.Severity = {
2051
2110
  trace: 0,
2052
2111
  debug: 1,
@@ -2058,7 +2117,7 @@ _Logger.Severity = {
2058
2117
  var Logger = _Logger;
2059
2118
 
2060
2119
  // src/models/DependencyProcessor.ts
2061
- var DependencyProcessor = class {
2120
+ var _DependencyProcessor = class _DependencyProcessor {
2062
2121
  constructor(store2, eventManager, taskRunner, logger) {
2063
2122
  this.store = store2;
2064
2123
  this.eventManager = eventManager;
@@ -2171,18 +2230,18 @@ var DependencyProcessor = class {
2171
2230
  }
2172
2231
  makeTaskWithIntercept(original) {
2173
2232
  const taskId = original.id;
2174
- const fn = (input) => {
2233
+ const fn = /* @__PURE__ */ __name((input) => {
2175
2234
  const storeTask = this.store.tasks.get(taskId);
2176
2235
  const effective = storeTask.task;
2177
2236
  return this.taskRunner.run(effective, input);
2178
- };
2237
+ }, "fn");
2179
2238
  return Object.assign(fn, {
2180
- intercept: (middleware) => {
2239
+ intercept: /* @__PURE__ */ __name((middleware) => {
2181
2240
  this.store.checkLock();
2182
2241
  const storeTask = this.store.tasks.get(taskId);
2183
2242
  if (!storeTask.interceptors) storeTask.interceptors = [];
2184
2243
  storeTask.interceptors.push(middleware);
2185
- }
2244
+ }, "intercept")
2186
2245
  });
2187
2246
  }
2188
2247
  async initializeRoot() {
@@ -2205,7 +2264,7 @@ var DependencyProcessor = class {
2205
2264
  const hook = hookStoreElement.hook;
2206
2265
  if (hook.on) {
2207
2266
  const eventDefinition = hook.on;
2208
- const handler = async (receivedEvent) => {
2267
+ const handler = /* @__PURE__ */ __name(async (receivedEvent) => {
2209
2268
  if (receivedEvent.source === hook.id) {
2210
2269
  return;
2211
2270
  }
@@ -2214,7 +2273,7 @@ var DependencyProcessor = class {
2214
2273
  receivedEvent,
2215
2274
  hookStoreElement.computedDependencies
2216
2275
  );
2217
- };
2276
+ }, "handler");
2218
2277
  const order = hook.order ?? 0;
2219
2278
  if (eventDefinition === "*") {
2220
2279
  this.eventManager.addGlobalListener(handler, { order });
@@ -2334,11 +2393,13 @@ var DependencyProcessor = class {
2334
2393
  return storeResource.value;
2335
2394
  }
2336
2395
  };
2396
+ __name(_DependencyProcessor, "DependencyProcessor");
2397
+ var DependencyProcessor = _DependencyProcessor;
2337
2398
 
2338
2399
  // src/models/EventManager.ts
2339
2400
  var HandlerOptionsDefaults = { order: 0 };
2340
2401
  var _isLocked2;
2341
- var EventManager = class {
2402
+ var _EventManager = class _EventManager {
2342
2403
  constructor(options) {
2343
2404
  // Core storage for event listeners
2344
2405
  this.listeners = /* @__PURE__ */ new Map();
@@ -2395,16 +2456,16 @@ var EventManager = class {
2395
2456
  }
2396
2457
  }
2397
2458
  const frame = { id: eventDefinition.id, source };
2398
- const processEmission = async () => {
2459
+ const processEmission = /* @__PURE__ */ __name(async () => {
2399
2460
  const pseudoForExclude = {
2400
2461
  id: eventDefinition.id,
2401
2462
  data,
2402
2463
  timestamp: /* @__PURE__ */ new Date(),
2403
2464
  source,
2404
2465
  meta: eventDefinition.meta || {},
2405
- stopPropagation: () => {
2406
- },
2407
- isPropagationStopped: () => false,
2466
+ stopPropagation: /* @__PURE__ */ __name(() => {
2467
+ }, "stopPropagation"),
2468
+ isPropagationStopped: /* @__PURE__ */ __name(() => false, "isPropagationStopped"),
2408
2469
  tags: eventDefinition.tags
2409
2470
  };
2410
2471
  const excludeFromGlobal = this.isExcludedFromGlobal(pseudoForExclude);
@@ -2416,13 +2477,13 @@ var EventManager = class {
2416
2477
  timestamp: /* @__PURE__ */ new Date(),
2417
2478
  source,
2418
2479
  meta: eventDefinition.meta || {},
2419
- stopPropagation: () => {
2480
+ stopPropagation: /* @__PURE__ */ __name(() => {
2420
2481
  propagationStopped = true;
2421
- },
2422
- isPropagationStopped: () => propagationStopped,
2482
+ }, "stopPropagation"),
2483
+ isPropagationStopped: /* @__PURE__ */ __name(() => propagationStopped, "isPropagationStopped"),
2423
2484
  tags: eventDefinition.tags
2424
2485
  };
2425
- const baseEmit = async (eventToEmit) => {
2486
+ const baseEmit = /* @__PURE__ */ __name(async (eventToEmit) => {
2426
2487
  if (allListeners.length === 0) {
2427
2488
  return;
2428
2489
  }
@@ -2438,15 +2499,15 @@ var EventManager = class {
2438
2499
  await listener.handler(eventToEmit);
2439
2500
  }
2440
2501
  }
2441
- };
2502
+ }, "baseEmit");
2442
2503
  let emitWithInterceptors = baseEmit;
2443
2504
  const reversedInterceptors = [...this.emissionInterceptors].reverse();
2444
2505
  for (const interceptor of reversedInterceptors) {
2445
2506
  const nextFunction = emitWithInterceptors;
2446
- emitWithInterceptors = async (eventToEmit) => interceptor(nextFunction, eventToEmit);
2507
+ emitWithInterceptors = /* @__PURE__ */ __name(async (eventToEmit) => interceptor(nextFunction, eventToEmit), "emitWithInterceptors");
2447
2508
  }
2448
2509
  await emitWithInterceptors(event);
2449
- };
2510
+ }, "processEmission");
2450
2511
  if (this.runtimeCycleDetection && this.emissionStack && this.currentHookIdContext) {
2451
2512
  const currentStack = this.emissionStack.getStore();
2452
2513
  if (currentStack) {
@@ -2540,9 +2601,9 @@ var EventManager = class {
2540
2601
  timestamp: /* @__PURE__ */ new Date(),
2541
2602
  source: "",
2542
2603
  meta: eventDefinition.meta || {},
2543
- stopPropagation: () => {
2544
- },
2545
- isPropagationStopped: () => false,
2604
+ stopPropagation: /* @__PURE__ */ __name(() => {
2605
+ }, "stopPropagation"),
2606
+ isPropagationStopped: /* @__PURE__ */ __name(() => false, "isPropagationStopped"),
2546
2607
  tags: eventDefinition.tags
2547
2608
  };
2548
2609
  if (this.isExcludedFromGlobal(pseudoEmission)) {
@@ -2582,7 +2643,7 @@ var EventManager = class {
2582
2643
  * @returns Promise resolving to the hook execution result
2583
2644
  */
2584
2645
  async executeHookWithInterceptors(hook, event, computedDependencies) {
2585
- const baseExecute = async (hookToExecute, eventForHook) => {
2646
+ const baseExecute = /* @__PURE__ */ __name(async (hookToExecute, eventForHook) => {
2586
2647
  try {
2587
2648
  const result = await hookToExecute.run(
2588
2649
  eventForHook,
@@ -2592,12 +2653,12 @@ var EventManager = class {
2592
2653
  } catch (err) {
2593
2654
  throw err;
2594
2655
  }
2595
- };
2656
+ }, "baseExecute");
2596
2657
  let executeWithInterceptors = baseExecute;
2597
2658
  const reversedInterceptors = [...this.hookInterceptors].reverse();
2598
2659
  for (const interceptor of reversedInterceptors) {
2599
2660
  const nextFunction = executeWithInterceptors;
2600
- executeWithInterceptors = async (hookToExecute, eventForHook) => interceptor(nextFunction, hookToExecute, eventForHook);
2661
+ executeWithInterceptors = /* @__PURE__ */ __name(async (hookToExecute, eventForHook) => interceptor(nextFunction, hookToExecute, eventForHook), "executeWithInterceptors");
2601
2662
  }
2602
2663
  if (this.runtimeCycleDetection) {
2603
2664
  return await this.currentHookIdContext?.run(
@@ -2716,6 +2777,8 @@ var EventManager = class {
2716
2777
  }
2717
2778
  };
2718
2779
  _isLocked2 = new WeakMap();
2780
+ __name(_EventManager, "EventManager");
2781
+ var EventManager = _EventManager;
2719
2782
 
2720
2783
  // src/models/utils/findCircularDependencies.ts
2721
2784
  function findCircularDependencies(nodes) {
@@ -2750,6 +2813,7 @@ function findCircularDependencies(nodes) {
2750
2813
  stack.delete(node.id);
2751
2814
  path.pop();
2752
2815
  }
2816
+ __name(dfs, "dfs");
2753
2817
  for (const node of nodes) {
2754
2818
  if (!visited.has(node.id)) {
2755
2819
  dfs(node);
@@ -2758,9 +2822,10 @@ function findCircularDependencies(nodes) {
2758
2822
  result.cycles = Array.from(new Set(result.cycles));
2759
2823
  return result;
2760
2824
  }
2825
+ __name(findCircularDependencies, "findCircularDependencies");
2761
2826
 
2762
2827
  // src/models/StoreValidator.ts
2763
- var StoreValidator = class {
2828
+ var _StoreValidator = class _StoreValidator {
2764
2829
  constructor(registry) {
2765
2830
  this.registry = registry;
2766
2831
  }
@@ -2839,9 +2904,11 @@ var StoreValidator = class {
2839
2904
  }
2840
2905
  }
2841
2906
  };
2907
+ __name(_StoreValidator, "StoreValidator");
2908
+ var StoreValidator = _StoreValidator;
2842
2909
 
2843
2910
  // src/models/StoreRegistry.ts
2844
- var StoreRegistry = class {
2911
+ var _StoreRegistry = class _StoreRegistry {
2845
2912
  constructor(store2) {
2846
2913
  this.store = store2;
2847
2914
  this.tasks = /* @__PURE__ */ new Map();
@@ -3192,9 +3259,11 @@ var StoreRegistry = class {
3192
3259
  return currentItem;
3193
3260
  }
3194
3261
  };
3262
+ __name(_StoreRegistry, "StoreRegistry");
3263
+ var StoreRegistry = _StoreRegistry;
3195
3264
 
3196
3265
  // src/models/OverrideManager.ts
3197
- var OverrideManager = class {
3266
+ var _OverrideManager = class _OverrideManager {
3198
3267
  constructor(registry) {
3199
3268
  this.registry = registry;
3200
3269
  this.overrides = /* @__PURE__ */ new Map();
@@ -3257,10 +3326,12 @@ var OverrideManager = class {
3257
3326
  }
3258
3327
  }
3259
3328
  };
3329
+ __name(_OverrideManager, "OverrideManager");
3330
+ var OverrideManager = _OverrideManager;
3260
3331
 
3261
3332
  // src/models/Store.ts
3262
3333
  var _isLocked3, _isInitialized;
3263
- var Store = class {
3334
+ var _Store = class _Store {
3264
3335
  constructor(eventManager, logger, onUnhandledError) {
3265
3336
  this.eventManager = eventManager;
3266
3337
  this.logger = logger;
@@ -3439,6 +3510,8 @@ var Store = class {
3439
3510
  };
3440
3511
  _isLocked3 = new WeakMap();
3441
3512
  _isInitialized = new WeakMap();
3513
+ __name(_Store, "Store");
3514
+ var Store = _Store;
3442
3515
 
3443
3516
  // src/globals/resources/debug/types.ts
3444
3517
  var allFalse = Object.freeze({
@@ -3489,7 +3562,8 @@ function formatConfig(config) {
3489
3562
  }
3490
3563
  return { ...allFalse, ...config };
3491
3564
  }
3492
- var getConfig = (config, taggable) => {
3565
+ __name(formatConfig, "formatConfig");
3566
+ var getConfig = /* @__PURE__ */ __name((config, taggable) => {
3493
3567
  if (!taggable) {
3494
3568
  return formatConfig(config);
3495
3569
  }
@@ -3499,7 +3573,7 @@ var getConfig = (config, taggable) => {
3499
3573
  return { ...formatConfig(config), ...debugTagConfigFormatted };
3500
3574
  }
3501
3575
  return formatConfig(config);
3502
- };
3576
+ }, "getConfig");
3503
3577
 
3504
3578
  // src/globals/resources/debug/debugConfig.resource.ts
3505
3579
  var debugConfig = defineResource({
@@ -3509,21 +3583,21 @@ var debugConfig = defineResource({
3509
3583
  description: "Debug config. This is used to debug the system."
3510
3584
  },
3511
3585
  tags: [globalTags.system],
3512
- init: async (config) => {
3586
+ init: /* @__PURE__ */ __name(async (config) => {
3513
3587
  const myConfig = { ...getConfig(config) };
3514
3588
  Object.freeze(myConfig);
3515
3589
  return myConfig;
3516
- }
3590
+ }, "init")
3517
3591
  });
3518
3592
 
3519
3593
  // src/globals/resources/debug/utils.ts
3520
- var hasSystemTag = (definition) => {
3594
+ var hasSystemTag = /* @__PURE__ */ __name((definition) => {
3521
3595
  const maybeTags = definition.tags;
3522
3596
  if (!Array.isArray(maybeTags)) {
3523
3597
  return false;
3524
3598
  }
3525
3599
  return globalTags.system.exists(definition);
3526
- };
3600
+ }, "hasSystemTag");
3527
3601
 
3528
3602
  // src/globals/resources/debug/globalEvent.hook.ts
3529
3603
  var globalEventListener = defineHook({
@@ -3533,7 +3607,7 @@ var globalEventListener = defineHook({
3533
3607
  logger: globalResources.logger,
3534
3608
  debugConfig
3535
3609
  },
3536
- run: async (event, { logger, debugConfig: debugConfig2 }) => {
3610
+ run: /* @__PURE__ */ __name(async (event, { logger, debugConfig: debugConfig2 }) => {
3537
3611
  if (hasSystemTag(event)) {
3538
3612
  return;
3539
3613
  }
@@ -3545,7 +3619,7 @@ var globalEventListener = defineHook({
3545
3619
  data: debugConfig2.logEventEmissionInput ? { data: event.data } : void 0
3546
3620
  });
3547
3621
  }
3548
- },
3622
+ }, "run"),
3549
3623
  meta: {
3550
3624
  title: "Non-system Event Logger",
3551
3625
  description: "Logs all non-system events."
@@ -3556,13 +3630,13 @@ var globalEventListener = defineHook({
3556
3630
  // src/globals/resources/debug/executionTracker.middleware.ts
3557
3631
  var tasksTrackerMiddleware = defineTaskMiddleware({
3558
3632
  id: "globals.debug.middleware.task.executionTracker",
3559
- everywhere: (task) => !globalTags.system.exists(task),
3633
+ everywhere: /* @__PURE__ */ __name((task) => !globalTags.system.exists(task), "everywhere"),
3560
3634
  dependencies: {
3561
3635
  logger: globalResources.logger,
3562
3636
  debugConfig,
3563
3637
  store: globalResources.store
3564
3638
  },
3565
- run: async ({ task, next }, { logger, debugConfig: debugConfig2, store: store2 }) => {
3639
+ run: /* @__PURE__ */ __name(async ({ task, next }, { logger, debugConfig: debugConfig2, store: store2 }) => {
3566
3640
  const start = Date.now();
3567
3641
  logger = logger.with({
3568
3642
  source: tasksTrackerMiddleware.id
@@ -3581,7 +3655,7 @@ var tasksTrackerMiddleware = defineTaskMiddleware({
3581
3655
  data: shouldShowResult ? { result } : void 0
3582
3656
  });
3583
3657
  return result;
3584
- },
3658
+ }, "run"),
3585
3659
  meta: {
3586
3660
  title: "Execution Tracker",
3587
3661
  description: "Tracks the execution of tasks and resources."
@@ -3595,8 +3669,8 @@ var resourcesTrackerMiddleware = defineResourceMiddleware({
3595
3669
  debugConfig,
3596
3670
  store: globalResources.store
3597
3671
  },
3598
- everywhere: (resource) => !globalTags.system.exists(resource),
3599
- run: async ({ resource, next }, { logger, debugConfig: debugConfig2, store: store2 }) => {
3672
+ everywhere: /* @__PURE__ */ __name((resource) => !globalTags.system.exists(resource), "everywhere"),
3673
+ run: /* @__PURE__ */ __name(async ({ resource, next }, { logger, debugConfig: debugConfig2, store: store2 }) => {
3600
3674
  const start = Date.now();
3601
3675
  logger = logger.with({
3602
3676
  source: resourcesTrackerMiddleware.id
@@ -3618,7 +3692,7 @@ var resourcesTrackerMiddleware = defineResourceMiddleware({
3618
3692
  data: shouldShowResult ? { result } : void 0
3619
3693
  });
3620
3694
  return result;
3621
- },
3695
+ }, "run"),
3622
3696
  meta: {
3623
3697
  title: "Execution Tracker",
3624
3698
  description: "Tracks the execution of tasks and resources."
@@ -3640,7 +3714,7 @@ var middlewareInterceptorResource = defineResource({
3640
3714
  debugConfig,
3641
3715
  middlewareManager: globalResources.middlewareManager
3642
3716
  },
3643
- init: async (event, deps) => {
3717
+ init: /* @__PURE__ */ __name(async (event, deps) => {
3644
3718
  const { logger, debugConfig: debugConfig2, middlewareManager } = deps;
3645
3719
  middlewareManager.intercept(
3646
3720
  "task",
@@ -3698,7 +3772,7 @@ var middlewareInterceptorResource = defineResource({
3698
3772
  return result;
3699
3773
  }
3700
3774
  );
3701
- }
3775
+ }, "init")
3702
3776
  });
3703
3777
 
3704
3778
  // src/globals/resources/debug/hook.hook.ts
@@ -3714,7 +3788,7 @@ var hookInterceptorResource = defineResource({
3714
3788
  debugConfig,
3715
3789
  eventManager: globalResources.eventManager
3716
3790
  },
3717
- init: async (event, deps) => {
3791
+ init: /* @__PURE__ */ __name(async (event, deps) => {
3718
3792
  deps.eventManager.interceptHook(async (next, hook, event2) => {
3719
3793
  const { logger, debugConfig: debugConfig2 } = deps;
3720
3794
  if (hasSystemTag(hook)) {
@@ -3737,13 +3811,13 @@ var hookInterceptorResource = defineResource({
3737
3811
  });
3738
3812
  }
3739
3813
  });
3740
- }
3814
+ }, "init")
3741
3815
  });
3742
3816
 
3743
3817
  // src/globals/resources/debug/debug.resource.ts
3744
3818
  var debugResource = defineResource({
3745
3819
  id: "globals.resources.debug",
3746
- register: (config) => {
3820
+ register: /* @__PURE__ */ __name((config) => {
3747
3821
  return [
3748
3822
  debugConfig.with(config),
3749
3823
  globalEventListener,
@@ -3752,7 +3826,7 @@ var debugResource = defineResource({
3752
3826
  tasksTrackerMiddleware,
3753
3827
  resourcesTrackerMiddleware
3754
3828
  ];
3755
- },
3829
+ }, "register"),
3756
3830
  meta: {
3757
3831
  title: "Debug",
3758
3832
  description: "Debug resource. This is used to debug the system."
@@ -3767,25 +3841,26 @@ var processSafetyNetsInstalled = false;
3767
3841
  function installGlobalProcessSafetyNetsOnce() {
3768
3842
  if (processSafetyNetsInstalled) return;
3769
3843
  processSafetyNetsInstalled = true;
3770
- const onUncaughtException = async (err) => {
3844
+ const onUncaughtException = /* @__PURE__ */ __name(async (err) => {
3771
3845
  for (const handler of activeErrorHandlers) {
3772
3846
  try {
3773
3847
  await handler(err, "uncaughtException");
3774
3848
  } catch (_) {
3775
3849
  }
3776
3850
  }
3777
- };
3778
- const onUnhandledRejection = async (reason) => {
3851
+ }, "onUncaughtException");
3852
+ const onUnhandledRejection = /* @__PURE__ */ __name(async (reason) => {
3779
3853
  for (const handler of activeErrorHandlers) {
3780
3854
  try {
3781
3855
  await handler(reason, "unhandledRejection");
3782
3856
  } catch (_) {
3783
3857
  }
3784
3858
  }
3785
- };
3859
+ }, "onUnhandledRejection");
3786
3860
  platform2.onUncaughtException(onUncaughtException);
3787
3861
  platform2.onUnhandledRejection(onUnhandledRejection);
3788
3862
  }
3863
+ __name(installGlobalProcessSafetyNetsOnce, "installGlobalProcessSafetyNetsOnce");
3789
3864
  function registerProcessLevelSafetyNets(handler) {
3790
3865
  installGlobalProcessSafetyNetsOnce();
3791
3866
  activeErrorHandlers.add(handler);
@@ -3793,12 +3868,13 @@ function registerProcessLevelSafetyNets(handler) {
3793
3868
  activeErrorHandlers.delete(handler);
3794
3869
  };
3795
3870
  }
3871
+ __name(registerProcessLevelSafetyNets, "registerProcessLevelSafetyNets");
3796
3872
  var activeDisposers = /* @__PURE__ */ new Set();
3797
3873
  var shutdownHooksInstalled = false;
3798
3874
  function installGlobalShutdownHooksOnce() {
3799
3875
  if (shutdownHooksInstalled) return;
3800
3876
  shutdownHooksInstalled = true;
3801
- const handler = async () => {
3877
+ const handler = /* @__PURE__ */ __name(async () => {
3802
3878
  try {
3803
3879
  const disposers = Array.from(activeDisposers);
3804
3880
  for (const d of disposers) {
@@ -3817,9 +3893,10 @@ function installGlobalShutdownHooksOnce() {
3817
3893
  }
3818
3894
  }
3819
3895
  }
3820
- };
3896
+ }, "handler");
3821
3897
  platform2.onShutdownSignal(handler);
3822
3898
  }
3899
+ __name(installGlobalShutdownHooksOnce, "installGlobalShutdownHooksOnce");
3823
3900
  function registerShutdownHook(disposeOnce) {
3824
3901
  installGlobalShutdownHooksOnce();
3825
3902
  activeDisposers.add(disposeOnce);
@@ -3827,6 +3904,7 @@ function registerShutdownHook(disposeOnce) {
3827
3904
  activeDisposers.delete(disposeOnce);
3828
3905
  };
3829
3906
  }
3907
+ __name(registerShutdownHook, "registerShutdownHook");
3830
3908
 
3831
3909
  // src/models/UnhandledError.ts
3832
3910
  function createDefaultUnhandledError(logger) {
@@ -3841,6 +3919,7 @@ function createDefaultUnhandledError(logger) {
3841
3919
  });
3842
3920
  };
3843
3921
  }
3922
+ __name(createDefaultUnhandledError, "createDefaultUnhandledError");
3844
3923
  function bindProcessErrorHandler(handler) {
3845
3924
  return async (error, source) => {
3846
3925
  try {
@@ -3849,15 +3928,17 @@ function bindProcessErrorHandler(handler) {
3849
3928
  }
3850
3929
  };
3851
3930
  }
3931
+ __name(bindProcessErrorHandler, "bindProcessErrorHandler");
3852
3932
  async function safeReportUnhandledError(handler, info) {
3853
3933
  try {
3854
3934
  await handler(info);
3855
3935
  } catch {
3856
3936
  }
3857
3937
  }
3938
+ __name(safeReportUnhandledError, "safeReportUnhandledError");
3858
3939
 
3859
3940
  // src/models/RunResult.ts
3860
- var RunResult = class {
3941
+ var _RunResult = class _RunResult {
3861
3942
  constructor(value, logger, store2, eventManager, taskRunner, disposeFn) {
3862
3943
  this.value = value;
3863
3944
  this.logger = logger;
@@ -3871,7 +3952,7 @@ var RunResult = class {
3871
3952
  * @param args - The arguments to pass to the task.
3872
3953
  * @returns The result of the task.
3873
3954
  */
3874
- this.runTask = (task, ...args) => {
3955
+ this.runTask = /* @__PURE__ */ __name((task, ...args) => {
3875
3956
  if (typeof task === "string") {
3876
3957
  const taskId = task;
3877
3958
  if (!this.store.tasks.has(taskId)) {
@@ -3880,13 +3961,13 @@ var RunResult = class {
3880
3961
  task = this.store.tasks.get(taskId).task;
3881
3962
  }
3882
3963
  return this.taskRunner.run(task, ...args);
3883
- };
3964
+ }, "runTask");
3884
3965
  /**
3885
3966
  * Emit an event within the context of the run result.
3886
3967
  * @param event - The event to emit.
3887
3968
  * @param payload - The payload to emit.
3888
3969
  */
3889
- this.emitEvent = (event, payload) => {
3970
+ this.emitEvent = /* @__PURE__ */ __name((event, payload) => {
3890
3971
  if (typeof event === "string") {
3891
3972
  const eventId = event;
3892
3973
  if (!this.store.events.has(eventId)) {
@@ -3895,29 +3976,31 @@ var RunResult = class {
3895
3976
  event = this.store.events.get(eventId).event;
3896
3977
  }
3897
3978
  return this.eventManager.emit(event, payload, "outside");
3898
- };
3979
+ }, "emitEvent");
3899
3980
  /**
3900
3981
  * Get the value of a resource from the run result.
3901
3982
  * @param resource - The resource to get the value of.
3902
3983
  * @returns The value of the resource.
3903
3984
  */
3904
- this.getResourceValue = (resource) => {
3985
+ this.getResourceValue = /* @__PURE__ */ __name((resource) => {
3905
3986
  const resourceId = typeof resource === "string" ? resource : resource.id;
3906
3987
  if (!this.store.resources.has(resourceId)) {
3907
3988
  throw new ResourceNotFoundError(resourceId);
3908
3989
  }
3909
3990
  return this.store.resources.get(resourceId).value;
3910
- };
3911
- this.dispose = () => {
3991
+ }, "getResourceValue");
3992
+ this.dispose = /* @__PURE__ */ __name(() => {
3912
3993
  return this.disposeFn();
3913
- };
3994
+ }, "dispose");
3914
3995
  }
3915
3996
  };
3997
+ __name(_RunResult, "RunResult");
3998
+ var RunResult = _RunResult;
3916
3999
 
3917
4000
  // src/run.ts
3918
4001
  var platform3 = getPlatform();
3919
4002
  async function run(resourceOrResourceWithConfig, options) {
3920
- await getPlatform().init();
4003
+ await platform3.init();
3921
4004
  const {
3922
4005
  debug = void 0,
3923
4006
  logs = {},
@@ -3960,7 +4043,7 @@ async function run(resourceOrResourceWithConfig, options) {
3960
4043
  logger
3961
4044
  );
3962
4045
  let unhookShutdown;
3963
- const disposeAll = async () => {
4046
+ const disposeAll = /* @__PURE__ */ __name(async () => {
3964
4047
  try {
3965
4048
  if (unhookProcessSafetyNets) {
3966
4049
  unhookProcessSafetyNets();
@@ -3973,7 +4056,7 @@ async function run(resourceOrResourceWithConfig, options) {
3973
4056
  } finally {
3974
4057
  await store2.dispose();
3975
4058
  }
3976
- };
4059
+ }, "disposeAll");
3977
4060
  try {
3978
4061
  if (debug) {
3979
4062
  store2.storeGenericItem(debugResource.with(debug));
@@ -4029,6 +4112,7 @@ async function run(resourceOrResourceWithConfig, options) {
4029
4112
  throw err;
4030
4113
  }
4031
4114
  }
4115
+ __name(run, "run");
4032
4116
  function extractResourceAndConfig(resourceOrResourceWithConfig) {
4033
4117
  let resource;
4034
4118
  let config;
@@ -4041,6 +4125,7 @@ function extractResourceAndConfig(resourceOrResourceWithConfig) {
4041
4125
  }
4042
4126
  return { resource, config };
4043
4127
  }
4128
+ __name(extractResourceAndConfig, "extractResourceAndConfig");
4044
4129
 
4045
4130
  // src/testing.ts
4046
4131
  var testResourceCounter = 0;
@@ -4060,12 +4145,13 @@ function createTestResource(root, options) {
4060
4145
  }
4061
4146
  });
4062
4147
  }
4148
+ __name(createTestResource, "createTestResource");
4063
4149
  function buildTestFacade(deps) {
4064
4150
  return {
4065
4151
  // Run a task within the fully initialized ecosystem
4066
- runTask: (task, ...args) => deps.taskRunner.run(task, ...args),
4152
+ runTask: /* @__PURE__ */ __name((task, ...args) => deps.taskRunner.run(task, ...args), "runTask"),
4067
4153
  // Access a resource value by id (string or symbol)
4068
- getResource: (id2) => deps.store.resources.get(id2)?.value,
4154
+ getResource: /* @__PURE__ */ __name((id2) => deps.store.resources.get(id2)?.value, "getResource"),
4069
4155
  // Expose internals when needed in tests (not recommended for app usage)
4070
4156
  taskRunner: deps.taskRunner,
4071
4157
  store: deps.store,
@@ -4073,9 +4159,10 @@ function buildTestFacade(deps) {
4073
4159
  eventManager: deps.eventManager
4074
4160
  };
4075
4161
  }
4162
+ __name(buildTestFacade, "buildTestFacade");
4076
4163
 
4077
4164
  // src/models/Semaphore.ts
4078
- var Semaphore = class {
4165
+ var _Semaphore = class _Semaphore {
4079
4166
  constructor(maxPermits) {
4080
4167
  this.waitingQueue = [];
4081
4168
  this.disposed = false;
@@ -4110,10 +4197,10 @@ var Semaphore = class {
4110
4197
  }, options.timeout);
4111
4198
  }
4112
4199
  if (options?.signal) {
4113
- const abortHandler = () => {
4200
+ const abortHandler = /* @__PURE__ */ __name(() => {
4114
4201
  this.removeFromQueue(operation);
4115
4202
  reject(new Error("Operation was aborted"));
4116
- };
4203
+ }, "abortHandler");
4117
4204
  options.signal.addEventListener("abort", abortHandler, { once: true });
4118
4205
  const originalResolve = operation.resolve;
4119
4206
  const originalReject = operation.reject;
@@ -4219,6 +4306,8 @@ var Semaphore = class {
4219
4306
  };
4220
4307
  }
4221
4308
  };
4309
+ __name(_Semaphore, "Semaphore");
4310
+ var Semaphore = _Semaphore;
4222
4311
 
4223
4312
  // src/index.ts
4224
4313
  var globals = {