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