@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
package/dist/pipeline/index.js
CHANGED
|
@@ -1,47 +1,16 @@
|
|
|
1
1
|
var __webpack_modules__ = ({
|
|
2
|
-
|
|
3
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2
|
+
416(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
3
|
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
-
|
|
4
|
+
U: () => (WorkPipeline),
|
|
5
|
+
k: () => (TrampolinePipeline)
|
|
6
6
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
_current = null;
|
|
10
|
-
enqueue(unitOfWork) {
|
|
11
|
-
this._queue.push(unitOfWork);
|
|
12
|
-
this._next();
|
|
13
|
-
}
|
|
14
|
-
_next() {
|
|
15
|
-
if (this._current != null || this._queue.length === 0) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
// Take first item
|
|
19
|
-
this._current = this._queue.shift() ?? null;
|
|
20
|
-
if (this._current == null) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this._current(() => {
|
|
24
|
-
this._current = null;
|
|
25
|
-
this._next();
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
"./src/pipeline/TrampolinePipeline.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
33
|
-
__webpack_require__.r(__webpack_exports__);
|
|
34
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
35
|
-
TrampolinePipeline: () => (TrampolinePipeline),
|
|
36
|
-
WorkPipeline: () => (WorkPipeline)
|
|
37
|
-
});
|
|
38
|
-
/* import */ var _utilities__rspack_import_0 = __webpack_require__("./src/utilities/logger.ts");
|
|
39
|
-
/* import */ var _results__rspack_import_1 = __webpack_require__("./src/results/Result.ts");
|
|
7
|
+
/* import */ var _utilities__rspack_import_0 = __webpack_require__(581);
|
|
8
|
+
/* import */ var _results__rspack_import_1 = __webpack_require__(718);
|
|
40
9
|
|
|
41
10
|
|
|
42
11
|
class TrampolinePipeline {
|
|
43
12
|
_list = [];
|
|
44
|
-
_hasErrored = false;
|
|
13
|
+
_hasErrored = false;
|
|
45
14
|
filter(initialData, done) {
|
|
46
15
|
this._hasErrored = false; // Reset error flag on new execution
|
|
47
16
|
if (this._list.length === 0) {
|
|
@@ -53,17 +22,16 @@ class TrampolinePipeline {
|
|
|
53
22
|
let isRunning = false; // Guard against overlapping trampoline calls
|
|
54
23
|
try {
|
|
55
24
|
// --- Revised Completion Logic --- (Moved up for clarity)
|
|
56
|
-
const finalStepSentinel = ()
|
|
25
|
+
const finalStepSentinel = ()=>{
|
|
57
26
|
// Only call done if no error has occurred
|
|
58
27
|
if (!this._hasErrored) {
|
|
59
28
|
done(currentData);
|
|
60
29
|
}
|
|
61
30
|
return null; // Stop the trampoline
|
|
62
31
|
};
|
|
63
|
-
const createStepRevised = (idx)
|
|
64
|
-
return ()
|
|
65
|
-
if (this._hasErrored)
|
|
66
|
-
return null; // Stop if an error occurred elsewhere
|
|
32
|
+
const createStepRevised = (idx)=>{
|
|
33
|
+
return ()=>{
|
|
34
|
+
if (this._hasErrored) return null; // Stop if an error occurred elsewhere
|
|
67
35
|
if (idx >= this._list.length) {
|
|
68
36
|
return finalStepSentinel(); // Execute the dedicated final step
|
|
69
37
|
}
|
|
@@ -72,10 +40,10 @@ class TrampolinePipeline {
|
|
|
72
40
|
let syncCallbackResult = null;
|
|
73
41
|
let calledSync = false;
|
|
74
42
|
try {
|
|
75
|
-
processor(currentData, (result, error)
|
|
43
|
+
processor(currentData, (result, error)=>{
|
|
76
44
|
// --- Error Handling ---
|
|
77
45
|
if (error) {
|
|
78
|
-
_utilities__rspack_import_0.logger.error(`Error reported by processor at index ${idx}:`, error);
|
|
46
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error reported by processor at index ${idx}:`, error);
|
|
79
47
|
this._hasErrored = true; // Set flag
|
|
80
48
|
// Throw the error to be caught by outer try...catch blocks
|
|
81
49
|
throw error;
|
|
@@ -89,16 +57,14 @@ class TrampolinePipeline {
|
|
|
89
57
|
// Callback was synchronous
|
|
90
58
|
syncCallbackResult = nextStep; // Store next step function
|
|
91
59
|
calledSync = true;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
60
|
+
} else {
|
|
94
61
|
// Callback was asynchronous, restart trampoline
|
|
95
62
|
trampoline(nextStep);
|
|
96
63
|
}
|
|
97
64
|
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
_utilities__rspack_import_0.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (!this._hasErrored) {
|
|
67
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
102
68
|
this._hasErrored = true;
|
|
103
69
|
}
|
|
104
70
|
// Rethrow to be caught by the trampoline's catch block
|
|
@@ -107,21 +73,20 @@ class TrampolinePipeline {
|
|
|
107
73
|
if (calledSync) {
|
|
108
74
|
// Return the next step function for the sync loop
|
|
109
75
|
return syncCallbackResult;
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
76
|
+
} else {
|
|
112
77
|
// Pause trampoline for async, loop will stop as step returns null
|
|
113
78
|
return null;
|
|
114
79
|
}
|
|
115
80
|
};
|
|
116
81
|
};
|
|
117
82
|
// The trampoline loop
|
|
118
|
-
const trampoline = (step)
|
|
83
|
+
const trampoline = (step)=>{
|
|
119
84
|
if (isRunning) {
|
|
120
85
|
return;
|
|
121
86
|
}
|
|
122
87
|
isRunning = true;
|
|
123
88
|
let currentStep = step;
|
|
124
|
-
while
|
|
89
|
+
while(currentStep !== null){
|
|
125
90
|
try {
|
|
126
91
|
// Stop immediately if an error was flagged elsewhere
|
|
127
92
|
if (this._hasErrored) {
|
|
@@ -129,29 +94,39 @@ class TrampolinePipeline {
|
|
|
129
94
|
break;
|
|
130
95
|
}
|
|
131
96
|
currentStep = currentStep(); // Execute step, get next step or null
|
|
132
|
-
}
|
|
133
|
-
catch (trampolineError) {
|
|
97
|
+
} catch (trampolineError) {
|
|
134
98
|
// Catch errors propagated from step execution (processor or callback errors)
|
|
135
|
-
if (!this._hasErrored) {
|
|
136
|
-
_utilities__rspack_import_0.logger.error("Error during trampoline step execution:", trampolineError);
|
|
99
|
+
if (!this._hasErrored) {
|
|
100
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error("Error during trampoline step execution:", trampolineError);
|
|
137
101
|
this._hasErrored = true;
|
|
138
102
|
}
|
|
139
103
|
currentStep = null; // Stop the loop
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
|
|
104
|
+
// Report the failure to the caller.
|
|
105
|
+
//
|
|
106
|
+
// This used to break without calling `done`, on the reasoning that
|
|
107
|
+
// the application should handle the uncaught exception. It cannot:
|
|
108
|
+
// the error is caught right here, so nothing escapes to be handled,
|
|
109
|
+
// and every caller awaiting the callback waits forever. A hang is
|
|
110
|
+
// strictly worse than an error — it gives the caller nothing to act
|
|
111
|
+
// on and no way to time out.
|
|
112
|
+
//
|
|
113
|
+
// `done` runs exactly once per execution: this path returns
|
|
114
|
+
// immediately, and finalStepSentinel checks `_hasErrored` before
|
|
115
|
+
// reporting success, so the two are mutually exclusive.
|
|
116
|
+
isRunning = false;
|
|
117
|
+
done(currentData, trampolineError);
|
|
118
|
+
return;
|
|
143
119
|
}
|
|
144
120
|
}
|
|
145
121
|
// Loop ends when currentStep is null or loop is broken by error
|
|
146
122
|
isRunning = false;
|
|
147
|
-
|
|
123
|
+
// Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.
|
|
148
124
|
};
|
|
149
125
|
// --- Start the process ---
|
|
150
126
|
index = 0; // Reset index
|
|
151
127
|
currentData = initialData; // Reset data
|
|
152
128
|
trampoline(createStepRevised(0)); // Start with the revised step creator
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
129
|
+
} catch (error) {
|
|
155
130
|
done(currentData, error);
|
|
156
131
|
}
|
|
157
132
|
}
|
|
@@ -160,44 +135,42 @@ class TrampolinePipeline {
|
|
|
160
135
|
return this;
|
|
161
136
|
}
|
|
162
137
|
pipeEach(items, fn, map) {
|
|
163
|
-
for
|
|
164
|
-
this.pipe((previous, done)
|
|
165
|
-
fn(map(previous, _results__rspack_import_1.Result.success(items[i])), done);
|
|
138
|
+
for(let i = 0, length = items.length; i < length; i++){
|
|
139
|
+
this.pipe((previous, done)=>{
|
|
140
|
+
fn(map(previous, _results__rspack_import_1/* .Result.success */.Q.success(items[i])), done);
|
|
166
141
|
});
|
|
167
142
|
}
|
|
168
143
|
}
|
|
169
144
|
}
|
|
170
145
|
/**
|
|
171
146
|
* Processes functions with callbacks asynchronously.
|
|
172
|
-
*
|
|
147
|
+
*
|
|
173
148
|
* This pipeline handles work items that contain callback functions,
|
|
174
149
|
* executing them in an asynchronous manner while maintaining proper
|
|
175
150
|
* flow control and error handling.
|
|
176
|
-
*/
|
|
177
|
-
class WorkPipeline {
|
|
151
|
+
*/ class WorkPipeline {
|
|
178
152
|
unitsOfWork = [];
|
|
179
|
-
_hasErrored = false;
|
|
153
|
+
_hasErrored = false;
|
|
180
154
|
filter(done) {
|
|
181
155
|
this._hasErrored = false; // Reset error flag on new execution
|
|
182
156
|
if (this.unitsOfWork.length === 0) {
|
|
183
|
-
done(_results__rspack_import_1.Result.success());
|
|
157
|
+
done(_results__rspack_import_1/* .Result.success */.Q.success());
|
|
184
158
|
return;
|
|
185
159
|
}
|
|
186
160
|
let index = 0;
|
|
187
161
|
let isRunning = false; // Guard against overlapping trampoline calls
|
|
188
162
|
try {
|
|
189
163
|
// --- Revised Completion Logic --- (Moved up for clarity)
|
|
190
|
-
const finalStepSentinel = ()
|
|
164
|
+
const finalStepSentinel = ()=>{
|
|
191
165
|
// Only call done if no error has occurred
|
|
192
166
|
if (!this._hasErrored) {
|
|
193
|
-
done(_results__rspack_import_1.Result.success());
|
|
167
|
+
done(_results__rspack_import_1/* .Result.success */.Q.success());
|
|
194
168
|
}
|
|
195
169
|
return null; // Stop the trampoline
|
|
196
170
|
};
|
|
197
|
-
const createStepRevised = (idx)
|
|
198
|
-
return ()
|
|
199
|
-
if (this._hasErrored)
|
|
200
|
-
return null; // Stop if an error occurred elsewhere
|
|
171
|
+
const createStepRevised = (idx)=>{
|
|
172
|
+
return ()=>{
|
|
173
|
+
if (this._hasErrored) return null; // Stop if an error occurred elsewhere
|
|
201
174
|
if (idx >= this.unitsOfWork.length) {
|
|
202
175
|
return finalStepSentinel(); // Execute the dedicated final step
|
|
203
176
|
}
|
|
@@ -206,10 +179,10 @@ class WorkPipeline {
|
|
|
206
179
|
let syncCallbackResult = null;
|
|
207
180
|
let calledSync = false;
|
|
208
181
|
try {
|
|
209
|
-
processor((result)
|
|
182
|
+
processor((result)=>{
|
|
210
183
|
// --- Error Handling ---
|
|
211
|
-
if (result.ok === _results__rspack_import_1.Result.ERROR) {
|
|
212
|
-
_utilities__rspack_import_0.logger.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
|
|
184
|
+
if (result.ok === _results__rspack_import_1/* .Result.ERROR */.Q.ERROR) {
|
|
185
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
|
|
213
186
|
this._hasErrored = true; // Set flag
|
|
214
187
|
// Throw the error to be caught by outer try...catch blocks
|
|
215
188
|
throw result.error;
|
|
@@ -222,16 +195,14 @@ class WorkPipeline {
|
|
|
222
195
|
// Callback was synchronous
|
|
223
196
|
syncCallbackResult = nextStep; // Store next step function
|
|
224
197
|
calledSync = true;
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
198
|
+
} else {
|
|
227
199
|
// Callback was asynchronous, restart trampoline
|
|
228
200
|
trampoline(nextStep);
|
|
229
201
|
}
|
|
230
202
|
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
_utilities__rspack_import_0.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
if (!this._hasErrored) {
|
|
205
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
235
206
|
this._hasErrored = true;
|
|
236
207
|
}
|
|
237
208
|
// Rethrow to be caught by the trampoline's catch block
|
|
@@ -240,21 +211,20 @@ class WorkPipeline {
|
|
|
240
211
|
if (calledSync) {
|
|
241
212
|
// Return the next step function for the sync loop
|
|
242
213
|
return syncCallbackResult;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
214
|
+
} else {
|
|
245
215
|
// Pause trampoline for async, loop will stop as step returns null
|
|
246
216
|
return null;
|
|
247
217
|
}
|
|
248
218
|
};
|
|
249
219
|
};
|
|
250
220
|
// The trampoline loop
|
|
251
|
-
const trampoline = (step)
|
|
221
|
+
const trampoline = (step)=>{
|
|
252
222
|
if (isRunning) {
|
|
253
223
|
return;
|
|
254
224
|
}
|
|
255
225
|
isRunning = true;
|
|
256
226
|
let currentStep = step;
|
|
257
|
-
while
|
|
227
|
+
while(currentStep !== null){
|
|
258
228
|
try {
|
|
259
229
|
// Stop immediately if an error was flagged elsewhere
|
|
260
230
|
if (this._hasErrored) {
|
|
@@ -262,29 +232,30 @@ class WorkPipeline {
|
|
|
262
232
|
break;
|
|
263
233
|
}
|
|
264
234
|
currentStep = currentStep(); // Execute step, get next step or null
|
|
265
|
-
}
|
|
266
|
-
catch (trampolineError) {
|
|
235
|
+
} catch (trampolineError) {
|
|
267
236
|
// Catch errors propagated from step execution (processor or callback errors)
|
|
268
|
-
if (!this._hasErrored) {
|
|
269
|
-
_utilities__rspack_import_0.logger.error("Error during trampoline step execution:", trampolineError);
|
|
237
|
+
if (!this._hasErrored) {
|
|
238
|
+
_utilities__rspack_import_0/* .logger.error */.vF.error("Error during trampoline step execution:", trampolineError);
|
|
270
239
|
this._hasErrored = true;
|
|
271
240
|
}
|
|
272
241
|
currentStep = null; // Stop the loop
|
|
273
|
-
//
|
|
274
|
-
//
|
|
275
|
-
|
|
242
|
+
// Report the failure to the caller. See the note on the same path in
|
|
243
|
+
// TrampolinePipeline: swallowing the error here left every caller
|
|
244
|
+
// awaiting `done` hanging instead of receiving a failure.
|
|
245
|
+
isRunning = false;
|
|
246
|
+
done(_results__rspack_import_1/* .Result.error */.Q.error(trampolineError));
|
|
247
|
+
return;
|
|
276
248
|
}
|
|
277
249
|
}
|
|
278
250
|
// Loop ends when currentStep is null or loop is broken by error
|
|
279
251
|
isRunning = false;
|
|
280
|
-
|
|
252
|
+
// Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.
|
|
281
253
|
};
|
|
282
254
|
// --- Start the process ---
|
|
283
255
|
index = 0; // Reset index
|
|
284
256
|
trampoline(createStepRevised(0)); // Start with the revised step creator
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
done(_results__rspack_import_1.Result.error(error));
|
|
257
|
+
} catch (error) {
|
|
258
|
+
done(_results__rspack_import_1/* .Result.error */.Q.error(error));
|
|
288
259
|
}
|
|
289
260
|
}
|
|
290
261
|
pipe(work) {
|
|
@@ -294,11 +265,9 @@ class WorkPipeline {
|
|
|
294
265
|
|
|
295
266
|
|
|
296
267
|
},
|
|
297
|
-
|
|
298
|
-
__webpack_require__.r(__webpack_exports__);
|
|
268
|
+
718(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
299
269
|
__webpack_require__.d(__webpack_exports__, {
|
|
300
|
-
|
|
301
|
-
Result: () => (Result)
|
|
270
|
+
Q: () => (Result)
|
|
302
271
|
});
|
|
303
272
|
class BaseResult {
|
|
304
273
|
static ERROR = "error";
|
|
@@ -345,7 +314,7 @@ class Result extends BaseResult {
|
|
|
345
314
|
};
|
|
346
315
|
}
|
|
347
316
|
}
|
|
348
|
-
class PluginEventResult extends BaseResult {
|
|
317
|
+
class PluginEventResult extends (/* unused pure expression or super */ null && (BaseResult)) {
|
|
349
318
|
static success(id, data) {
|
|
350
319
|
return {
|
|
351
320
|
id,
|
|
@@ -377,54 +346,130 @@ class PluginEventResult extends BaseResult {
|
|
|
377
346
|
|
|
378
347
|
|
|
379
348
|
},
|
|
380
|
-
|
|
381
|
-
__webpack_require__.r(__webpack_exports__);
|
|
349
|
+
581(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
382
350
|
__webpack_require__.d(__webpack_exports__, {
|
|
383
|
-
|
|
351
|
+
vF: () => (logger)
|
|
384
352
|
});
|
|
385
353
|
/**
|
|
386
|
-
*
|
|
387
|
-
|
|
388
|
-
|
|
354
|
+
* Levelled logging, resolved once.
|
|
355
|
+
*
|
|
356
|
+
* Three things about the previous implementation drove this shape:
|
|
357
|
+
*
|
|
358
|
+
* - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever
|
|
359
|
+
* compared against `true`, so setting it to `false` did nothing — while
|
|
360
|
+
* `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.
|
|
361
|
+
* A documented switch that silently does nothing is worse than no switch.
|
|
362
|
+
* - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always
|
|
363
|
+
* sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through
|
|
364
|
+
* a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also
|
|
365
|
+
* capture console output by snapshotting a stack trace per call, so the cost is far above what
|
|
366
|
+
* writing to a terminal would suggest — and the output buries whatever the failure was.
|
|
367
|
+
* - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug
|
|
368
|
+
* was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.
|
|
369
|
+
*
|
|
370
|
+
* Levels are compared numerically against a value cached at module load. Measured against a
|
|
371
|
+
* no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.
|
|
372
|
+
* Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why
|
|
373
|
+
* this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —
|
|
374
|
+
* a lazy API would recover 0.3% of an enabled call's cost and would have to change every call
|
|
375
|
+
* site to do it.
|
|
376
|
+
*/ /** Ordered from most severe to most verbose. `silent` discards everything. */ const LOG_LEVELS = [
|
|
377
|
+
'silent',
|
|
378
|
+
'error',
|
|
379
|
+
'warn',
|
|
380
|
+
'info',
|
|
381
|
+
'debug'
|
|
382
|
+
];
|
|
383
|
+
/** Numeric rank, so a gate is one integer comparison. */ const RANK = {
|
|
384
|
+
silent: 0,
|
|
385
|
+
error: 1,
|
|
386
|
+
warn: 2,
|
|
387
|
+
info: 3,
|
|
388
|
+
debug: 4
|
|
389
|
+
};
|
|
390
|
+
const isLogLevel = (value)=>typeof value === 'string' && LOG_LEVELS.includes(value);
|
|
391
|
+
/**
|
|
392
|
+
* Resolves the configured level, in precedence order.
|
|
393
|
+
*
|
|
394
|
+
* Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an
|
|
395
|
+
* environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything
|
|
396
|
+
* unrecognised is ignored rather than treated as an error — a typo'd level should not take down
|
|
397
|
+
* an application, and `silent` is the safe direction to fall back to.
|
|
398
|
+
*/ const resolveLevel = ()=>{
|
|
389
399
|
if (typeof globalThis !== 'undefined') {
|
|
390
400
|
const g = globalThis;
|
|
391
|
-
if (g.
|
|
392
|
-
return
|
|
401
|
+
if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {
|
|
402
|
+
return g.__ROUTIER_LOG_LEVEL__;
|
|
403
|
+
}
|
|
404
|
+
// Both directions honoured. `=== false` used to fall through to the NODE_ENV checks
|
|
405
|
+
// below and re-enable the logging it was asked to suppress.
|
|
406
|
+
if (g.__ROUTIER_DEBUG__ === true) return 'debug';
|
|
407
|
+
if (g.__ROUTIER_DEBUG__ === false) return 'silent';
|
|
393
408
|
}
|
|
409
|
+
// There is deliberately no `import.meta.env` branch, although the documentation used to
|
|
410
|
+
// promise one. It could never work: this package is bundled with rspack, which replaces
|
|
411
|
+
// `import.meta` with `undefined`, so the check would read the *library's* build-time
|
|
412
|
+
// environment rather than the application's — and referencing `import.meta` at all is a parse
|
|
413
|
+
// error under a CommonJS build target, which is how the test suite loads this file. Vite and
|
|
414
|
+
// similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own
|
|
415
|
+
// `import.meta.env`, which is what the docs now describe.
|
|
394
416
|
if (typeof process !== 'undefined' && process.env != null) {
|
|
417
|
+
if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {
|
|
418
|
+
return process.env.ROUTIER_LOG_LEVEL;
|
|
419
|
+
}
|
|
395
420
|
const debug = process.env.DEBUG;
|
|
396
|
-
if (debug === 'routier' || debug === '*')
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
421
|
+
if (debug === 'routier' || debug === '*') return 'debug';
|
|
422
|
+
const env = "production"?.toLowerCase();
|
|
423
|
+
// `test` is deliberately absent. It used to be here, which meant no test suite anywhere
|
|
424
|
+
// could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test
|
|
425
|
+
// needs the output.
|
|
426
|
+
if (env === 'dev' || env === 'development') return 'debug';
|
|
401
427
|
}
|
|
402
|
-
return
|
|
428
|
+
return 'silent';
|
|
429
|
+
};
|
|
430
|
+
let level = resolveLevel();
|
|
431
|
+
let rank = RANK[level];
|
|
432
|
+
/**
|
|
433
|
+
* Overrides the level for the rest of the process.
|
|
434
|
+
*
|
|
435
|
+
* The configuration above is read once, at import, which is what makes the gate cheap — but it
|
|
436
|
+
* also means an application that decides its verbosity after startup, or a test that wants to
|
|
437
|
+
* assert on output, has no way in. This is that way in.
|
|
438
|
+
*/ const setLogLevel = (next)=>{
|
|
439
|
+
if (isLogLevel(next) === false) {
|
|
440
|
+
throw new Error(`Unknown log level "${next}". Expected one of: ${LOG_LEVELS.join(', ')}`);
|
|
441
|
+
}
|
|
442
|
+
level = next;
|
|
443
|
+
rank = RANK[next];
|
|
444
|
+
};
|
|
445
|
+
const getLogLevel = ()=>level;
|
|
446
|
+
/** Re-reads the environment. For tests that change it after this module was imported. */ const resetLogLevel = ()=>{
|
|
447
|
+
level = resolveLevel();
|
|
448
|
+
rank = RANK[level];
|
|
403
449
|
};
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
450
|
+
/**
|
|
451
|
+
* Whether a message at this level would be emitted.
|
|
452
|
+
*
|
|
453
|
+
* For the rare call site whose *arguments* are expensive to build — a serialization, a deep
|
|
454
|
+
* clone, a join over a large collection. An ordinary payload object is not worth guarding; see
|
|
455
|
+
* the measurement in the header.
|
|
456
|
+
*/ const isLogLevelEnabled = (at)=>rank >= RANK[at];
|
|
457
|
+
const emit = (at, method, args)=>{
|
|
458
|
+
if (rank < RANK[at]) {
|
|
459
|
+
return;
|
|
407
460
|
}
|
|
461
|
+
// Resolved at call time rather than captured once: test harnesses and browser devtools both
|
|
462
|
+
// replace console methods after modules have loaded, and a captured reference would keep
|
|
463
|
+
// writing past the replacement.
|
|
464
|
+
console[method](...args);
|
|
408
465
|
};
|
|
409
466
|
const logger = {
|
|
410
|
-
log: (...args)
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
warn: (...args) => {
|
|
417
|
-
tryLog("warn", ...args);
|
|
418
|
-
},
|
|
419
|
-
error: (...args) => {
|
|
420
|
-
tryLog("error", ...args);
|
|
421
|
-
},
|
|
422
|
-
debug: (...args) => {
|
|
423
|
-
tryLog("debug", ...args);
|
|
424
|
-
},
|
|
425
|
-
table: (...args) => {
|
|
426
|
-
tryLog("table", ...args);
|
|
427
|
-
},
|
|
467
|
+
/** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */ log: (...args)=>emit('info', 'log', args),
|
|
468
|
+
info: (...args)=>emit('info', 'info', args),
|
|
469
|
+
warn: (...args)=>emit('warn', 'warn', args),
|
|
470
|
+
error: (...args)=>emit('error', 'error', args),
|
|
471
|
+
debug: (...args)=>emit('debug', 'debug', args),
|
|
472
|
+
/** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */ table: (...args)=>emit('debug', 'table', args)
|
|
428
473
|
};
|
|
429
474
|
|
|
430
475
|
|
|
@@ -468,35 +513,52 @@ __webpack_require__.d = (exports, definition) => {
|
|
|
468
513
|
(() => {
|
|
469
514
|
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
470
515
|
})();
|
|
471
|
-
// webpack/runtime/make_namespace_object
|
|
472
|
-
(() => {
|
|
473
|
-
// define __esModule on exports
|
|
474
|
-
__webpack_require__.r = (exports) => {
|
|
475
|
-
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
476
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
477
|
-
}
|
|
478
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
479
|
-
};
|
|
480
|
-
})();
|
|
481
516
|
var __webpack_exports__ = {};
|
|
482
517
|
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
483
518
|
(() => {
|
|
484
|
-
|
|
519
|
+
|
|
520
|
+
// EXPORTS
|
|
485
521
|
__webpack_require__.d(__webpack_exports__, {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
522
|
+
kX: () => (/* reexport */ TrampolinePipeline/* .TrampolinePipeline */.k),
|
|
523
|
+
hq: () => (/* reexport */ SyncronousQueue),
|
|
524
|
+
UQ: () => (/* reexport */ TrampolinePipeline/* .WorkPipeline */.U)
|
|
489
525
|
});
|
|
490
|
-
|
|
491
|
-
|
|
526
|
+
|
|
527
|
+
;// CONCATENATED MODULE: ./src/pipeline/SyncronousQueue.ts
|
|
528
|
+
class SyncronousQueue {
|
|
529
|
+
_queue = [];
|
|
530
|
+
_current = null;
|
|
531
|
+
enqueue(unitOfWork) {
|
|
532
|
+
this._queue.push(unitOfWork);
|
|
533
|
+
this._next();
|
|
534
|
+
}
|
|
535
|
+
_next() {
|
|
536
|
+
if (this._current != null || this._queue.length === 0) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
// Take first item
|
|
540
|
+
this._current = this._queue.shift() ?? null;
|
|
541
|
+
if (this._current == null) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
this._current(()=>{
|
|
545
|
+
this._current = null;
|
|
546
|
+
this._next();
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// EXTERNAL MODULE: ./src/pipeline/TrampolinePipeline.ts
|
|
552
|
+
var TrampolinePipeline = __webpack_require__(416);
|
|
553
|
+
;// CONCATENATED MODULE: ./src/pipeline/index.ts
|
|
492
554
|
|
|
493
555
|
|
|
494
556
|
|
|
495
557
|
})();
|
|
496
558
|
|
|
497
|
-
var __webpack_exports__SyncronousQueue = __webpack_exports__.
|
|
498
|
-
var __webpack_exports__TrampolinePipeline = __webpack_exports__.
|
|
499
|
-
var __webpack_exports__WorkPipeline = __webpack_exports__.
|
|
559
|
+
var __webpack_exports__SyncronousQueue = __webpack_exports__.hq;
|
|
560
|
+
var __webpack_exports__TrampolinePipeline = __webpack_exports__.kX;
|
|
561
|
+
var __webpack_exports__WorkPipeline = __webpack_exports__.UQ;
|
|
500
562
|
export { __webpack_exports__SyncronousQueue as SyncronousQueue, __webpack_exports__TrampolinePipeline as TrampolinePipeline, __webpack_exports__WorkPipeline as WorkPipeline };
|
|
501
563
|
|
|
502
564
|
//# sourceMappingURL=index.js.map
|