@routier/core 0.2.1 → 0.4.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/LICENSE +21 -0
- package/{readme.md → README.md} +3 -3
- package/dist/assertions/index.cjs +191 -0
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.js +43 -63
- package/dist/assertions/index.js.map +1 -1
- package/dist/capabilities/index.cjs +820 -0
- package/dist/capabilities/index.cjs.map +1 -0
- package/dist/capabilities/index.js +584 -558
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
- package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
- package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
- package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
- package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
- package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
- package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
- package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
- package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
- package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
- package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
- package/dist/codegen/handlers/types.d.ts +55 -1
- package/dist/codegen/index.cjs +618 -0
- package/dist/codegen/index.cjs.map +1 -0
- package/dist/codegen/index.js +99 -127
- package/dist/codegen/index.js.map +1 -1
- package/dist/collections/MemoryDataCollection.d.ts +15 -1
- package/dist/collections/TagCollection.d.ts +0 -1
- package/dist/collections/index.cjs +702 -0
- package/dist/collections/index.cjs.map +1 -0
- package/dist/collections/index.js +282 -276
- package/dist/collections/index.js.map +1 -1
- package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
- package/dist/errors/PluginDestroyedError.d.ts +10 -0
- package/dist/errors/index.cjs +132 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +61 -19
- package/dist/errors/index.js.map +1 -1
- package/dist/expressions/evaluate.d.ts +53 -0
- package/dist/expressions/index.cjs +2087 -0
- package/dist/expressions/index.cjs.map +1 -0
- package/dist/expressions/index.d.ts +1 -1
- package/dist/expressions/index.js +1727 -1082
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/parser.d.ts +19 -0
- package/dist/expressions/types.d.ts +87 -2
- package/dist/index.cjs +14377 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +12374 -7931
- package/dist/index.js.map +1 -1
- package/dist/performance/index.cjs +217 -0
- package/dist/performance/index.cjs.map +1 -0
- package/dist/performance/index.js +120 -55
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.cjs +576 -0
- package/dist/pipeline/index.cjs.map +1 -0
- package/dist/pipeline/index.js +223 -161
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
- package/dist/plugins/CacheDbPlugin.d.ts +70 -0
- package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
- package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
- package/dist/plugins/RetryDbPlugin.d.ts +77 -0
- package/dist/plugins/index.cjs +6551 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +6271 -1170
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/QueryOptionsCollection.d.ts +34 -0
- package/dist/plugins/query/explain.d.ts +82 -0
- package/dist/plugins/query/formatExplanation.d.ts +9 -0
- package/dist/plugins/query/index.d.ts +4 -0
- package/dist/plugins/query/join.d.ts +210 -0
- package/dist/plugins/query/similarity.d.ts +38 -0
- package/dist/plugins/query/types.d.ts +75 -1
- package/dist/plugins/translators/DataTranslator.d.ts +28 -0
- package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
- package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
- package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
- package/dist/plugins/translators/index.d.ts +1 -0
- package/dist/plugins/types.d.ts +125 -3
- package/dist/plugins/wire/handler.d.ts +122 -0
- package/dist/plugins/wire/index.d.ts +4 -0
- package/dist/plugins/wire/persist.d.ts +43 -0
- package/dist/plugins/wire/query.d.ts +49 -0
- package/dist/plugins/wire/types.d.ts +139 -0
- package/dist/results/index.cjs +174 -0
- package/dist/results/index.cjs.map +1 -0
- package/dist/results/index.js +29 -44
- package/dist/results/index.js.map +1 -1
- package/dist/schema/PropertyInfo.d.ts +31 -2
- package/dist/schema/SchemaDefinition.d.ts +23 -1
- package/dist/schema/builder.d.ts +35 -1
- package/dist/schema/communication/broadcast.d.ts +17 -1
- package/dist/schema/index.cjs +6911 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +5330 -4541
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +48 -2
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
- package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
- package/dist/schema/property/modifiers/index.d.ts +1 -0
- package/dist/schema/property/types/SchemaFile.d.ts +60 -0
- package/dist/schema/property/types/SchemaString.d.ts +21 -1
- package/dist/schema/property/types/SchemaVector.d.ts +61 -0
- package/dist/schema/property/types/index.d.ts +2 -0
- package/dist/schema/table/SchemaTransform.d.ts +40 -0
- package/dist/schema/table/index.d.ts +1 -0
- package/dist/schema/types.d.ts +166 -8
- package/dist/schema/utils/propertyKind.d.ts +4 -0
- package/dist/types/index.cjs +23 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.js +0 -14
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.cjs +1013 -0
- package/dist/utilities/index.cjs.map +1 -0
- package/dist/utilities/index.js +541 -379
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/logger.d.ts +48 -0
- package/package.json +156 -98
- package/dist/codegen/SlotPath.test.d.ts +0 -1
- package/dist/codegen/blocks.test.d.ts +0 -1
- package/dist/codegen/utils.test.d.ts +0 -1
- package/dist/collections/Changes.test.d.ts +0 -1
- package/dist/collections/IdSet.test.d.ts +0 -1
- package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
- package/dist/collections/TagCollection.contract.test.d.ts +0 -1
- package/dist/collections/TagCollection.test.d.ts +0 -1
- package/dist/expressions/parser.test.d.ts +0 -1
- package/dist/expressions/sql.d.ts +0 -28
- package/dist/expressions/sql.test.d.ts +0 -1
- package/dist/expressions/utils.test.d.ts +0 -1
- package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
- package/dist/plugins/query/Query.test.d.ts +0 -1
- package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
- package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
- package/dist/results/Result.test.d.ts +0 -1
- package/dist/results/utils.test.d.ts +0 -1
- package/dist/schema/PropertyInfo.test.d.ts +0 -1
- package/dist/schema/communication/broadcast.test.d.ts +0 -1
- package/dist/schema/schemaGeneration.test.d.ts +0 -1
- package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
- package/dist/utilities/arrays.test.d.ts +0 -1
- package/dist/utilities/dates.test.d.ts +0 -1
- package/dist/utilities/runtime.test.d.ts +0 -1
- package/dist/utilities/strings.test.d.ts +0 -1
- package/dist/utilities/uuid.test.d.ts +0 -1
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_modules__ = ({
|
|
4
|
+
416(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
6
|
+
U: () => (WorkPipeline),
|
|
7
|
+
k: () => (TrampolinePipeline)
|
|
8
|
+
});
|
|
9
|
+
/* import */ var _utilities__rspack_import_0 = __webpack_require__(581);
|
|
10
|
+
/* import */ var _results__rspack_import_1 = __webpack_require__(718);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TrampolinePipeline {
|
|
14
|
+
_list = [];
|
|
15
|
+
_hasErrored = false;
|
|
16
|
+
filter(initialData, done) {
|
|
17
|
+
this._hasErrored = false; // Reset error flag on new execution
|
|
18
|
+
if (this._list.length === 0) {
|
|
19
|
+
done(initialData);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let index = 0;
|
|
23
|
+
let currentData = initialData;
|
|
24
|
+
let isRunning = false; // Guard against overlapping trampoline calls
|
|
25
|
+
try {
|
|
26
|
+
// --- Revised Completion Logic --- (Moved up for clarity)
|
|
27
|
+
const finalStepSentinel = ()=>{
|
|
28
|
+
// Only call done if no error has occurred
|
|
29
|
+
if (!this._hasErrored) {
|
|
30
|
+
done(currentData);
|
|
31
|
+
}
|
|
32
|
+
return null; // Stop the trampoline
|
|
33
|
+
};
|
|
34
|
+
const createStepRevised = (idx)=>{
|
|
35
|
+
return ()=>{
|
|
36
|
+
if (this._hasErrored) return null; // Stop if an error occurred elsewhere
|
|
37
|
+
if (idx >= this._list.length) {
|
|
38
|
+
return finalStepSentinel(); // Execute the dedicated final step
|
|
39
|
+
}
|
|
40
|
+
const processor = this._list[idx];
|
|
41
|
+
// Initialize syncCallbackResult to null to satisfy StepResult type
|
|
42
|
+
let syncCallbackResult = null;
|
|
43
|
+
let calledSync = false;
|
|
44
|
+
try {
|
|
45
|
+
processor(currentData, (result, error)=>{
|
|
46
|
+
// --- Error Handling ---
|
|
47
|
+
if (error) {
|
|
48
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error reported by processor at index ${idx}:`, error);
|
|
49
|
+
this._hasErrored = true; // Set flag
|
|
50
|
+
// Throw the error to be caught by outer try...catch blocks
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
// --- /Error Handling ---
|
|
54
|
+
// If no error, proceed as before
|
|
55
|
+
currentData = result;
|
|
56
|
+
index = idx + 1; // Update index for the next step
|
|
57
|
+
const nextStep = createStepRevised(index); // Use updated index
|
|
58
|
+
if (isRunning) {
|
|
59
|
+
// Callback was synchronous
|
|
60
|
+
syncCallbackResult = nextStep; // Store next step function
|
|
61
|
+
calledSync = true;
|
|
62
|
+
} else {
|
|
63
|
+
// Callback was asynchronous, restart trampoline
|
|
64
|
+
trampoline(nextStep);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (!this._hasErrored) {
|
|
69
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
70
|
+
this._hasErrored = true;
|
|
71
|
+
}
|
|
72
|
+
// Rethrow to be caught by the trampoline's catch block
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
if (calledSync) {
|
|
76
|
+
// Return the next step function for the sync loop
|
|
77
|
+
return syncCallbackResult;
|
|
78
|
+
} else {
|
|
79
|
+
// Pause trampoline for async, loop will stop as step returns null
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
// The trampoline loop
|
|
85
|
+
const trampoline = (step)=>{
|
|
86
|
+
if (isRunning) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
isRunning = true;
|
|
90
|
+
let currentStep = step;
|
|
91
|
+
while(currentStep !== null){
|
|
92
|
+
try {
|
|
93
|
+
// Stop immediately if an error was flagged elsewhere
|
|
94
|
+
if (this._hasErrored) {
|
|
95
|
+
currentStep = null;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
currentStep = currentStep(); // Execute step, get next step or null
|
|
99
|
+
} catch (trampolineError) {
|
|
100
|
+
// Catch errors propagated from step execution (processor or callback errors)
|
|
101
|
+
if (!this._hasErrored) {
|
|
102
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error("Error during trampoline step execution:", trampolineError);
|
|
103
|
+
this._hasErrored = true;
|
|
104
|
+
}
|
|
105
|
+
currentStep = null; // Stop the loop
|
|
106
|
+
// Report the failure to the caller.
|
|
107
|
+
//
|
|
108
|
+
// This used to break without calling `done`, on the reasoning that
|
|
109
|
+
// the application should handle the uncaught exception. It cannot:
|
|
110
|
+
// the error is caught right here, so nothing escapes to be handled,
|
|
111
|
+
// and every caller awaiting the callback waits forever. A hang is
|
|
112
|
+
// strictly worse than an error — it gives the caller nothing to act
|
|
113
|
+
// on and no way to time out.
|
|
114
|
+
//
|
|
115
|
+
// `done` runs exactly once per execution: this path returns
|
|
116
|
+
// immediately, and finalStepSentinel checks `_hasErrored` before
|
|
117
|
+
// reporting success, so the two are mutually exclusive.
|
|
118
|
+
isRunning = false;
|
|
119
|
+
done(currentData, trampolineError);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Loop ends when currentStep is null or loop is broken by error
|
|
124
|
+
isRunning = false;
|
|
125
|
+
// Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.
|
|
126
|
+
};
|
|
127
|
+
// --- Start the process ---
|
|
128
|
+
index = 0; // Reset index
|
|
129
|
+
currentData = initialData; // Reset data
|
|
130
|
+
trampoline(createStepRevised(0)); // Start with the revised step creator
|
|
131
|
+
} catch (error) {
|
|
132
|
+
done(currentData, error);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
pipe(processor) {
|
|
136
|
+
this._list.push(processor);
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
pipeEach(items, fn, map) {
|
|
140
|
+
for(let i = 0, length = items.length; i < length; i++){
|
|
141
|
+
this.pipe((previous, done)=>{
|
|
142
|
+
fn(map(previous, _results__rspack_import_1/* .Result.success */.Q.success(items[i])), done);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Processes functions with callbacks asynchronously.
|
|
149
|
+
*
|
|
150
|
+
* This pipeline handles work items that contain callback functions,
|
|
151
|
+
* executing them in an asynchronous manner while maintaining proper
|
|
152
|
+
* flow control and error handling.
|
|
153
|
+
*/ class WorkPipeline {
|
|
154
|
+
unitsOfWork = [];
|
|
155
|
+
_hasErrored = false;
|
|
156
|
+
filter(done) {
|
|
157
|
+
this._hasErrored = false; // Reset error flag on new execution
|
|
158
|
+
if (this.unitsOfWork.length === 0) {
|
|
159
|
+
done(_results__rspack_import_1/* .Result.success */.Q.success());
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
let index = 0;
|
|
163
|
+
let isRunning = false; // Guard against overlapping trampoline calls
|
|
164
|
+
try {
|
|
165
|
+
// --- Revised Completion Logic --- (Moved up for clarity)
|
|
166
|
+
const finalStepSentinel = ()=>{
|
|
167
|
+
// Only call done if no error has occurred
|
|
168
|
+
if (!this._hasErrored) {
|
|
169
|
+
done(_results__rspack_import_1/* .Result.success */.Q.success());
|
|
170
|
+
}
|
|
171
|
+
return null; // Stop the trampoline
|
|
172
|
+
};
|
|
173
|
+
const createStepRevised = (idx)=>{
|
|
174
|
+
return ()=>{
|
|
175
|
+
if (this._hasErrored) return null; // Stop if an error occurred elsewhere
|
|
176
|
+
if (idx >= this.unitsOfWork.length) {
|
|
177
|
+
return finalStepSentinel(); // Execute the dedicated final step
|
|
178
|
+
}
|
|
179
|
+
const processor = this.unitsOfWork[idx];
|
|
180
|
+
// Initialize syncCallbackResult to null to satisfy StepResult type
|
|
181
|
+
let syncCallbackResult = null;
|
|
182
|
+
let calledSync = false;
|
|
183
|
+
try {
|
|
184
|
+
processor((result)=>{
|
|
185
|
+
// --- Error Handling ---
|
|
186
|
+
if (result.ok === _results__rspack_import_1/* .Result.ERROR */.Q.ERROR) {
|
|
187
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
|
|
188
|
+
this._hasErrored = true; // Set flag
|
|
189
|
+
// Throw the error to be caught by outer try...catch blocks
|
|
190
|
+
throw result.error;
|
|
191
|
+
}
|
|
192
|
+
// --- /Error Handling ---
|
|
193
|
+
// If no error, proceed as before
|
|
194
|
+
index = idx + 1; // Update index for the next step
|
|
195
|
+
const nextStep = createStepRevised(index); // Use updated index
|
|
196
|
+
if (isRunning) {
|
|
197
|
+
// Callback was synchronous
|
|
198
|
+
syncCallbackResult = nextStep; // Store next step function
|
|
199
|
+
calledSync = true;
|
|
200
|
+
} else {
|
|
201
|
+
// Callback was asynchronous, restart trampoline
|
|
202
|
+
trampoline(nextStep);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (!this._hasErrored) {
|
|
207
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
208
|
+
this._hasErrored = true;
|
|
209
|
+
}
|
|
210
|
+
// Rethrow to be caught by the trampoline's catch block
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
if (calledSync) {
|
|
214
|
+
// Return the next step function for the sync loop
|
|
215
|
+
return syncCallbackResult;
|
|
216
|
+
} else {
|
|
217
|
+
// Pause trampoline for async, loop will stop as step returns null
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
// The trampoline loop
|
|
223
|
+
const trampoline = (step)=>{
|
|
224
|
+
if (isRunning) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
isRunning = true;
|
|
228
|
+
let currentStep = step;
|
|
229
|
+
while(currentStep !== null){
|
|
230
|
+
try {
|
|
231
|
+
// Stop immediately if an error was flagged elsewhere
|
|
232
|
+
if (this._hasErrored) {
|
|
233
|
+
currentStep = null;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
currentStep = currentStep(); // Execute step, get next step or null
|
|
237
|
+
} catch (trampolineError) {
|
|
238
|
+
// Catch errors propagated from step execution (processor or callback errors)
|
|
239
|
+
if (!this._hasErrored) {
|
|
240
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error("Error during trampoline step execution:", trampolineError);
|
|
241
|
+
this._hasErrored = true;
|
|
242
|
+
}
|
|
243
|
+
currentStep = null; // Stop the loop
|
|
244
|
+
// Report the failure to the caller. See the note on the same path in
|
|
245
|
+
// TrampolinePipeline: swallowing the error here left every caller
|
|
246
|
+
// awaiting `done` hanging instead of receiving a failure.
|
|
247
|
+
isRunning = false;
|
|
248
|
+
done(_results__rspack_import_1/* .Result.error */.Q.error(trampolineError));
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Loop ends when currentStep is null or loop is broken by error
|
|
253
|
+
isRunning = false;
|
|
254
|
+
// Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.
|
|
255
|
+
};
|
|
256
|
+
// --- Start the process ---
|
|
257
|
+
index = 0; // Reset index
|
|
258
|
+
trampoline(createStepRevised(0)); // Start with the revised step creator
|
|
259
|
+
} catch (error) {
|
|
260
|
+
done(_results__rspack_import_1/* .Result.error */.Q.error(error));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
pipe(work) {
|
|
264
|
+
this.unitsOfWork.push(work);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
},
|
|
270
|
+
718(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
271
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
272
|
+
Q: () => (Result)
|
|
273
|
+
});
|
|
274
|
+
class BaseResult {
|
|
275
|
+
static ERROR = "error";
|
|
276
|
+
static SUCCESS = "success";
|
|
277
|
+
static PARTIAL = "partial";
|
|
278
|
+
static resolve(result, resolve, reject) {
|
|
279
|
+
if (result.ok === BaseResult.SUCCESS) {
|
|
280
|
+
resolve(result.data);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (result.ok === BaseResult.PARTIAL) {
|
|
284
|
+
reject({
|
|
285
|
+
partial: result.data,
|
|
286
|
+
error: result.error
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
reject(result.error);
|
|
291
|
+
}
|
|
292
|
+
static assertSuccess(result) {
|
|
293
|
+
if (result.ok !== BaseResult.SUCCESS) {
|
|
294
|
+
throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
class Result extends BaseResult {
|
|
299
|
+
static success(data) {
|
|
300
|
+
return {
|
|
301
|
+
ok: Result.SUCCESS,
|
|
302
|
+
data
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
static error(error) {
|
|
306
|
+
return {
|
|
307
|
+
ok: Result.ERROR,
|
|
308
|
+
error
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
static partial(data, error) {
|
|
312
|
+
return {
|
|
313
|
+
ok: Result.PARTIAL,
|
|
314
|
+
data,
|
|
315
|
+
error
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
class PluginEventResult extends (/* unused pure expression or super */ null && (BaseResult)) {
|
|
320
|
+
static success(id, data) {
|
|
321
|
+
return {
|
|
322
|
+
id,
|
|
323
|
+
ok: Result.SUCCESS,
|
|
324
|
+
data
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
static error(id, error) {
|
|
328
|
+
return {
|
|
329
|
+
id,
|
|
330
|
+
ok: Result.ERROR,
|
|
331
|
+
error
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
static partial(id, data, error) {
|
|
335
|
+
return {
|
|
336
|
+
id,
|
|
337
|
+
ok: Result.PARTIAL,
|
|
338
|
+
data,
|
|
339
|
+
error
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
static assertSuccess(result) {
|
|
343
|
+
if (result.ok !== Result.SUCCESS) {
|
|
344
|
+
throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
},
|
|
351
|
+
581(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
352
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
353
|
+
vF: () => (logger)
|
|
354
|
+
});
|
|
355
|
+
/**
|
|
356
|
+
* Levelled logging, resolved once.
|
|
357
|
+
*
|
|
358
|
+
* Three things about the previous implementation drove this shape:
|
|
359
|
+
*
|
|
360
|
+
* - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever
|
|
361
|
+
* compared against `true`, so setting it to `false` did nothing — while
|
|
362
|
+
* `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.
|
|
363
|
+
* A documented switch that silently does nothing is worse than no switch.
|
|
364
|
+
* - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always
|
|
365
|
+
* sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through
|
|
366
|
+
* a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also
|
|
367
|
+
* capture console output by snapshotting a stack trace per call, so the cost is far above what
|
|
368
|
+
* writing to a terminal would suggest — and the output buries whatever the failure was.
|
|
369
|
+
* - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug
|
|
370
|
+
* was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.
|
|
371
|
+
*
|
|
372
|
+
* Levels are compared numerically against a value cached at module load. Measured against a
|
|
373
|
+
* no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.
|
|
374
|
+
* Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why
|
|
375
|
+
* this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —
|
|
376
|
+
* a lazy API would recover 0.3% of an enabled call's cost and would have to change every call
|
|
377
|
+
* site to do it.
|
|
378
|
+
*/ /** Ordered from most severe to most verbose. `silent` discards everything. */ const LOG_LEVELS = [
|
|
379
|
+
'silent',
|
|
380
|
+
'error',
|
|
381
|
+
'warn',
|
|
382
|
+
'info',
|
|
383
|
+
'debug'
|
|
384
|
+
];
|
|
385
|
+
/** Numeric rank, so a gate is one integer comparison. */ const RANK = {
|
|
386
|
+
silent: 0,
|
|
387
|
+
error: 1,
|
|
388
|
+
warn: 2,
|
|
389
|
+
info: 3,
|
|
390
|
+
debug: 4
|
|
391
|
+
};
|
|
392
|
+
const isLogLevel = (value)=>typeof value === 'string' && LOG_LEVELS.includes(value);
|
|
393
|
+
/**
|
|
394
|
+
* Resolves the configured level, in precedence order.
|
|
395
|
+
*
|
|
396
|
+
* Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an
|
|
397
|
+
* environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything
|
|
398
|
+
* unrecognised is ignored rather than treated as an error — a typo'd level should not take down
|
|
399
|
+
* an application, and `silent` is the safe direction to fall back to.
|
|
400
|
+
*/ const resolveLevel = ()=>{
|
|
401
|
+
if (typeof globalThis !== 'undefined') {
|
|
402
|
+
const g = globalThis;
|
|
403
|
+
if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {
|
|
404
|
+
return g.__ROUTIER_LOG_LEVEL__;
|
|
405
|
+
}
|
|
406
|
+
// Both directions honoured. `=== false` used to fall through to the NODE_ENV checks
|
|
407
|
+
// below and re-enable the logging it was asked to suppress.
|
|
408
|
+
if (g.__ROUTIER_DEBUG__ === true) return 'debug';
|
|
409
|
+
if (g.__ROUTIER_DEBUG__ === false) return 'silent';
|
|
410
|
+
}
|
|
411
|
+
// There is deliberately no `import.meta.env` branch, although the documentation used to
|
|
412
|
+
// promise one. It could never work: this package is bundled with rspack, which replaces
|
|
413
|
+
// `import.meta` with `undefined`, so the check would read the *library's* build-time
|
|
414
|
+
// environment rather than the application's — and referencing `import.meta` at all is a parse
|
|
415
|
+
// error under a CommonJS build target, which is how the test suite loads this file. Vite and
|
|
416
|
+
// similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own
|
|
417
|
+
// `import.meta.env`, which is what the docs now describe.
|
|
418
|
+
if (typeof process !== 'undefined' && process.env != null) {
|
|
419
|
+
if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {
|
|
420
|
+
return process.env.ROUTIER_LOG_LEVEL;
|
|
421
|
+
}
|
|
422
|
+
const debug = process.env.DEBUG;
|
|
423
|
+
if (debug === 'routier' || debug === '*') return 'debug';
|
|
424
|
+
const env = "production"?.toLowerCase();
|
|
425
|
+
// `test` is deliberately absent. It used to be here, which meant no test suite anywhere
|
|
426
|
+
// could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test
|
|
427
|
+
// needs the output.
|
|
428
|
+
if (env === 'dev' || env === 'development') return 'debug';
|
|
429
|
+
}
|
|
430
|
+
return 'silent';
|
|
431
|
+
};
|
|
432
|
+
let level = resolveLevel();
|
|
433
|
+
let rank = RANK[level];
|
|
434
|
+
/**
|
|
435
|
+
* Overrides the level for the rest of the process.
|
|
436
|
+
*
|
|
437
|
+
* The configuration above is read once, at import, which is what makes the gate cheap — but it
|
|
438
|
+
* also means an application that decides its verbosity after startup, or a test that wants to
|
|
439
|
+
* assert on output, has no way in. This is that way in.
|
|
440
|
+
*/ const setLogLevel = (next)=>{
|
|
441
|
+
if (isLogLevel(next) === false) {
|
|
442
|
+
throw new Error(`Unknown log level "${next}". Expected one of: ${LOG_LEVELS.join(', ')}`);
|
|
443
|
+
}
|
|
444
|
+
level = next;
|
|
445
|
+
rank = RANK[next];
|
|
446
|
+
};
|
|
447
|
+
const getLogLevel = ()=>level;
|
|
448
|
+
/** Re-reads the environment. For tests that change it after this module was imported. */ const resetLogLevel = ()=>{
|
|
449
|
+
level = resolveLevel();
|
|
450
|
+
rank = RANK[level];
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Whether a message at this level would be emitted.
|
|
454
|
+
*
|
|
455
|
+
* For the rare call site whose *arguments* are expensive to build — a serialization, a deep
|
|
456
|
+
* clone, a join over a large collection. An ordinary payload object is not worth guarding; see
|
|
457
|
+
* the measurement in the header.
|
|
458
|
+
*/ const isLogLevelEnabled = (at)=>rank >= RANK[at];
|
|
459
|
+
const emit = (at, method, args)=>{
|
|
460
|
+
if (rank < RANK[at]) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
// Resolved at call time rather than captured once: test harnesses and browser devtools both
|
|
464
|
+
// replace console methods after modules have loaded, and a captured reference would keep
|
|
465
|
+
// writing past the replacement.
|
|
466
|
+
console[method](...args);
|
|
467
|
+
};
|
|
468
|
+
const logger = {
|
|
469
|
+
/** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */ log: (...args)=>emit('info', 'log', args),
|
|
470
|
+
info: (...args)=>emit('info', 'info', args),
|
|
471
|
+
warn: (...args)=>emit('warn', 'warn', args),
|
|
472
|
+
error: (...args)=>emit('error', 'error', args),
|
|
473
|
+
debug: (...args)=>emit('debug', 'debug', args),
|
|
474
|
+
/** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */ table: (...args)=>emit('debug', 'table', args)
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
},
|
|
479
|
+
|
|
480
|
+
});
|
|
481
|
+
// The module cache
|
|
482
|
+
var __webpack_module_cache__ = {};
|
|
483
|
+
|
|
484
|
+
// The require function
|
|
485
|
+
function __webpack_require__(moduleId) {
|
|
486
|
+
|
|
487
|
+
// Check if module is in cache
|
|
488
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
489
|
+
if (cachedModule !== undefined) {
|
|
490
|
+
return cachedModule.exports;
|
|
491
|
+
}
|
|
492
|
+
// Create a new module (and put it into the cache)
|
|
493
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
494
|
+
exports: {}
|
|
495
|
+
});
|
|
496
|
+
// Execute the module function
|
|
497
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
498
|
+
|
|
499
|
+
// Return the exports of the module
|
|
500
|
+
return module.exports;
|
|
501
|
+
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// webpack/runtime/define_property_getters
|
|
505
|
+
(() => {
|
|
506
|
+
__webpack_require__.d = (exports, definition) => {
|
|
507
|
+
for(var key in definition) {
|
|
508
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
509
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
})();
|
|
514
|
+
// webpack/runtime/has_own_property
|
|
515
|
+
(() => {
|
|
516
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
517
|
+
})();
|
|
518
|
+
// webpack/runtime/make_namespace_object
|
|
519
|
+
(() => {
|
|
520
|
+
// define __esModule on exports
|
|
521
|
+
__webpack_require__.r = (exports) => {
|
|
522
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
523
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
524
|
+
}
|
|
525
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
526
|
+
};
|
|
527
|
+
})();
|
|
528
|
+
var __webpack_exports__ = {};
|
|
529
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
530
|
+
(() => {
|
|
531
|
+
// ESM COMPAT FLAG
|
|
532
|
+
__webpack_require__.r(__webpack_exports__);
|
|
533
|
+
|
|
534
|
+
// EXPORTS
|
|
535
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
536
|
+
TrampolinePipeline: () => (/* reexport */ TrampolinePipeline/* .TrampolinePipeline */.k),
|
|
537
|
+
WorkPipeline: () => (/* reexport */ TrampolinePipeline/* .WorkPipeline */.U),
|
|
538
|
+
SyncronousQueue: () => (/* reexport */ SyncronousQueue)
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
;// CONCATENATED MODULE: ./src/pipeline/SyncronousQueue.ts
|
|
542
|
+
class SyncronousQueue {
|
|
543
|
+
_queue = [];
|
|
544
|
+
_current = null;
|
|
545
|
+
enqueue(unitOfWork) {
|
|
546
|
+
this._queue.push(unitOfWork);
|
|
547
|
+
this._next();
|
|
548
|
+
}
|
|
549
|
+
_next() {
|
|
550
|
+
if (this._current != null || this._queue.length === 0) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
// Take first item
|
|
554
|
+
this._current = this._queue.shift() ?? null;
|
|
555
|
+
if (this._current == null) {
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
this._current(()=>{
|
|
559
|
+
this._current = null;
|
|
560
|
+
this._next();
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// EXTERNAL MODULE: ./src/pipeline/TrampolinePipeline.ts
|
|
566
|
+
var TrampolinePipeline = __webpack_require__(416);
|
|
567
|
+
;// CONCATENATED MODULE: ./src/pipeline/index.ts
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
})();
|
|
572
|
+
|
|
573
|
+
module.exports = __webpack_exports__;
|
|
574
|
+
})()
|
|
575
|
+
;
|
|
576
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline/index.cjs","sources":["webpack://@routier/core/./src/pipeline/TrampolinePipeline.ts","webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/pipeline/SyncronousQueue.ts","webpack://@routier/core/./src/pipeline/index.ts"],"sourcesContent":["import { logger } from \"../utilities\";\nimport { CallbackResult, Result, ResultType } from \"../results\";\n\n/**\n * Type definition for an asynchronous function that takes data and a callback.\n * TIn: The input data type.\n * TOut: The output data type (passed to the callback).\n */\nexport type Processor<TIn, TOut> = (data: TIn, callback: (result: TOut, error?: any) => void) => void;\n\n// Return type for a step execution: Either the next step function or null if waiting/done.\ntype StepResult<TData> = TrampolineStep<TData> | null;\ntype TrampolineStep<TData> = () => StepResult<TData>;\n\nexport class TrampolinePipeline<TInitial, TCurrent = TInitial> {\n private _list: Processor<any, any>[] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter<TFinal>(initialData: TInitial, done: (data: TFinal, error?: any) => void) {\n\n this._hasErrored = false; // Reset error flag on new execution\n\n if (this._list.length === 0) {\n done(initialData as unknown as TFinal);\n return;\n }\n\n let index = 0;\n let currentData: any = initialData;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<any> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n done(currentData as TFinal);\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this._list.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const processor = this._list[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor(currentData, (result, error) => {\n // --- Error Handling ---\n if (error) {\n logger.error(`Error reported by processor at index ${idx}:`, error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n currentData = result;\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (currentStep !== null) {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n logger.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n\n // Report the failure to the caller.\n //\n // This used to break without calling `done`, on the reasoning that\n // the application should handle the uncaught exception. It cannot:\n // the error is caught right here, so nothing escapes to be handled,\n // and every caller awaiting the callback waits forever. A hang is\n // strictly worse than an error — it gives the caller nothing to act\n // on and no way to time out.\n //\n // `done` runs exactly once per execution: this path returns\n // immediately, and finalStepSentinel checks `_hasErrored` before\n // reporting success, so the two are mutually exclusive.\n isRunning = false;\n done(currentData as TFinal, trampolineError);\n return;\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n currentData = initialData; // Reset data\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(currentData, error);\n }\n }\n\n pipe<TNext>(processor: Processor<TCurrent, TNext>) {\n this._list.push(processor);\n return this as unknown as TrampolinePipeline<TInitial, TNext>;\n }\n\n pipeEach(items: TCurrent[], fn: (payload: ResultType<TCurrent>, done: CallbackResult<TCurrent>) => void, map: (previous: ResultType<TCurrent>, current: ResultType<TCurrent>) => ResultType<TCurrent>) {\n for (let i = 0, length = items.length; i < length; i++) {\n\n this.pipe<ResultType<TCurrent>>((previous, done) => {\n\n fn(map(previous as ResultType<TCurrent>, Result.success(items[i])), done);\n });\n }\n }\n}\n\nexport type UnitOfWork = (done: CallbackResult<never>) => void;\n\n/**\n * Processes functions with callbacks asynchronously.\n * \n * This pipeline handles work items that contain callback functions,\n * executing them in an asynchronous manner while maintaining proper\n * flow control and error handling.\n */\nexport class WorkPipeline {\n private unitsOfWork: UnitOfWork[] = [];\n private _hasErrored: boolean = false; // Flag to prevent calling done on error\n\n filter(done: CallbackResult<never>) {\n\n this._hasErrored = false; // Reset error flag on new execution\n\n if (this.unitsOfWork.length === 0) {\n done(Result.success());\n return;\n }\n\n let index = 0;\n let isRunning = false; // Guard against overlapping trampoline calls\n\n try {\n // --- Revised Completion Logic --- (Moved up for clarity)\n const finalStepSentinel = (): StepResult<never> => { // A special step function for the very end\n // Only call done if no error has occurred\n if (!this._hasErrored) {\n done(Result.success());\n }\n return null; // Stop the trampoline\n };\n\n const createStepRevised = (idx: number): TrampolineStep<any> => {\n return () => {\n if (this._hasErrored) return null; // Stop if an error occurred elsewhere\n\n if (idx >= this.unitsOfWork.length) {\n return finalStepSentinel(); // Execute the dedicated final step\n }\n\n const processor = this.unitsOfWork[idx];\n // Initialize syncCallbackResult to null to satisfy StepResult type\n let syncCallbackResult: StepResult<any> = null;\n let calledSync = false;\n\n try {\n processor((result) => {\n // --- Error Handling ---\n if (result.ok === Result.ERROR) {\n logger.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);\n this._hasErrored = true; // Set flag\n // Throw the error to be caught by outer try...catch blocks\n throw result.error;\n }\n // --- /Error Handling ---\n\n // If no error, proceed as before\n index = idx + 1; // Update index for the next step\n const nextStep = createStepRevised(index); // Use updated index\n\n if (isRunning) {\n // Callback was synchronous\n syncCallbackResult = nextStep; // Store next step function\n calledSync = true;\n } else {\n // Callback was asynchronous, restart trampoline\n trampoline(nextStep);\n }\n });\n } catch (error) {\n if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback\n logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);\n this._hasErrored = true;\n }\n // Rethrow to be caught by the trampoline's catch block\n throw error;\n }\n\n if (calledSync) {\n // Return the next step function for the sync loop\n return syncCallbackResult;\n } else {\n // Pause trampoline for async, loop will stop as step returns null\n return null;\n }\n };\n };\n\n // The trampoline loop\n const trampoline = (step: TrampolineStep<any> | null) => {\n\n if (isRunning) {\n return;\n }\n\n isRunning = true;\n let currentStep = step;\n\n while (currentStep !== null) {\n try {\n // Stop immediately if an error was flagged elsewhere\n if (this._hasErrored) {\n currentStep = null;\n break;\n }\n currentStep = currentStep(); // Execute step, get next step or null\n } catch (trampolineError) {\n // Catch errors propagated from step execution (processor or callback errors)\n if (!this._hasErrored) { // Avoid double logging\n logger.error(\"Error during trampoline step execution:\", trampolineError);\n this._hasErrored = true;\n }\n currentStep = null; // Stop the loop\n\n // Report the failure to the caller. See the note on the same path in\n // TrampolinePipeline: swallowing the error here left every caller\n // awaiting `done` hanging instead of receiving a failure.\n isRunning = false;\n done(Result.error(trampolineError));\n return;\n }\n }\n // Loop ends when currentStep is null or loop is broken by error\n isRunning = false;\n\n // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.\n };\n\n // --- Start the process ---\n index = 0; // Reset index\n trampoline(createStepRevised(0)); // Start with the revised step creator\n } catch (error: any) {\n done(Result.error(error));\n }\n }\n\n pipe(work: UnitOfWork) {\n this.unitsOfWork.push(work);\n }\n}","import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n // `test` is deliberately absent. It used to be here, which meant no test suite anywhere\n // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test\n // needs the output.\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n return 'silent';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export type SyncronousUnitOfWork = (done: () => void) => void\n\nexport class SyncronousQueue {\n\n private readonly _queue: SyncronousUnitOfWork[] = [];\n private _current: SyncronousUnitOfWork | null = null;\n\n enqueue(unitOfWork: SyncronousUnitOfWork) {\n this._queue.push(unitOfWork);\n this._next();\n }\n\n private _next() {\n if (this._current != null || this._queue.length === 0) {\n return;\n }\n\n // Take first item\n this._current = this._queue.shift() ?? null;\n\n if (this._current == null) {\n return;\n }\n\n this._current(() => {\n this._current = null;\n this._next();\n })\n }\n}","export * from './SyncronousQueue';\nexport * from './TrampolinePipeline';"],"names":["logger","Result","TrampolinePipeline","initialData","done","index","currentData","isRunning","finalStepSentinel","createStepRevised","idx","processor","syncCallbackResult","calledSync","result","error","nextStep","trampoline","step","currentStep","trampolineError","items","fn","map","i","length","previous","WorkPipeline","work","BaseResult","resolve","reject","Error","data","PluginEventResult","id","LOG_LEVELS","RANK","isLogLevel","value","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","next","getLogLevel","resetLogLevel","isLogLevelEnabled","at","emit","method","args","console","SyncronousQueue","unitOfWork"],"mappings":";;;;;;;;;;AAAsC;AAC0B;AAazD,MAAME;IACD,QAA+B,EAAE,CAAC;IAClC,cAAuB,MAAM;IAErC,OAAeC,WAAqB,EAAEC,IAAyC,EAAE;QAE7E,IAAI,CAAC,WAAW,GAAG,OAAO,oCAAoC;QAE9D,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,GAAG;YACzBA,KAAKD;YACL;QACJ;QAEA,IAAIE,QAAQ;QACZ,IAAIC,cAAmBH;QACvB,IAAII,YAAY,OAAO,6CAA6C;QAEpE,IAAI;YACA,0DAA0D;YAC1D,MAAMC,oBAAoB;gBACtB,0CAA0C;gBAC1C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;oBACnBJ,KAAKE;gBACT;gBACA,OAAO,MAAM,sBAAsB;YACvC;YAEA,MAAMG,oBAAoB,CAAC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