@routier/core 0.1.0-rc.1 → 0.2.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.
Files changed (43) hide show
  1. package/dist/assertions/index.js +4 -15
  2. package/dist/assertions/index.js.map +1 -1
  3. package/dist/capabilities/index.js +99 -89
  4. package/dist/capabilities/index.js.map +1 -1
  5. package/dist/codegen/index.js +21 -36
  6. package/dist/codegen/index.js.map +1 -1
  7. package/dist/collections/index.js +49 -92
  8. package/dist/collections/index.js.map +1 -1
  9. package/dist/errors/index.js +4 -15
  10. package/dist/errors/index.js.map +1 -1
  11. package/dist/expressions/index.js +102 -86
  12. package/dist/expressions/index.js.map +1 -1
  13. package/dist/index.js +1737 -2418
  14. package/dist/index.js.map +1 -1
  15. package/dist/performance/index.js +73 -9
  16. package/dist/performance/index.js.map +1 -1
  17. package/dist/pipeline/TrampolinePipeline.d.ts +0 -8
  18. package/dist/pipeline/index.js +71 -174
  19. package/dist/pipeline/index.js.map +1 -1
  20. package/dist/plugins/index.js +302 -479
  21. package/dist/plugins/index.js.map +1 -1
  22. package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +6 -5
  23. package/dist/plugins/replication/ReplicationDbPlugin.d.ts +5 -5
  24. package/dist/plugins/replication/types.d.ts +1 -0
  25. package/dist/plugins/types.d.ts +1 -1
  26. package/dist/results/index.js +11 -26
  27. package/dist/results/index.js.map +1 -1
  28. package/dist/schema/SchemaDefinition.d.ts +7 -6
  29. package/dist/schema/index.js +1119 -1483
  30. package/dist/schema/index.js.map +1 -1
  31. package/dist/schema/property/types/SchemaNumber.d.ts +1 -0
  32. package/dist/schema/property/types/SchemaString.d.ts +1 -0
  33. package/dist/schema/testSchemas.test.d.ts +37 -16
  34. package/dist/schema/types.d.ts +5 -3
  35. package/dist/types/index.js +0 -6
  36. package/dist/types/index.js.map +1 -1
  37. package/dist/utilities/index.d.ts +1 -0
  38. package/dist/utilities/index.js +103 -117
  39. package/dist/utilities/index.js.map +1 -1
  40. package/dist/utilities/logger.d.ts +8 -0
  41. package/dist/utilities/types.d.ts +17 -2
  42. package/package.json +3 -2
  43. package/readme.md +1 -1
@@ -1,7 +1,70 @@
1
- // The require scope
2
- var __webpack_require__ = {};
1
+ var __webpack_modules__ = ({
2
+ "./src/utilities/logger.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3
+ __webpack_require__.r(__webpack_exports__);
4
+ __webpack_require__.d(__webpack_exports__, {
5
+ logger: () => (logger)
6
+ });
7
+ const isDevelopment = () => {
8
+ if (typeof process === 'undefined' || process.env == null) {
9
+ return false;
10
+ }
11
+ const env = "development"?.toLowerCase();
12
+ return env === 'dev' || env === 'development' || env === 'test';
13
+ };
14
+ const shouldLog = isDevelopment();
15
+ const tryLog = (type, ...args) => {
16
+ if (shouldLog) {
17
+ console[type](...args);
18
+ }
19
+ };
20
+ const logger = {
21
+ log: (...args) => {
22
+ tryLog("log", ...args);
23
+ },
24
+ info: (...args) => {
25
+ tryLog("info", ...args);
26
+ },
27
+ warn: (...args) => {
28
+ tryLog("warn", ...args);
29
+ },
30
+ error: (...args) => {
31
+ tryLog("error", ...args);
32
+ },
33
+ debug: (...args) => {
34
+ tryLog("debug", ...args);
35
+ },
36
+ table: (...args) => {
37
+ tryLog("table", ...args);
38
+ },
39
+ };
40
+
41
+
42
+ },
43
+
44
+ });
45
+ // The module cache
46
+ var __webpack_module_cache__ = {};
47
+
48
+ // The require function
49
+ function __webpack_require__(moduleId) {
50
+
51
+ // Check if module is in cache
52
+ var cachedModule = __webpack_module_cache__[moduleId];
53
+ if (cachedModule !== undefined) {
54
+ return cachedModule.exports;
55
+ }
56
+ // Create a new module (and put it into the cache)
57
+ var module = (__webpack_module_cache__[moduleId] = {
58
+ exports: {}
59
+ });
60
+ // Execute the module function
61
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
62
+
63
+ // Return the exports of the module
64
+ return module.exports;
65
+
66
+ }
3
67
 
4
- /************************************************************************/
5
68
  // webpack/runtime/define_property_getters
6
69
  (() => {
7
70
  __webpack_require__.d = (exports, definition) => {
@@ -26,17 +89,16 @@ __webpack_require__.r = (exports) => {
26
89
  Object.defineProperty(exports, '__esModule', { value: true });
27
90
  };
28
91
  })();
29
- /************************************************************************/
30
92
  var __webpack_exports__ = {};
31
-
32
- /*!**********************************!*\
33
- !*** ./src/performance/index.ts ***!
34
- \**********************************/
93
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
94
+ (() => {
35
95
  __webpack_require__.r(__webpack_exports__);
36
96
  __webpack_require__.d(__webpack_exports__, {
37
97
  measure: () => (measure),
38
98
  now: () => (now)
39
99
  });
100
+ /* import */ var _utilities__rspack_import_0 = __webpack_require__("./src/utilities/logger.ts");
101
+
40
102
  const measurements = {};
41
103
  const now = () => {
42
104
  if (typeof performance !== 'undefined' && performance.now) {
@@ -54,10 +116,12 @@ const measure = {
54
116
  const start = measurements[name];
55
117
  delete measurements[name];
56
118
  const delta = now() - start;
57
- console.log(`[ROUTIER] - Performance: ${name} took ${delta}`);
119
+ _utilities__rspack_import_0.logger.log(`[ROUTIER] - Performance: ${name} took ${delta}`);
58
120
  }
59
121
  };
60
122
 
123
+ })();
124
+
61
125
  var __webpack_exports__measure = __webpack_exports__.measure;
62
126
  var __webpack_exports__now = __webpack_exports__.now;
63
127
  export { __webpack_exports__measure as measure, __webpack_exports__now as now };
@@ -1 +1 @@
1
- {"version":3,"file":"performance/index.js","sources":["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/performance/index.ts"],"sourcesContent":["__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};","const measurements: Record<string, number> = {}\n\nexport const now = (): number => {\n if (typeof performance !== 'undefined' && performance.now) {\n // Browser or modern Node.js\n return performance.now();\n }\n\n // Fallback for older environments\n return Date.now();\n}\n\nexport const measure = {\n start: (name: string): void => {\n measurements[name] = now();\n },\n end: (name: string): void => {\n const start = measurements[name];\n\n delete measurements[name];\n\n const delta = now() - start;\n\n console.log(`[ROUTIER] - Performance: ${name} took ${delta}`);\n }\n}"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA;;;;ACNA;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D;;;;;;;;;;;;;ACNA,MAAM,YAAY,GAA2B,EAAE;AAExC,MAAM,GAAG,GAAG,GAAW,EAAE;IAC5B,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,CAAC,GAAG,EAAE,CAAC;QACxD,4BAA4B;QAC5B,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED,kCAAkC;IAClC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC;AAEM,MAAM,OAAO,GAAG;IACnB,KAAK,EAAE,CAAC,IAAY,EAAQ,EAAE;QAC1B,YAAY,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAC/B,CAAC;IACD,GAAG,EAAE,CAAC,IAAY,EAAQ,EAAE;QACxB,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAEjC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAE1B,MAAM,KAAK,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC;QAE5B,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;CACJ"}
1
+ {"version":3,"file":"performance/index.js","sources":["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/performance/index.ts"],"sourcesContent":["const isDevelopment = (): boolean => {\n if (typeof process === 'undefined' || process.env == null) {\n return false;\n }\n const env = process.env.NODE_ENV?.toLowerCase();\n return env === 'dev' || env === 'development' || env === 'test';\n};\n\ntype LogMethods = \"log\" | \"info\" | \"warn\" | \"error\" | \"debug\" | \"table\";\nconst shouldLog = isDevelopment();\nconst tryLog = (type: LogMethods, ...args: unknown[]) => {\n if (shouldLog) {\n (console[type] as (...args: unknown[]) => void)(...args);\n }\n};\n\nexport const logger = {\n log: (...args: unknown[]): void => {\n tryLog(\"log\", ...args);\n },\n info: (...args: unknown[]): void => {\n tryLog(\"info\", ...args);\n },\n warn: (...args: unknown[]): void => {\n tryLog(\"warn\", ...args);\n },\n error: (...args: unknown[]): void => {\n tryLog(\"error\", ...args);\n },\n debug: (...args: unknown[]): void => {\n tryLog(\"debug\", ...args);\n },\n table: (...args: unknown[]): void => {\n tryLog(\"table\", ...args);\n },\n};\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};","import { logger } from \"../utilities\";\n\nconst measurements: Record<string, number> = {}\n\nexport const now = (): number => {\n if (typeof performance !== 'undefined' && performance.now) {\n // Browser or modern Node.js\n return performance.now();\n }\n\n // Fallback for older environments\n return Date.now();\n}\n\nexport const measure = {\n start: (name: string): void => {\n measurements[name] = now();\n },\n end: (name: string): void => {\n const start = measurements[name];\n\n delete measurements[name];\n\n const delta = now() - start;\n\n logger.log(`[ROUTIER] - Performance: ${name} took ${delta}`);\n }\n}"],"names":[],"mappings":";;;;;;AAAA,MAAM,aAAa,GAAG,GAAY,EAAE;IAChC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,GAAG,GAAG,aAAoB,EAAE,WAAW,EAAE,CAAC;IAChD,OAAO,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,aAAa,IAAI,GAAG,KAAK,MAAM,CAAC;AACpE,CAAC,CAAC;AAGF,MAAM,SAAS,GAAG,aAAa,EAAE,CAAC;AAClC,MAAM,MAAM,GAAG,CAAC,IAAgB,EAAE,GAAG,IAAe,EAAE,EAAE;IACpD,IAAI,SAAS,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAkC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7D,CAAC;AACL,CAAC,CAAC;AAEK,MAAM,MAAM,GAAG;IAClB,GAAG,EAAE,CAAC,GAAG,IAAe,EAAQ,EAAE;QAC9B,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,EAAE,CAAC,GAAG,IAAe,EAAQ,EAAE;QAC/B,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,EAAE,CAAC,GAAG,IAAe,EAAQ,EAAE;QAC/B,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAQ,EAAE;QAChC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAQ,EAAE;QAChC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAQ,EAAE;QAChC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACnCF;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;ACNsC;AAEtC,MAAM,YAAY,GAA2B,EAAE;AAExC,MAAM,GAAG,GAAG,GAAW,EAAE;IAC5B,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,CAAC,GAAG,EAAE,CAAC;QACxD,4BAA4B;QAC5B,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED,kCAAkC;IAClC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC;AAEM,MAAM,OAAO,GAAG;IACnB,KAAK,EAAE,CAAC,IAAY,EAAQ,EAAE;QAC1B,YAAY,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAC/B,CAAC;IACD,GAAG,EAAE,CAAC,IAAY,EAAQ,EAAE;QACxB,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAEjC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAE1B,MAAM,KAAK,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC;QAE5B,sCAAU,CAAC,4BAA4B,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC;IACjE,CAAC;CACJ"}
@@ -12,14 +12,6 @@ export declare class TrampolinePipeline<TInitial, TCurrent = TInitial> {
12
12
  pipe<TNext>(processor: Processor<TCurrent, TNext>): TrampolinePipeline<TInitial, TNext>;
13
13
  pipeEach(items: TCurrent[], fn: (payload: ResultType<TCurrent>, done: CallbackResult<TCurrent>) => void, map: (previous: ResultType<TCurrent>, current: ResultType<TCurrent>) => ResultType<TCurrent>): void;
14
14
  }
15
- export type AsyncUnitOfWork<TData, TResult> = (payload: TData, done: CallbackResult<TResult>) => void;
16
- export declare class AsyncPipeline<TData, TResult> {
17
- private _list;
18
- private _hasErrored;
19
- filter(done: CallbackResult<TResult[]>): void;
20
- pipe(data: TData, processor: AsyncUnitOfWork<TData, TResult>): void;
21
- pipeEach(items: TData[], processor: AsyncUnitOfWork<TData, TResult>): void;
22
- }
23
15
  export type UnitOfWork = (done: CallbackResult<never>) => void;
24
16
  /**
25
17
  * Processes functions with callbacks asynchronously.
@@ -1,9 +1,5 @@
1
1
  var __webpack_modules__ = ({
2
- "./src/pipeline/SyncronousQueue.ts":
3
- /*!*****************************************!*\
4
- !*** ./src/pipeline/SyncronousQueue.ts ***!
5
- \*****************************************/
6
- (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2
+ "./src/pipeline/SyncronousQueue.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7
3
  __webpack_require__.r(__webpack_exports__);
8
4
  __webpack_require__.d(__webpack_exports__, {
9
5
  SyncronousQueue: () => (SyncronousQueue)
@@ -32,19 +28,16 @@ class SyncronousQueue {
32
28
  }
33
29
 
34
30
 
35
- }),
36
- "./src/pipeline/TrampolinePipeline.ts":
37
- /*!********************************************!*\
38
- !*** ./src/pipeline/TrampolinePipeline.ts ***!
39
- \********************************************/
40
- (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
31
+ },
32
+ "./src/pipeline/TrampolinePipeline.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
41
33
  __webpack_require__.r(__webpack_exports__);
42
34
  __webpack_require__.d(__webpack_exports__, {
43
- AsyncPipeline: () => (AsyncPipeline),
44
35
  TrampolinePipeline: () => (TrampolinePipeline),
45
36
  WorkPipeline: () => (WorkPipeline)
46
37
  });
47
- /* ESM import */var _results__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../results */ "./src/results/Result.ts");
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");
40
+
48
41
 
49
42
  class TrampolinePipeline {
50
43
  _list = [];
@@ -52,7 +45,7 @@ class TrampolinePipeline {
52
45
  filter(initialData, done) {
53
46
  this._hasErrored = false; // Reset error flag on new execution
54
47
  if (this._list.length === 0) {
55
- queueMicrotask(() => done(initialData));
48
+ done(initialData);
56
49
  return;
57
50
  }
58
51
  let index = 0;
@@ -63,7 +56,7 @@ class TrampolinePipeline {
63
56
  const finalStepSentinel = () => {
64
57
  // Only call done if no error has occurred
65
58
  if (!this._hasErrored) {
66
- queueMicrotask(() => done(currentData));
59
+ done(currentData);
67
60
  }
68
61
  return null; // Stop the trampoline
69
62
  };
@@ -82,7 +75,7 @@ class TrampolinePipeline {
82
75
  processor(currentData, (result, error) => {
83
76
  // --- Error Handling ---
84
77
  if (error) {
85
- console.error(`Error reported by processor at index ${idx}:`, error);
78
+ _utilities__rspack_import_0.logger.error(`Error reported by processor at index ${idx}:`, error);
86
79
  this._hasErrored = true; // Set flag
87
80
  // Throw the error to be caught by outer try...catch blocks
88
81
  throw error;
@@ -105,7 +98,7 @@ class TrampolinePipeline {
105
98
  }
106
99
  catch (error) {
107
100
  if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
108
- console.error(`Error thrown by processor at index ${idx} or its callback:`, error);
101
+ _utilities__rspack_import_0.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
109
102
  this._hasErrored = true;
110
103
  }
111
104
  // Rethrow to be caught by the trampoline's catch block
@@ -128,7 +121,7 @@ class TrampolinePipeline {
128
121
  }
129
122
  isRunning = true;
130
123
  let currentStep = step;
131
- while (typeof currentStep === 'function') {
124
+ while (currentStep !== null) {
132
125
  try {
133
126
  // Stop immediately if an error was flagged elsewhere
134
127
  if (this._hasErrored) {
@@ -140,7 +133,7 @@ class TrampolinePipeline {
140
133
  catch (trampolineError) {
141
134
  // Catch errors propagated from step execution (processor or callback errors)
142
135
  if (!this._hasErrored) { // Avoid double logging
143
- console.error("Error during trampoline step execution:", trampolineError);
136
+ _utilities__rspack_import_0.logger.error("Error during trampoline step execution:", trampolineError);
144
137
  this._hasErrored = true;
145
138
  }
146
139
  currentStep = null; // Stop the loop
@@ -169,135 +162,11 @@ class TrampolinePipeline {
169
162
  pipeEach(items, fn, map) {
170
163
  for (let i = 0, length = items.length; i < length; i++) {
171
164
  this.pipe((previous, done) => {
172
- fn(map(previous, _results__WEBPACK_IMPORTED_MODULE_0__.Result.success(items[i])), done);
165
+ fn(map(previous, _results__rspack_import_1.Result.success(items[i])), done);
173
166
  });
174
167
  }
175
168
  }
176
169
  }
177
- class AsyncPipeline {
178
- _list = [];
179
- _hasErrored = false; // Flag to prevent calling done on error
180
- filter(done) {
181
- this._hasErrored = false; // Reset error flag on new execution
182
- let currentData = [];
183
- if (this._list.length === 0) {
184
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success()));
185
- return;
186
- }
187
- let index = 0;
188
- let isRunning = false; // Guard against overlapping trampoline calls
189
- try {
190
- // --- Revised Completion Logic --- (Moved up for clarity)
191
- const finalStepSentinel = () => {
192
- // Only call done if no error has occurred
193
- if (!this._hasErrored) {
194
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success(currentData)));
195
- }
196
- return null; // Stop the trampoline
197
- };
198
- const createStepRevised = (idx) => {
199
- return () => {
200
- if (this._hasErrored)
201
- return null; // Stop if an error occurred elsewhere
202
- if (idx >= this._list.length) {
203
- return finalStepSentinel(); // Execute the dedicated final step
204
- }
205
- const [payload, processor] = this._list[idx];
206
- // Initialize syncCallbackResult to null to satisfy StepResult type
207
- let syncCallbackResult = null;
208
- let calledSync = false;
209
- try {
210
- processor(payload, (result) => {
211
- // --- Error Handling ---
212
- if (result.ok === _results__WEBPACK_IMPORTED_MODULE_0__.Result.ERROR) {
213
- console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
214
- this._hasErrored = true; // Set flag
215
- // Throw the error to be caught by outer try...catch blocks
216
- throw result.error;
217
- }
218
- // --- /Error Handling ---
219
- // If no error, proceed as before
220
- currentData.push(result.data);
221
- index = idx + 1; // Update index for the next step
222
- const nextStep = createStepRevised(index); // Use updated index
223
- if (isRunning) {
224
- // Callback was synchronous
225
- syncCallbackResult = nextStep; // Store next step function
226
- calledSync = true;
227
- }
228
- else {
229
- // Callback was asynchronous, restart trampoline
230
- trampoline(nextStep);
231
- }
232
- });
233
- }
234
- catch (error) {
235
- if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
236
- console.error(`Error thrown by processor at index ${idx} or its callback:`, error);
237
- this._hasErrored = true;
238
- }
239
- // Rethrow to be caught by the trampoline's catch block
240
- throw error;
241
- }
242
- if (calledSync) {
243
- // Return the next step function for the sync loop
244
- return syncCallbackResult;
245
- }
246
- else {
247
- // Pause trampoline for async, loop will stop as step returns null
248
- return null;
249
- }
250
- };
251
- };
252
- // The trampoline loop
253
- const trampoline = (step) => {
254
- if (isRunning) {
255
- return;
256
- }
257
- isRunning = true;
258
- let currentStep = step;
259
- while (typeof currentStep === 'function') {
260
- try {
261
- // Stop immediately if an error was flagged elsewhere
262
- if (this._hasErrored) {
263
- currentStep = null;
264
- break;
265
- }
266
- currentStep = currentStep(); // Execute step, get next step or null
267
- }
268
- catch (trampolineError) {
269
- // Catch errors propagated from step execution (processor or callback errors)
270
- if (!this._hasErrored) { // Avoid double logging
271
- console.error("Error during trampoline step execution:", trampolineError);
272
- this._hasErrored = true;
273
- }
274
- currentStep = null; // Stop the loop
275
- // We don't call `done` here because an error occurred.
276
- // The application should handle the uncaught exception if desired.
277
- break; // Explicitly break loop on error
278
- }
279
- }
280
- // Loop ends when currentStep is null or loop is broken by error
281
- isRunning = false;
282
- // Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.
283
- };
284
- // --- Start the process ---
285
- index = 0; // Reset index
286
- trampoline(createStepRevised(0)); // Start with the revised step creator
287
- }
288
- catch (error) {
289
- done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.error(error));
290
- }
291
- }
292
- pipe(data, processor) {
293
- this._list.push([data, processor]);
294
- }
295
- pipeEach(items, processor) {
296
- for (let i = 0, length = items.length; i < length; i++) {
297
- this.pipe(items[i], processor);
298
- }
299
- }
300
- }
301
170
  /**
302
171
  * Processes functions with callbacks asynchronously.
303
172
  *
@@ -311,7 +180,7 @@ class WorkPipeline {
311
180
  filter(done) {
312
181
  this._hasErrored = false; // Reset error flag on new execution
313
182
  if (this.unitsOfWork.length === 0) {
314
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success()));
183
+ done(_results__rspack_import_1.Result.success());
315
184
  return;
316
185
  }
317
186
  let index = 0;
@@ -321,7 +190,7 @@ class WorkPipeline {
321
190
  const finalStepSentinel = () => {
322
191
  // Only call done if no error has occurred
323
192
  if (!this._hasErrored) {
324
- queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success()));
193
+ done(_results__rspack_import_1.Result.success());
325
194
  }
326
195
  return null; // Stop the trampoline
327
196
  };
@@ -339,8 +208,8 @@ class WorkPipeline {
339
208
  try {
340
209
  processor((result) => {
341
210
  // --- Error Handling ---
342
- if (result.ok === _results__WEBPACK_IMPORTED_MODULE_0__.Result.ERROR) {
343
- console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
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);
344
213
  this._hasErrored = true; // Set flag
345
214
  // Throw the error to be caught by outer try...catch blocks
346
215
  throw result.error;
@@ -362,7 +231,7 @@ class WorkPipeline {
362
231
  }
363
232
  catch (error) {
364
233
  if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
365
- console.error(`Error thrown by processor at index ${idx} or its callback:`, error);
234
+ _utilities__rspack_import_0.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
366
235
  this._hasErrored = true;
367
236
  }
368
237
  // Rethrow to be caught by the trampoline's catch block
@@ -385,7 +254,7 @@ class WorkPipeline {
385
254
  }
386
255
  isRunning = true;
387
256
  let currentStep = step;
388
- while (typeof currentStep === 'function') {
257
+ while (currentStep !== null) {
389
258
  try {
390
259
  // Stop immediately if an error was flagged elsewhere
391
260
  if (this._hasErrored) {
@@ -397,7 +266,7 @@ class WorkPipeline {
397
266
  catch (trampolineError) {
398
267
  // Catch errors propagated from step execution (processor or callback errors)
399
268
  if (!this._hasErrored) { // Avoid double logging
400
- console.error("Error during trampoline step execution:", trampolineError);
269
+ _utilities__rspack_import_0.logger.error("Error during trampoline step execution:", trampolineError);
401
270
  this._hasErrored = true;
402
271
  }
403
272
  currentStep = null; // Stop the loop
@@ -415,7 +284,7 @@ class WorkPipeline {
415
284
  trampoline(createStepRevised(0)); // Start with the revised step creator
416
285
  }
417
286
  catch (error) {
418
- done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.error(error));
287
+ done(_results__rspack_import_1.Result.error(error));
419
288
  }
420
289
  }
421
290
  pipe(work) {
@@ -424,12 +293,8 @@ class WorkPipeline {
424
293
  }
425
294
 
426
295
 
427
- }),
428
- "./src/results/Result.ts":
429
- /*!*******************************!*\
430
- !*** ./src/results/Result.ts ***!
431
- \*******************************/
432
- (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
296
+ },
297
+ "./src/results/Result.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
433
298
  __webpack_require__.r(__webpack_exports__);
434
299
  __webpack_require__.d(__webpack_exports__, {
435
300
  PluginEventResult: () => (PluginEventResult),
@@ -511,10 +376,50 @@ class PluginEventResult extends BaseResult {
511
376
  }
512
377
 
513
378
 
514
- }),
379
+ },
380
+ "./src/utilities/logger.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
381
+ __webpack_require__.r(__webpack_exports__);
382
+ __webpack_require__.d(__webpack_exports__, {
383
+ logger: () => (logger)
384
+ });
385
+ const isDevelopment = () => {
386
+ if (typeof process === 'undefined' || process.env == null) {
387
+ return false;
388
+ }
389
+ const env = "development"?.toLowerCase();
390
+ return env === 'dev' || env === 'development' || env === 'test';
391
+ };
392
+ const shouldLog = isDevelopment();
393
+ const tryLog = (type, ...args) => {
394
+ if (shouldLog) {
395
+ console[type](...args);
396
+ }
397
+ };
398
+ const logger = {
399
+ log: (...args) => {
400
+ tryLog("log", ...args);
401
+ },
402
+ info: (...args) => {
403
+ tryLog("info", ...args);
404
+ },
405
+ warn: (...args) => {
406
+ tryLog("warn", ...args);
407
+ },
408
+ error: (...args) => {
409
+ tryLog("error", ...args);
410
+ },
411
+ debug: (...args) => {
412
+ tryLog("debug", ...args);
413
+ },
414
+ table: (...args) => {
415
+ tryLog("table", ...args);
416
+ },
417
+ };
418
+
419
+
420
+ },
515
421
 
516
422
  });
517
- /************************************************************************/
518
423
  // The module cache
519
424
  var __webpack_module_cache__ = {};
520
425
 
@@ -538,7 +443,6 @@ return module.exports;
538
443
 
539
444
  }
540
445
 
541
- /************************************************************************/
542
446
  // webpack/runtime/define_property_getters
543
447
  (() => {
544
448
  __webpack_require__.d = (exports, definition) => {
@@ -563,32 +467,25 @@ __webpack_require__.r = (exports) => {
563
467
  Object.defineProperty(exports, '__esModule', { value: true });
564
468
  };
565
469
  })();
566
- /************************************************************************/
567
470
  var __webpack_exports__ = {};
568
471
  // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
569
472
  (() => {
570
-
571
- /*!*******************************!*\
572
- !*** ./src/pipeline/index.ts ***!
573
- \*******************************/
574
473
  __webpack_require__.r(__webpack_exports__);
575
474
  __webpack_require__.d(__webpack_exports__, {
576
- AsyncPipeline: () => (/* reexport safe */ _TrampolinePipeline__WEBPACK_IMPORTED_MODULE_1__.AsyncPipeline),
577
- SyncronousQueue: () => (/* reexport safe */ _SyncronousQueue__WEBPACK_IMPORTED_MODULE_0__.SyncronousQueue),
578
- TrampolinePipeline: () => (/* reexport safe */ _TrampolinePipeline__WEBPACK_IMPORTED_MODULE_1__.TrampolinePipeline),
579
- WorkPipeline: () => (/* reexport safe */ _TrampolinePipeline__WEBPACK_IMPORTED_MODULE_1__.WorkPipeline)
475
+ SyncronousQueue: () => (/* reexport safe */ _SyncronousQueue__rspack_import_0.SyncronousQueue),
476
+ TrampolinePipeline: () => (/* reexport safe */ _TrampolinePipeline__rspack_import_1.TrampolinePipeline),
477
+ WorkPipeline: () => (/* reexport safe */ _TrampolinePipeline__rspack_import_1.WorkPipeline)
580
478
  });
581
- /* ESM import */var _SyncronousQueue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SyncronousQueue */ "./src/pipeline/SyncronousQueue.ts");
582
- /* ESM import */var _TrampolinePipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TrampolinePipeline */ "./src/pipeline/TrampolinePipeline.ts");
479
+ /* import */ var _SyncronousQueue__rspack_import_0 = __webpack_require__("./src/pipeline/SyncronousQueue.ts");
480
+ /* import */ var _TrampolinePipeline__rspack_import_1 = __webpack_require__("./src/pipeline/TrampolinePipeline.ts");
583
481
 
584
482
 
585
483
 
586
484
  })();
587
485
 
588
- var __webpack_exports__AsyncPipeline = __webpack_exports__.AsyncPipeline;
589
486
  var __webpack_exports__SyncronousQueue = __webpack_exports__.SyncronousQueue;
590
487
  var __webpack_exports__TrampolinePipeline = __webpack_exports__.TrampolinePipeline;
591
488
  var __webpack_exports__WorkPipeline = __webpack_exports__.WorkPipeline;
592
- export { __webpack_exports__AsyncPipeline as AsyncPipeline, __webpack_exports__SyncronousQueue as SyncronousQueue, __webpack_exports__TrampolinePipeline as TrampolinePipeline, __webpack_exports__WorkPipeline as WorkPipeline };
489
+ export { __webpack_exports__SyncronousQueue as SyncronousQueue, __webpack_exports__TrampolinePipeline as TrampolinePipeline, __webpack_exports__WorkPipeline as WorkPipeline };
593
490
 
594
491
  //# sourceMappingURL=index.js.map