@context-action/core 0.7.2 → 0.7.4
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 +175 -86
- package/dist/index.d.cts +5 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +175 -86
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/ActionRegister.ts","../src/action-guard.ts","../src/execution-modes.ts","../src/react-helpers.ts"],"sourcesContent":[],"mappings":";UAYiB,gBAAA;EAAA,CAAA,UAAA,EAAA,MAAgB,CAAA,EAAA,OAAA;AAwFjC;AAK0C,UALzB,kBAKyB,CAAA,IAAA,GAAA,EAAA,IAAA,IAAA,CAAA,CAAA;OAG1B,CAAA,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/ActionRegister.ts","../src/action-guard.ts","../src/execution-modes.ts","../src/react-helpers.ts"],"sourcesContent":[],"mappings":";UAYiB,gBAAA;EAAA,CAAA,UAAA,EAAA,MAAgB,CAAA,EAAA,OAAA;AAwFjC;AAK0C,UALzB,kBAKyB,CAAA,IAAA,GAAA,EAAA,IAAA,IAAA,CAAA,CAAA;OAG1B,CAAA,MAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;eAmCC,CAAA,QAAA,EAAA,CAAA,OAAA,EAtCmB,CAsCnB,EAAA,GAtCyB,CAsCzB,CAAA,EAAA,IAAA;YAGG,EAAA,EAtCJ,CAsCI;gBAGJ,CAAA,QAAA,EAAA,MAAA,CAAA,EAAA,IAAA;QAGwB,CAAA,MAAA,EATvB,CASuB,CAAA,EAAA,IAAA;WAAoB,CAAA,MAAA,EANxC,CAMwC,CA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AAA,CAAA;;;AACG,cIgBD,gBAAA,SAAyB,KAAA,CJhBxB;WACT,MAAA,EAAA,MAAA;WAAY,OAAA,CAAA,EAAA,GAAA;WAAR,SAAA,EAAA,MAAA,GAAA,SAAA;WAAoB,SAAA,EAAA,MAAA;8GI0BT;EJGH,OAAA,eAAa,CAAA,aAAA,EIgBX,KJhBW,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,EIoBzB,gBJpByB;AA0C9B;AAAoC,iBILpB,kBAAA,CJKoB,KAAA,EAAA,GAAA,CAAA,EAAA,KAAA,IILqB,gBJKrB"}
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,16 @@ async function executeSequential(context, createController) {
|
|
|
49
49
|
const controller = createController(registration, i);
|
|
50
50
|
try {
|
|
51
51
|
if (context.aborted) break;
|
|
52
|
+
if (registration.config.condition) try {
|
|
53
|
+
const shouldExecute = registration.config.condition(context.payload);
|
|
54
|
+
if (!shouldExecute) {
|
|
55
|
+
i++;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
} catch {
|
|
59
|
+
i++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
52
62
|
const result = registration.handler(context.payload, controller);
|
|
53
63
|
if (registration.config.blocking) {
|
|
54
64
|
const handlerResult = result instanceof Promise ? await result : result;
|
|
@@ -73,8 +83,20 @@ async function executeSequential(context, createController) {
|
|
|
73
83
|
if (context.terminated) break;
|
|
74
84
|
/** Handle jump to priority AFTER handler execution */
|
|
75
85
|
if (context.jumpToPriority !== void 0) {
|
|
76
|
-
|
|
77
|
-
if (
|
|
86
|
+
context.jumpCount = (context.jumpCount || 0) + 1;
|
|
87
|
+
if (context.jumpCount > (context.maxJumps || 10)) {
|
|
88
|
+
console.error(`[ActionRegister] ERROR: Maximum jump limit (${context.maxJumps || 10}) exceeded. Aborting to prevent infinite loop. Check your jumpToPriority logic and conditions.`);
|
|
89
|
+
context.aborted = true;
|
|
90
|
+
context.abortReason = `Maximum jump limit exceeded (${context.jumpCount} jumps)`;
|
|
91
|
+
context.jumpToPriority = void 0;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
const jumpIndex = context.handlers.findIndex((handler) => (handler.config.priority || 0) <= context.jumpToPriority);
|
|
95
|
+
if (jumpIndex !== -1 && jumpIndex !== i) {
|
|
96
|
+
if (jumpIndex < i) {
|
|
97
|
+
const targetHandler = context.handlers[jumpIndex];
|
|
98
|
+
if (targetHandler && !targetHandler.config.condition) console.warn(`[ActionRegister] WARNING: Backward jumpToPriority to handler '${targetHandler.config.id || "unnamed"}' without condition. This may cause infinite loops! Consider adding a condition to prevent re-execution. Jump count: ${context.jumpCount}/${context.maxJumps || 10}`);
|
|
99
|
+
}
|
|
78
100
|
i = jumpIndex;
|
|
79
101
|
context.jumpToPriority = void 0;
|
|
80
102
|
continue;
|
|
@@ -85,7 +107,9 @@ async function executeSequential(context, createController) {
|
|
|
85
107
|
} else i++;
|
|
86
108
|
} catch (error) {
|
|
87
109
|
const handlerError = handleExecutionError(error, registration);
|
|
88
|
-
|
|
110
|
+
errors.push(handlerError);
|
|
111
|
+
if (registration.config.blocking) throw handlerError.error;
|
|
112
|
+
i++;
|
|
89
113
|
}
|
|
90
114
|
}
|
|
91
115
|
if (nonBlockingPromises.length > 0) await Promise.allSettled(nonBlockingPromises);
|
|
@@ -125,6 +149,24 @@ async function executeParallel(context, createController) {
|
|
|
125
149
|
const handlerPromises = runnableHandlers.map(async (registration, _index) => {
|
|
126
150
|
const controller = createController(registration, _index);
|
|
127
151
|
try {
|
|
152
|
+
if (registration.config.condition) try {
|
|
153
|
+
const shouldExecute = registration.config.condition(context.payload);
|
|
154
|
+
if (!shouldExecute) return {
|
|
155
|
+
success: true,
|
|
156
|
+
handlerId: registration.id,
|
|
157
|
+
result: void 0,
|
|
158
|
+
terminated: false,
|
|
159
|
+
skipped: true
|
|
160
|
+
};
|
|
161
|
+
} catch {
|
|
162
|
+
return {
|
|
163
|
+
success: true,
|
|
164
|
+
handlerId: registration.id,
|
|
165
|
+
result: void 0,
|
|
166
|
+
terminated: false,
|
|
167
|
+
skipped: true
|
|
168
|
+
};
|
|
169
|
+
}
|
|
128
170
|
const result = registration.handler(context.payload, controller);
|
|
129
171
|
let handlerResult;
|
|
130
172
|
if (result instanceof Promise) {
|
|
@@ -199,6 +241,26 @@ async function executeRace(context, createController) {
|
|
|
199
241
|
const handlerPromises = runnableHandlers.map(async (registration, _index) => {
|
|
200
242
|
const controller = createController(registration, _index);
|
|
201
243
|
try {
|
|
244
|
+
if (registration.config.condition) try {
|
|
245
|
+
const shouldExecute = registration.config.condition(context.payload);
|
|
246
|
+
if (!shouldExecute) return {
|
|
247
|
+
success: true,
|
|
248
|
+
handlerId: registration.id,
|
|
249
|
+
registration,
|
|
250
|
+
result: void 0,
|
|
251
|
+
terminated: false,
|
|
252
|
+
skipped: true
|
|
253
|
+
};
|
|
254
|
+
} catch {
|
|
255
|
+
return {
|
|
256
|
+
success: true,
|
|
257
|
+
handlerId: registration.id,
|
|
258
|
+
registration,
|
|
259
|
+
result: void 0,
|
|
260
|
+
terminated: false,
|
|
261
|
+
skipped: true
|
|
262
|
+
};
|
|
263
|
+
}
|
|
202
264
|
const result = registration.handler(context.payload, controller);
|
|
203
265
|
let handlerResult;
|
|
204
266
|
if (result instanceof Promise) {
|
|
@@ -528,13 +590,15 @@ var ActionGuard = class {
|
|
|
528
590
|
//#region src/concurrency/OperationQueue.ts
|
|
529
591
|
/**
|
|
530
592
|
* 작업 큐 관리자
|
|
531
|
-
*
|
|
593
|
+
*
|
|
532
594
|
* 핵심 기능:
|
|
533
595
|
* 1. 작업 직렬화 - 모든 작업을 순서대로 실행
|
|
534
596
|
* 2. 우선순위 지원 - 중요한 작업 우선 처리
|
|
535
597
|
* 3. 에러 처리 - 개별 작업 실패가 전체에 영향 주지 않음
|
|
536
598
|
* 4. 메모리 관리 - 완료된 작업 자동 정리
|
|
537
599
|
* 5. 🆕 동시성 제어 - maxConcurrency로 동시 실행 제한
|
|
600
|
+
* 6. 🆕 비동기 지원 - Promise.all() 완벽 지원
|
|
601
|
+
* 7. 🆕 이벤트 기반 처리 - 효율적인 큐 처리 시스템
|
|
538
602
|
*/
|
|
539
603
|
var OperationQueue = class {
|
|
540
604
|
constructor(name = "OperationQueue", maxConcurrency = 1) {
|
|
@@ -543,7 +607,7 @@ var OperationQueue = class {
|
|
|
543
607
|
this.processingPromise = null;
|
|
544
608
|
this.operationCounter = 0;
|
|
545
609
|
this.activeOperations = 0;
|
|
546
|
-
this.
|
|
610
|
+
this.pendingResolvers = [];
|
|
547
611
|
this.maxConcurrency = Math.max(1, maxConcurrency);
|
|
548
612
|
}
|
|
549
613
|
/**
|
|
@@ -572,13 +636,18 @@ var OperationQueue = class {
|
|
|
572
636
|
}
|
|
573
637
|
}
|
|
574
638
|
this.queue.splice(insertIndex, 0, queuedOperation);
|
|
639
|
+
if (this.processingPromise) this.notifyNewOperation();
|
|
575
640
|
this.processQueue();
|
|
576
641
|
});
|
|
577
642
|
}
|
|
578
643
|
/**
|
|
579
|
-
* 🆕 큐 처리 메인 로직 - 동시성 제어 지원
|
|
580
|
-
*
|
|
581
|
-
*
|
|
644
|
+
* 🆕 큐 처리 메인 로직 - 동시성 제어 및 비동기 지원
|
|
645
|
+
*
|
|
646
|
+
* 주요 특징:
|
|
647
|
+
* - maxConcurrency에 따라 동시 실행 작업 수를 제한하여 동시성 문제 방지
|
|
648
|
+
* - Promise.all() 시나리오에서 완벽한 순차적 실행 보장
|
|
649
|
+
* - 이벤트 기반 알림 시스템으로 효율적인 비동기 처리
|
|
650
|
+
* - 작업 완료 시 대기 중인 프로세스에게 자동 알림
|
|
582
651
|
*/
|
|
583
652
|
async processQueue() {
|
|
584
653
|
if (this.processingPromise) return this.processingPromise;
|
|
@@ -590,21 +659,46 @@ var OperationQueue = class {
|
|
|
590
659
|
}
|
|
591
660
|
}
|
|
592
661
|
async _doProcess() {
|
|
593
|
-
while (this.queue.length > 0 || this.
|
|
662
|
+
while (this.queue.length > 0 || this.activeOperations > 0) {
|
|
594
663
|
while (this.queue.length > 0 && this.activeOperations < this.maxConcurrency) {
|
|
595
664
|
const operation = this.queue.shift();
|
|
596
|
-
this.
|
|
597
|
-
const operationPromise = this.executeOperation(operation);
|
|
598
|
-
this.runningOperations.add(operationPromise);
|
|
599
|
-
operationPromise.finally(() => {
|
|
600
|
-
this.activeOperations--;
|
|
601
|
-
this.runningOperations.delete(operationPromise);
|
|
602
|
-
});
|
|
665
|
+
this.startOperation(operation);
|
|
603
666
|
}
|
|
604
|
-
if (this.
|
|
667
|
+
if (this.activeOperations > 0) await this.waitForAnyOperation();
|
|
605
668
|
}
|
|
606
669
|
}
|
|
607
670
|
/**
|
|
671
|
+
* 🆕 개별 작업을 시작하고 완료를 추적
|
|
672
|
+
*/
|
|
673
|
+
startOperation(operation) {
|
|
674
|
+
this.activeOperations++;
|
|
675
|
+
this.executeOperation(operation).finally(() => {
|
|
676
|
+
this.activeOperations--;
|
|
677
|
+
this.notifyOperationComplete();
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* 🆕 하나의 작업이 완료될 때까지 대기하거나 새로운 작업이 추가될 때까지 대기
|
|
682
|
+
*/
|
|
683
|
+
waitForAnyOperation() {
|
|
684
|
+
return new Promise((resolve) => {
|
|
685
|
+
this.pendingResolvers.push(resolve);
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* 🆕 작업 완료 신호 - 대기 중인 프로세스들에게 알림
|
|
690
|
+
*/
|
|
691
|
+
notifyOperationComplete() {
|
|
692
|
+
const resolvers = this.pendingResolvers.splice(0);
|
|
693
|
+
resolvers.forEach((resolve) => resolve());
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* 🆕 새로운 작업 추가 신호 - processQueue에서 호출
|
|
697
|
+
*/
|
|
698
|
+
notifyNewOperation() {
|
|
699
|
+
this.notifyOperationComplete();
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
608
702
|
* 🆕 개별 작업 실행 로직
|
|
609
703
|
*/
|
|
610
704
|
async executeOperation(operation) {
|
|
@@ -625,7 +719,6 @@ var OperationQueue = class {
|
|
|
625
719
|
isProcessing: Boolean(this.processingPromise),
|
|
626
720
|
activeOperations: this.activeOperations,
|
|
627
721
|
maxConcurrency: this.maxConcurrency,
|
|
628
|
-
runningOperationsCount: this.runningOperations.size,
|
|
629
722
|
operations: this.queue.map((op) => ({
|
|
630
723
|
id: op.id,
|
|
631
724
|
priority: op.priority,
|
|
@@ -654,6 +747,8 @@ var OperationQueue = class {
|
|
|
654
747
|
});
|
|
655
748
|
this.queue = [];
|
|
656
749
|
this.processingPromise = null;
|
|
750
|
+
const resolvers = this.pendingResolvers.splice(0);
|
|
751
|
+
resolvers.forEach((resolve) => resolve());
|
|
657
752
|
}
|
|
658
753
|
/**
|
|
659
754
|
* 큐 크기 조회
|
|
@@ -692,7 +787,8 @@ var ActionRegister = class {
|
|
|
692
787
|
this.executionMode = "sequential";
|
|
693
788
|
this.actionExecutionModes = /* @__PURE__ */ new Map();
|
|
694
789
|
this.unregisterFunctions = /* @__PURE__ */ new Map();
|
|
695
|
-
this.
|
|
790
|
+
this.lastRegisteredTimestamps = /* @__PURE__ */ new Map();
|
|
791
|
+
this.filterCacheDisabled = true;
|
|
696
792
|
this.handlerIdCounter = 0;
|
|
697
793
|
this.controllerPool = [];
|
|
698
794
|
this.maxControllerPoolSize = 10;
|
|
@@ -812,8 +908,9 @@ var ActionRegister = class {
|
|
|
812
908
|
once: config.once ?? false,
|
|
813
909
|
debounce: config.debounce ?? void 0,
|
|
814
910
|
throttle: config.throttle ?? void 0,
|
|
815
|
-
replaceExisting: config.replaceExisting ??
|
|
816
|
-
cleanup: config.cleanup
|
|
911
|
+
replaceExisting: config.replaceExisting ?? true,
|
|
912
|
+
cleanup: config.cleanup,
|
|
913
|
+
condition: config.condition
|
|
817
914
|
},
|
|
818
915
|
id: handlerId
|
|
819
916
|
};
|
|
@@ -827,19 +924,16 @@ var ActionRegister = class {
|
|
|
827
924
|
if (existingIndex !== -1) {
|
|
828
925
|
const existing = pipeline[existingIndex];
|
|
829
926
|
const existingUnregister = this.unregisterFunctions.get(handlerId);
|
|
830
|
-
if (config.replaceExisting) {
|
|
831
|
-
if (
|
|
832
|
-
|
|
833
|
-
this.unregisterFunctions.delete(handlerId);
|
|
834
|
-
}
|
|
835
|
-
if (existing && typeof existing.cleanup === "function") try {
|
|
836
|
-
existing.cleanup();
|
|
927
|
+
if (registration.config.replaceExisting) {
|
|
928
|
+
if (existing && existing.config.cleanup && typeof existing.config.cleanup === "function") try {
|
|
929
|
+
existing.config.cleanup();
|
|
837
930
|
} catch (cleanupError) {
|
|
838
931
|
this.log(`Cleanup error for replaced handler: ${String(action)}`, cleanupError, "warn");
|
|
839
932
|
}
|
|
933
|
+
if (existingUnregister) this.unregisterFunctions.delete(handlerId);
|
|
840
934
|
pipeline[existingIndex] = registration;
|
|
841
935
|
pipeline.sort((a, b) => b.config.priority - a.config.priority);
|
|
842
|
-
this.
|
|
936
|
+
this.lastRegisteredTimestamps.set(action, /* @__PURE__ */ new Date());
|
|
843
937
|
const newUnregister = this.createUnregisterFunction(action, handlerId, registration);
|
|
844
938
|
this.unregisterFunctions.set(handlerId, newUnregister);
|
|
845
939
|
this.log(`Handler replaced: ${String(action)}`, {
|
|
@@ -869,7 +963,7 @@ var ActionRegister = class {
|
|
|
869
963
|
}
|
|
870
964
|
pipeline.push(registration);
|
|
871
965
|
pipeline.sort((a, b) => b.config.priority - a.config.priority);
|
|
872
|
-
this.
|
|
966
|
+
this.lastRegisteredTimestamps.set(action, /* @__PURE__ */ new Date());
|
|
873
967
|
const unregister = this.createUnregisterFunction(action, handlerId, registration);
|
|
874
968
|
this.unregisterFunctions.set(handlerId, unregister);
|
|
875
969
|
this.log(`Handler registered: ${String(action)}`, {
|
|
@@ -963,6 +1057,8 @@ var ActionRegister = class {
|
|
|
963
1057
|
abortReason: void 0,
|
|
964
1058
|
currentIndex: 0,
|
|
965
1059
|
jumpToPriority: void 0,
|
|
1060
|
+
jumpCount: 0,
|
|
1061
|
+
maxJumps: 10,
|
|
966
1062
|
executionMode: currentExecutionMode,
|
|
967
1063
|
results: [],
|
|
968
1064
|
terminated: false,
|
|
@@ -1054,6 +1150,8 @@ var ActionRegister = class {
|
|
|
1054
1150
|
abortReason: void 0,
|
|
1055
1151
|
currentIndex: 0,
|
|
1056
1152
|
jumpToPriority: void 0,
|
|
1153
|
+
jumpCount: 0,
|
|
1154
|
+
maxJumps: 10,
|
|
1057
1155
|
executionMode: currentExecutionMode,
|
|
1058
1156
|
results: [],
|
|
1059
1157
|
terminated: false,
|
|
@@ -1214,32 +1312,19 @@ var ActionRegister = class {
|
|
|
1214
1312
|
return null;
|
|
1215
1313
|
}
|
|
1216
1314
|
/**
|
|
1217
|
-
* 🔧
|
|
1218
|
-
* Note: This caches handler SELECTION metadata only, never execution results
|
|
1219
|
-
*/
|
|
1220
|
-
get filterCacheMaxSize() {
|
|
1221
|
-
const totalHandlers = Array.from(this.pipelines.values()).reduce((sum, pipeline) => sum + pipeline.length, 0);
|
|
1222
|
-
return totalHandlers * 10 || 100;
|
|
1223
|
-
}
|
|
1224
|
-
/**
|
|
1225
|
-
* 🔧 Generate cache key for filter options
|
|
1315
|
+
* 🔧 Generate optimized cache key for filter options
|
|
1226
1316
|
*/
|
|
1227
1317
|
generateFilterCacheKey(filterOptions) {
|
|
1228
1318
|
if (!filterOptions) return "no-filter";
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
filterOptions.priority
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
return
|
|
1237
|
-
|
|
1238
|
-
/**
|
|
1239
|
-
* 🔧 Clear filter cache when pipelines change
|
|
1240
|
-
*/
|
|
1241
|
-
invalidateFilterCache() {
|
|
1242
|
-
this.filterCache.clear();
|
|
1319
|
+
const parts = [];
|
|
1320
|
+
if (filterOptions.handlerIds?.length) parts.push(`h:${filterOptions.handlerIds.slice().sort().join(",")}`);
|
|
1321
|
+
if (filterOptions.excludeHandlerIds?.length) parts.push(`e:${filterOptions.excludeHandlerIds.slice().sort().join(",")}`);
|
|
1322
|
+
if (filterOptions.priority) {
|
|
1323
|
+
const { min, max } = filterOptions.priority;
|
|
1324
|
+
if (min !== void 0 || max !== void 0) parts.push(`p:${min ?? "*"}-${max ?? "*"}`);
|
|
1325
|
+
}
|
|
1326
|
+
if (filterOptions.custom) return "custom-" + Date.now() + Math.random();
|
|
1327
|
+
return parts.length > 0 ? parts.join("|") : "no-filter";
|
|
1243
1328
|
}
|
|
1244
1329
|
/**
|
|
1245
1330
|
* 🔧 Create or reuse PipelineController from pool for better performance
|
|
@@ -1253,7 +1338,11 @@ var ActionRegister = class {
|
|
|
1253
1338
|
if (autoAbortController && autoAbortOptions?.allowHandlerAbort) autoAbortController.abort(reason);
|
|
1254
1339
|
};
|
|
1255
1340
|
controller.modifyPayload = (modifier) => {
|
|
1256
|
-
|
|
1341
|
+
try {
|
|
1342
|
+
context.payload = modifier(context.payload);
|
|
1343
|
+
} catch (modificationError) {
|
|
1344
|
+
this.log("Payload modification error", modificationError, "warn");
|
|
1345
|
+
}
|
|
1257
1346
|
};
|
|
1258
1347
|
controller.getPayload = () => context.payload;
|
|
1259
1348
|
controller.jumpToPriority = (priority) => {
|
|
@@ -1285,36 +1374,27 @@ var ActionRegister = class {
|
|
|
1285
1374
|
}
|
|
1286
1375
|
filterHandlers(handlers, filterOptions) {
|
|
1287
1376
|
if (!filterOptions) return handlers;
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1290
|
-
const cached = this.filterCache.get(cacheKey);
|
|
1291
|
-
if (cached) return cached;
|
|
1292
|
-
}
|
|
1377
|
+
const handlerIdSet = filterOptions.handlerIds ? new Set(filterOptions.handlerIds) : null;
|
|
1378
|
+
const excludeIdSet = filterOptions.excludeHandlerIds ? new Set(filterOptions.excludeHandlerIds) : null;
|
|
1293
1379
|
const filtered = handlers.filter((registration) => {
|
|
1294
1380
|
const config = registration.config;
|
|
1295
|
-
if (
|
|
1296
|
-
if (
|
|
1381
|
+
if (handlerIdSet && !handlerIdSet.has(config.id)) return false;
|
|
1382
|
+
if (excludeIdSet && excludeIdSet.has(config.id)) return false;
|
|
1297
1383
|
if (filterOptions.priority) {
|
|
1298
|
-
|
|
1299
|
-
if (filterOptions.priority.
|
|
1384
|
+
const priority = config.priority;
|
|
1385
|
+
if (filterOptions.priority.min !== void 0 && priority < filterOptions.priority.min) return false;
|
|
1386
|
+
if (filterOptions.priority.max !== void 0 && priority > filterOptions.priority.max) return false;
|
|
1300
1387
|
}
|
|
1301
1388
|
if (filterOptions.custom && !filterOptions.custom(config)) return false;
|
|
1302
1389
|
return true;
|
|
1303
1390
|
});
|
|
1304
|
-
if (!filterOptions.custom) {
|
|
1305
|
-
const currentMaxSize = this.filterCacheMaxSize;
|
|
1306
|
-
if (this.filterCache.size >= currentMaxSize) {
|
|
1307
|
-
const oldestKey = this.filterCache.keys().next().value;
|
|
1308
|
-
if (oldestKey !== void 0) this.filterCache.delete(oldestKey);
|
|
1309
|
-
}
|
|
1310
|
-
this.filterCache.set(cacheKey, filtered);
|
|
1311
|
-
}
|
|
1312
1391
|
return filtered;
|
|
1313
1392
|
}
|
|
1314
1393
|
processResults(context, resultOptions) {
|
|
1315
|
-
if (!resultOptions || !resultOptions.collect) return void 0;
|
|
1316
1394
|
const results = context.results;
|
|
1317
1395
|
if (context.terminated && context.terminationResult !== void 0) return context.terminationResult;
|
|
1396
|
+
if (!resultOptions) return results.length > 0 ? results[results.length - 1] : void 0;
|
|
1397
|
+
if (!resultOptions.collect && !resultOptions.strategy) return void 0;
|
|
1318
1398
|
const limitedResults = resultOptions.maxResults ? results.slice(0, resultOptions.maxResults) : results;
|
|
1319
1399
|
if (limitedResults.length === 0) return void 0;
|
|
1320
1400
|
switch (resultOptions.strategy) {
|
|
@@ -1327,7 +1407,9 @@ var ActionRegister = class {
|
|
|
1327
1407
|
case "custom":
|
|
1328
1408
|
if (resultOptions.merger) return resultOptions.merger(limitedResults);
|
|
1329
1409
|
throw new Error("Custom result strategy requires a merger function");
|
|
1330
|
-
default:
|
|
1410
|
+
default:
|
|
1411
|
+
if (resultOptions.collect) return limitedResults;
|
|
1412
|
+
return limitedResults[limitedResults.length - 1];
|
|
1331
1413
|
}
|
|
1332
1414
|
}
|
|
1333
1415
|
async executePipeline(context, autoAbortController, autoAbortOptions) {
|
|
@@ -1364,6 +1446,10 @@ var ActionRegister = class {
|
|
|
1364
1446
|
});
|
|
1365
1447
|
}
|
|
1366
1448
|
});
|
|
1449
|
+
if (pipeline.length === 0) {
|
|
1450
|
+
this.pipelines.delete(action);
|
|
1451
|
+
this.lastRegisteredTimestamps.delete(action);
|
|
1452
|
+
}
|
|
1367
1453
|
}
|
|
1368
1454
|
/**
|
|
1369
1455
|
* Get the number of registered handlers for an action
|
|
@@ -1417,7 +1503,7 @@ var ActionRegister = class {
|
|
|
1417
1503
|
*/
|
|
1418
1504
|
clearAction(action) {
|
|
1419
1505
|
this.pipelines.delete(action);
|
|
1420
|
-
this.
|
|
1506
|
+
this.lastRegisteredTimestamps.delete(action);
|
|
1421
1507
|
}
|
|
1422
1508
|
/**
|
|
1423
1509
|
* Remove all handlers for all actions
|
|
@@ -1428,7 +1514,7 @@ var ActionRegister = class {
|
|
|
1428
1514
|
*/
|
|
1429
1515
|
clearAll() {
|
|
1430
1516
|
this.pipelines.clear();
|
|
1431
|
-
this.
|
|
1517
|
+
this.lastRegisteredTimestamps.clear();
|
|
1432
1518
|
}
|
|
1433
1519
|
/**
|
|
1434
1520
|
* Get the name of this action register
|
|
@@ -1482,7 +1568,8 @@ var ActionRegister = class {
|
|
|
1482
1568
|
handlerCount: pipeline.length,
|
|
1483
1569
|
totalHandlers: pipeline.length,
|
|
1484
1570
|
handlersByPriority,
|
|
1485
|
-
executionStats
|
|
1571
|
+
executionStats,
|
|
1572
|
+
lastRegistered: this.lastRegisteredTimestamps.get(action)
|
|
1486
1573
|
};
|
|
1487
1574
|
}
|
|
1488
1575
|
/**
|
|
@@ -1562,8 +1649,11 @@ var ActionRegister = class {
|
|
|
1562
1649
|
const index = pipeline.findIndex((reg) => reg.id === handlerId && reg === registration);
|
|
1563
1650
|
if (index !== -1) {
|
|
1564
1651
|
pipeline.splice(index, 1);
|
|
1565
|
-
this.invalidateFilterCache();
|
|
1566
1652
|
this.unregisterFunctions.delete(handlerId);
|
|
1653
|
+
if (pipeline.length === 0) {
|
|
1654
|
+
this.pipelines.delete(action);
|
|
1655
|
+
this.lastRegisteredTimestamps.delete(action);
|
|
1656
|
+
}
|
|
1567
1657
|
if (registration.config.cleanup && typeof registration.config.cleanup === "function") try {
|
|
1568
1658
|
registration.config.cleanup();
|
|
1569
1659
|
} catch (cleanupError) {
|
|
@@ -1571,7 +1661,8 @@ var ActionRegister = class {
|
|
|
1571
1661
|
}
|
|
1572
1662
|
this.log(`Handler unregistered: ${String(action)}`, {
|
|
1573
1663
|
handlerId,
|
|
1574
|
-
remainingHandlers: pipeline.length
|
|
1664
|
+
remainingHandlers: pipeline.length,
|
|
1665
|
+
actionRemoved: pipeline.length === 0
|
|
1575
1666
|
});
|
|
1576
1667
|
}
|
|
1577
1668
|
};
|
|
@@ -1604,19 +1695,17 @@ var ActionRegister = class {
|
|
|
1604
1695
|
* @public
|
|
1605
1696
|
*/
|
|
1606
1697
|
destroy() {
|
|
1607
|
-
this.unregisterFunctions.forEach((unregister) => {
|
|
1608
|
-
try {
|
|
1609
|
-
unregister();
|
|
1610
|
-
} catch (error) {
|
|
1611
|
-
this.log("Error during unregister in destroy", error, "error");
|
|
1612
|
-
}
|
|
1613
|
-
});
|
|
1614
1698
|
this.unregisterFunctions.clear();
|
|
1699
|
+
for (const [action, pipeline] of this.pipelines.entries()) for (const registration of pipeline) if (registration.config.cleanup && typeof registration.config.cleanup === "function") try {
|
|
1700
|
+
registration.config.cleanup();
|
|
1701
|
+
} catch (cleanupError) {
|
|
1702
|
+
this.log(`Cleanup error for handler during destroy: ${String(action)}`, cleanupError, "warn");
|
|
1703
|
+
}
|
|
1615
1704
|
this.pipelines.clear();
|
|
1705
|
+
this.lastRegisteredTimestamps.clear();
|
|
1616
1706
|
this.actionGuard.destroy();
|
|
1617
1707
|
this.dispatchQueue?.clear?.();
|
|
1618
1708
|
this.actionExecutionModes.clear();
|
|
1619
|
-
this.filterCache.clear();
|
|
1620
1709
|
this.controllerPool.length = 0;
|
|
1621
1710
|
this.log("ActionRegister destroyed");
|
|
1622
1711
|
}
|