@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.
Files changed (161) hide show
  1. package/LICENSE +21 -0
  2. package/{readme.md → README.md} +3 -3
  3. package/dist/assertions/index.cjs +191 -0
  4. package/dist/assertions/index.cjs.map +1 -0
  5. package/dist/assertions/index.js +43 -63
  6. package/dist/assertions/index.js.map +1 -1
  7. package/dist/capabilities/index.cjs +820 -0
  8. package/dist/capabilities/index.cjs.map +1 -0
  9. package/dist/capabilities/index.js +584 -558
  10. package/dist/capabilities/index.js.map +1 -1
  11. package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
  12. package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
  13. package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
  14. package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
  15. package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
  16. package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
  17. package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
  18. package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
  19. package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
  20. package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
  21. package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
  22. package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
  23. package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
  24. package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
  25. package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
  26. package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
  27. package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
  28. package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
  29. package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
  30. package/dist/codegen/handlers/types.d.ts +55 -1
  31. package/dist/codegen/index.cjs +618 -0
  32. package/dist/codegen/index.cjs.map +1 -0
  33. package/dist/codegen/index.js +99 -127
  34. package/dist/codegen/index.js.map +1 -1
  35. package/dist/collections/MemoryDataCollection.d.ts +15 -1
  36. package/dist/collections/TagCollection.d.ts +0 -1
  37. package/dist/collections/index.cjs +702 -0
  38. package/dist/collections/index.cjs.map +1 -0
  39. package/dist/collections/index.js +282 -276
  40. package/dist/collections/index.js.map +1 -1
  41. package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
  42. package/dist/errors/PluginDestroyedError.d.ts +10 -0
  43. package/dist/errors/index.cjs +132 -0
  44. package/dist/errors/index.cjs.map +1 -0
  45. package/dist/errors/index.d.ts +2 -0
  46. package/dist/errors/index.js +61 -19
  47. package/dist/errors/index.js.map +1 -1
  48. package/dist/expressions/evaluate.d.ts +53 -0
  49. package/dist/expressions/index.cjs +2087 -0
  50. package/dist/expressions/index.cjs.map +1 -0
  51. package/dist/expressions/index.d.ts +1 -1
  52. package/dist/expressions/index.js +1727 -1082
  53. package/dist/expressions/index.js.map +1 -1
  54. package/dist/expressions/parser.d.ts +19 -0
  55. package/dist/expressions/types.d.ts +87 -2
  56. package/dist/index.cjs +14377 -0
  57. package/dist/index.cjs.map +1 -0
  58. package/dist/index.js +12374 -7931
  59. package/dist/index.js.map +1 -1
  60. package/dist/performance/index.cjs +217 -0
  61. package/dist/performance/index.cjs.map +1 -0
  62. package/dist/performance/index.js +120 -55
  63. package/dist/performance/index.js.map +1 -1
  64. package/dist/pipeline/index.cjs +576 -0
  65. package/dist/pipeline/index.cjs.map +1 -0
  66. package/dist/pipeline/index.js +223 -161
  67. package/dist/pipeline/index.js.map +1 -1
  68. package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
  69. package/dist/plugins/CacheDbPlugin.d.ts +70 -0
  70. package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
  71. package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
  72. package/dist/plugins/RetryDbPlugin.d.ts +77 -0
  73. package/dist/plugins/index.cjs +6551 -0
  74. package/dist/plugins/index.cjs.map +1 -0
  75. package/dist/plugins/index.d.ts +5 -0
  76. package/dist/plugins/index.js +6271 -1170
  77. package/dist/plugins/index.js.map +1 -1
  78. package/dist/plugins/query/QueryOptionsCollection.d.ts +34 -0
  79. package/dist/plugins/query/explain.d.ts +82 -0
  80. package/dist/plugins/query/formatExplanation.d.ts +9 -0
  81. package/dist/plugins/query/index.d.ts +4 -0
  82. package/dist/plugins/query/join.d.ts +210 -0
  83. package/dist/plugins/query/similarity.d.ts +38 -0
  84. package/dist/plugins/query/types.d.ts +75 -1
  85. package/dist/plugins/translators/DataTranslator.d.ts +28 -0
  86. package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
  87. package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
  88. package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
  89. package/dist/plugins/translators/index.d.ts +1 -0
  90. package/dist/plugins/types.d.ts +125 -3
  91. package/dist/plugins/wire/handler.d.ts +122 -0
  92. package/dist/plugins/wire/index.d.ts +4 -0
  93. package/dist/plugins/wire/persist.d.ts +43 -0
  94. package/dist/plugins/wire/query.d.ts +49 -0
  95. package/dist/plugins/wire/types.d.ts +139 -0
  96. package/dist/results/index.cjs +174 -0
  97. package/dist/results/index.cjs.map +1 -0
  98. package/dist/results/index.js +29 -44
  99. package/dist/results/index.js.map +1 -1
  100. package/dist/schema/PropertyInfo.d.ts +31 -2
  101. package/dist/schema/SchemaDefinition.d.ts +23 -1
  102. package/dist/schema/builder.d.ts +35 -1
  103. package/dist/schema/communication/broadcast.d.ts +17 -1
  104. package/dist/schema/index.cjs +6911 -0
  105. package/dist/schema/index.cjs.map +1 -0
  106. package/dist/schema/index.d.ts +2 -0
  107. package/dist/schema/index.js +5330 -4541
  108. package/dist/schema/index.js.map +1 -1
  109. package/dist/schema/property/base/SchemaBase.d.ts +48 -2
  110. package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
  111. package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
  112. package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
  113. package/dist/schema/property/modifiers/index.d.ts +1 -0
  114. package/dist/schema/property/types/SchemaFile.d.ts +60 -0
  115. package/dist/schema/property/types/SchemaString.d.ts +21 -1
  116. package/dist/schema/property/types/SchemaVector.d.ts +61 -0
  117. package/dist/schema/property/types/index.d.ts +2 -0
  118. package/dist/schema/table/SchemaTransform.d.ts +40 -0
  119. package/dist/schema/table/index.d.ts +1 -0
  120. package/dist/schema/types.d.ts +166 -8
  121. package/dist/schema/utils/propertyKind.d.ts +4 -0
  122. package/dist/types/index.cjs +23 -0
  123. package/dist/types/index.cjs.map +1 -0
  124. package/dist/types/index.js +0 -14
  125. package/dist/types/index.js.map +1 -1
  126. package/dist/utilities/index.cjs +1013 -0
  127. package/dist/utilities/index.cjs.map +1 -0
  128. package/dist/utilities/index.js +541 -379
  129. package/dist/utilities/index.js.map +1 -1
  130. package/dist/utilities/logger.d.ts +48 -0
  131. package/package.json +156 -98
  132. package/dist/codegen/SlotPath.test.d.ts +0 -1
  133. package/dist/codegen/blocks.test.d.ts +0 -1
  134. package/dist/codegen/utils.test.d.ts +0 -1
  135. package/dist/collections/Changes.test.d.ts +0 -1
  136. package/dist/collections/IdSet.test.d.ts +0 -1
  137. package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
  138. package/dist/collections/TagCollection.contract.test.d.ts +0 -1
  139. package/dist/collections/TagCollection.test.d.ts +0 -1
  140. package/dist/expressions/parser.test.d.ts +0 -1
  141. package/dist/expressions/sql.d.ts +0 -28
  142. package/dist/expressions/sql.test.d.ts +0 -1
  143. package/dist/expressions/utils.test.d.ts +0 -1
  144. package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
  145. package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
  146. package/dist/plugins/query/Query.test.d.ts +0 -1
  147. package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
  148. package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
  149. package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
  150. package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
  151. package/dist/results/Result.test.d.ts +0 -1
  152. package/dist/results/utils.test.d.ts +0 -1
  153. package/dist/schema/PropertyInfo.test.d.ts +0 -1
  154. package/dist/schema/communication/broadcast.test.d.ts +0 -1
  155. package/dist/schema/schemaGeneration.test.d.ts +0 -1
  156. package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
  157. package/dist/utilities/arrays.test.d.ts +0 -1
  158. package/dist/utilities/dates.test.d.ts +0 -1
  159. package/dist/utilities/runtime.test.d.ts +0 -1
  160. package/dist/utilities/strings.test.d.ts +0 -1
  161. package/dist/utilities/uuid.test.d.ts +0 -1
@@ -1,9 +1,385 @@
1
1
  var __webpack_modules__ = ({
2
- "./src/capabilities/Capability.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3
- __webpack_require__.r(__webpack_exports__);
2
+ 581(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
3
  __webpack_require__.d(__webpack_exports__, {
5
- Capability: () => (Capability)
4
+ vF: () => (logger)
6
5
  });
6
+ /**
7
+ * Levelled logging, resolved once.
8
+ *
9
+ * Three things about the previous implementation drove this shape:
10
+ *
11
+ * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever
12
+ * compared against `true`, so setting it to `false` did nothing — while
13
+ * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.
14
+ * A documented switch that silently does nothing is worse than no switch.
15
+ * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always
16
+ * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through
17
+ * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also
18
+ * capture console output by snapshotting a stack trace per call, so the cost is far above what
19
+ * writing to a terminal would suggest — and the output buries whatever the failure was.
20
+ * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug
21
+ * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.
22
+ *
23
+ * Levels are compared numerically against a value cached at module load. Measured against a
24
+ * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.
25
+ * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why
26
+ * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —
27
+ * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call
28
+ * site to do it.
29
+ */ /** Ordered from most severe to most verbose. `silent` discards everything. */ const LOG_LEVELS = [
30
+ 'silent',
31
+ 'error',
32
+ 'warn',
33
+ 'info',
34
+ 'debug'
35
+ ];
36
+ /** Numeric rank, so a gate is one integer comparison. */ const RANK = {
37
+ silent: 0,
38
+ error: 1,
39
+ warn: 2,
40
+ info: 3,
41
+ debug: 4
42
+ };
43
+ const isLogLevel = (value)=>typeof value === 'string' && LOG_LEVELS.includes(value);
44
+ /**
45
+ * Resolves the configured level, in precedence order.
46
+ *
47
+ * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an
48
+ * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything
49
+ * unrecognised is ignored rather than treated as an error — a typo'd level should not take down
50
+ * an application, and `silent` is the safe direction to fall back to.
51
+ */ const resolveLevel = ()=>{
52
+ if (typeof globalThis !== 'undefined') {
53
+ const g = globalThis;
54
+ if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {
55
+ return g.__ROUTIER_LOG_LEVEL__;
56
+ }
57
+ // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks
58
+ // below and re-enable the logging it was asked to suppress.
59
+ if (g.__ROUTIER_DEBUG__ === true) return 'debug';
60
+ if (g.__ROUTIER_DEBUG__ === false) return 'silent';
61
+ }
62
+ // There is deliberately no `import.meta.env` branch, although the documentation used to
63
+ // promise one. It could never work: this package is bundled with rspack, which replaces
64
+ // `import.meta` with `undefined`, so the check would read the *library's* build-time
65
+ // environment rather than the application's — and referencing `import.meta` at all is a parse
66
+ // error under a CommonJS build target, which is how the test suite loads this file. Vite and
67
+ // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own
68
+ // `import.meta.env`, which is what the docs now describe.
69
+ if (typeof process !== 'undefined' && process.env != null) {
70
+ if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {
71
+ return process.env.ROUTIER_LOG_LEVEL;
72
+ }
73
+ const debug = process.env.DEBUG;
74
+ if (debug === 'routier' || debug === '*') return 'debug';
75
+ const env = "production"?.toLowerCase();
76
+ // `test` is deliberately absent. It used to be here, which meant no test suite anywhere
77
+ // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test
78
+ // needs the output.
79
+ if (env === 'dev' || env === 'development') return 'debug';
80
+ }
81
+ return 'silent';
82
+ };
83
+ let level = resolveLevel();
84
+ let rank = RANK[level];
85
+ /**
86
+ * Overrides the level for the rest of the process.
87
+ *
88
+ * The configuration above is read once, at import, which is what makes the gate cheap — but it
89
+ * also means an application that decides its verbosity after startup, or a test that wants to
90
+ * assert on output, has no way in. This is that way in.
91
+ */ const setLogLevel = (next)=>{
92
+ if (isLogLevel(next) === false) {
93
+ throw new Error(`Unknown log level "${next}". Expected one of: ${LOG_LEVELS.join(', ')}`);
94
+ }
95
+ level = next;
96
+ rank = RANK[next];
97
+ };
98
+ const getLogLevel = ()=>level;
99
+ /** Re-reads the environment. For tests that change it after this module was imported. */ const resetLogLevel = ()=>{
100
+ level = resolveLevel();
101
+ rank = RANK[level];
102
+ };
103
+ /**
104
+ * Whether a message at this level would be emitted.
105
+ *
106
+ * For the rare call site whose *arguments* are expensive to build — a serialization, a deep
107
+ * clone, a join over a large collection. An ordinary payload object is not worth guarding; see
108
+ * the measurement in the header.
109
+ */ const isLogLevelEnabled = (at)=>rank >= RANK[at];
110
+ const emit = (at, method, args)=>{
111
+ if (rank < RANK[at]) {
112
+ return;
113
+ }
114
+ // Resolved at call time rather than captured once: test harnesses and browser devtools both
115
+ // replace console methods after modules have loaded, and a captured reference would keep
116
+ // writing past the replacement.
117
+ console[method](...args);
118
+ };
119
+ const logger = {
120
+ /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */ log: (...args)=>emit('info', 'log', args),
121
+ info: (...args)=>emit('info', 'info', args),
122
+ warn: (...args)=>emit('warn', 'warn', args),
123
+ error: (...args)=>emit('error', 'error', args),
124
+ debug: (...args)=>emit('debug', 'debug', args),
125
+ /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */ table: (...args)=>emit('debug', 'table', args)
126
+ };
127
+
128
+
129
+ },
130
+ 615(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
131
+ __webpack_require__.d(__webpack_exports__, {
132
+ Zm: () => (stringifyObject)
133
+ });
134
+ const hash = (value, seed = 0)=>{
135
+ // From Stack Overflow
136
+ // https://stackoverflow.com/a/52171480/3329760
137
+ let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
138
+ for(let i = 0, ch; i < value.length; i++){
139
+ ch = value.charCodeAt(i);
140
+ h1 = Math.imul(h1 ^ ch, 2654435761);
141
+ h2 = Math.imul(h2 ^ ch, 1597334677);
142
+ }
143
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
144
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
145
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
146
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
147
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
148
+ };
149
+ /**
150
+ * Fast string hash optimized for comparisons.
151
+ * Uses djb2 algorithm - very fast and good distribution for short to medium strings.
152
+ * Same input always produces same output (deterministic).
153
+ *
154
+ * @param value - The string to hash
155
+ * @param seed - Optional seed value (default: 5381)
156
+ * @returns A positive 32-bit integer hash value
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * fastHash("test") === fastHash("test") // true
161
+ * fastHash("test") !== fastHash("test2") // true
162
+ * ```
163
+ */ const fastHash = (value, seed = 5381)=>{
164
+ let hash = seed;
165
+ for(let i = 0; i < value.length; i++){
166
+ hash = (hash << 5) + hash + value.charCodeAt(i);
167
+ }
168
+ return hash >>> 0; // Convert to unsigned 32-bit integer
169
+ };
170
+ /**
171
+ * Converts any value to a readable string representation.
172
+ * Handles primitives, objects, arrays, classes, dates, errors, and functions.
173
+ * Supports depth limiting to prevent infinite recursion on circular references.
174
+ *
175
+ * @param obj - The value to stringify
176
+ * @param maxDepth - Maximum depth for nested objects (default: 3)
177
+ * @param currentDepth - Current recursion depth (default: 0)
178
+ * @returns String representation of the value
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * stringifyObject({ name: "test", count: 5 }) // '{ name: "test", count: 5 }'
183
+ * stringifyObject([1, 2, 3]) // '[1, 2, 3]'
184
+ * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'
185
+ * ```
186
+ */ function stringifyObject(obj, maxDepth = 3, currentDepth = 0) {
187
+ if (obj === null) return 'null';
188
+ if (obj === undefined) return 'undefined';
189
+ const type = typeof obj;
190
+ switch(type){
191
+ case 'string':
192
+ return `"${obj}"`;
193
+ case 'number':
194
+ case 'boolean':
195
+ return String(obj);
196
+ case 'function':
197
+ return `[Function: ${getFunctionName(obj)}]`;
198
+ case 'object':
199
+ if (currentDepth >= maxDepth) {
200
+ return '[Max Depth Reached]';
201
+ }
202
+ return stringifyObjectValue(obj, maxDepth, currentDepth);
203
+ default:
204
+ return `[${type}]`;
205
+ }
206
+ }
207
+ function getFunctionName(fn) {
208
+ const name = fn.name;
209
+ return name || 'anonymous';
210
+ }
211
+ function getObjectProperties(obj) {
212
+ const properties = {};
213
+ for(const key in obj){
214
+ if (obj.hasOwnProperty(key)) {
215
+ properties[key] = obj[key];
216
+ }
217
+ }
218
+ return properties;
219
+ }
220
+ function stringifyObjectValue(obj, maxDepth, currentDepth) {
221
+ if (obj === null) return 'null';
222
+ if (obj instanceof Date) {
223
+ return `Date(${obj.toISOString()})`;
224
+ }
225
+ if (obj instanceof Error) {
226
+ return `Error(${obj.message})`;
227
+ }
228
+ if (obj instanceof RegExp) {
229
+ return obj.toString();
230
+ }
231
+ if (Array.isArray(obj)) {
232
+ return stringifyArray(obj, maxDepth, currentDepth);
233
+ }
234
+ if (obj.constructor && obj.constructor.name !== 'Object') {
235
+ return stringifyClassInstance(obj, maxDepth, currentDepth);
236
+ }
237
+ return stringifyPlainObject(obj, maxDepth, currentDepth);
238
+ }
239
+ function stringifyArray(arr, maxDepth, currentDepth) {
240
+ if (arr.length === 0) return '[]';
241
+ const items = arr.slice(0, 5).map((item)=>stringifyObject(item, maxDepth, currentDepth + 1));
242
+ const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';
243
+ return `[${items.join(', ')}${suffix}]`;
244
+ }
245
+ function stringifyClassInstance(obj, maxDepth, currentDepth) {
246
+ const className = obj.constructor.name;
247
+ const properties = getObjectProperties(obj);
248
+ if (Object.keys(properties).length === 0) {
249
+ return `${className} {}`;
250
+ }
251
+ const props = Object.entries(properties).slice(0, 5).map(([key, value])=>{
252
+ const isPrimitive = value === null || value === undefined || typeof value !== 'object' && typeof value !== 'function';
253
+ const depth = isPrimitive ? currentDepth : currentDepth + 1;
254
+ return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
255
+ });
256
+ const suffix = Object.keys(properties).length > 5 ? `... (+${Object.keys(properties).length - 5} more)` : '';
257
+ return `${className} { ${props.join(', ')}${suffix} }`;
258
+ }
259
+ function stringifyPlainObject(obj, maxDepth, currentDepth) {
260
+ const properties = getObjectProperties(obj);
261
+ if (Object.keys(properties).length === 0) {
262
+ return '{}';
263
+ }
264
+ const props = Object.entries(properties).slice(0, 5).map(([key, value])=>{
265
+ const isPrimitive = value === null || value === undefined || typeof value !== 'object' && typeof value !== 'function';
266
+ const depth = isPrimitive ? currentDepth : currentDepth + 1;
267
+ return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
268
+ });
269
+ const suffix = Object.keys(properties).length > 5 ? `... (+${Object.keys(properties).length - 5} more)` : '';
270
+ return `{ ${props.join(', ')}${suffix} }`;
271
+ }
272
+
273
+
274
+ },
275
+ 618(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
276
+ __webpack_require__.d(__webpack_exports__, {
277
+ u: () => (uuid)
278
+ });
279
+ const uuid = (length = 16)=>{
280
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
281
+ const charLength = chars.length;
282
+ let result = '';
283
+ for(let i = 0; i < length; i++){
284
+ result += chars[Math.random() * charLength | 0];
285
+ }
286
+ return result;
287
+ };
288
+ const HEX_CHARS = '0123456789abcdef';
289
+ const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
290
+ const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
291
+ const hasRandomUUID = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';
292
+ const uuidv4 = ()=>{
293
+ if (hasRandomUUID) {
294
+ return crypto.randomUUID();
295
+ }
296
+ return uuidv4Fallback();
297
+ };
298
+ const uuidv4Fallback = ()=>{
299
+ let randomBytes = null;
300
+ if (hasCrypto) {
301
+ randomBytes = crypto.getRandomValues(new Uint8Array(16));
302
+ }
303
+ let byteIndex = 0;
304
+ let uuid = '';
305
+ for(let i = 0; i < UUID_TEMPLATE.length; i++){
306
+ const c = UUID_TEMPLATE[i];
307
+ if (c === '-') {
308
+ uuid += '-';
309
+ continue;
310
+ }
311
+ let r;
312
+ if (hasCrypto && randomBytes) {
313
+ // Each byte gives two hex digits (nibbles)
314
+ r = i % 2 === 0 ? randomBytes[byteIndex] >> 4 : randomBytes[byteIndex++] & 0x0f;
315
+ } else {
316
+ r = Math.floor(Math.random() * 16);
317
+ }
318
+ if (c === 'x') {
319
+ uuid += HEX_CHARS[r];
320
+ } else if (c === 'y') {
321
+ // Variant bits: 8, 9, A, or B
322
+ uuid += HEX_CHARS[r & 0x3 | 0x8];
323
+ } else if (c === '4') {
324
+ uuid += '4';
325
+ }
326
+ }
327
+ return uuid;
328
+ };
329
+
330
+
331
+ },
332
+
333
+ });
334
+ // The module cache
335
+ var __webpack_module_cache__ = {};
336
+
337
+ // The require function
338
+ function __webpack_require__(moduleId) {
339
+
340
+ // Check if module is in cache
341
+ var cachedModule = __webpack_module_cache__[moduleId];
342
+ if (cachedModule !== undefined) {
343
+ return cachedModule.exports;
344
+ }
345
+ // Create a new module (and put it into the cache)
346
+ var module = (__webpack_module_cache__[moduleId] = {
347
+ exports: {}
348
+ });
349
+ // Execute the module function
350
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
351
+
352
+ // Return the exports of the module
353
+ return module.exports;
354
+
355
+ }
356
+
357
+ // webpack/runtime/define_property_getters
358
+ (() => {
359
+ __webpack_require__.d = (exports, definition) => {
360
+ for(var key in definition) {
361
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
362
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
363
+ }
364
+ }
365
+ };
366
+ })();
367
+ // webpack/runtime/has_own_property
368
+ (() => {
369
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
370
+ })();
371
+ var __webpack_exports__ = {};
372
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
373
+ (() => {
374
+
375
+ // EXPORTS
376
+ __webpack_require__.d(__webpack_exports__, {
377
+ nS: () => (/* reexport */ Capability),
378
+ VP: () => (/* reexport */ PerformanceCapability),
379
+ XO: () => (/* reexport */ TracingCapability)
380
+ });
381
+
382
+ ;// CONCATENATED MODULE: ./src/capabilities/Capability.ts
7
383
  class Capability {
8
384
  excludedNames = new Set([
9
385
  "Array",
@@ -20,6 +396,7 @@ class Capability {
20
396
  "SchemaDefault",
21
397
  "SchemaDeserialize",
22
398
  "SchemaDistinct",
399
+ "SchemaSearchable",
23
400
  "SchemaFrom",
24
401
  "SchemaIdentity",
25
402
  "SchemaIndex",
@@ -38,10 +415,7 @@ class Capability {
38
415
  return typeof obj === "object" && obj !== null;
39
416
  }
40
417
  isCallableMethod(descriptor, key) {
41
- return (descriptor?.value &&
42
- typeof descriptor.value === 'function' &&
43
- key !== 'constructor' &&
44
- key !== 'undefined');
418
+ return descriptor?.value && typeof descriptor.value === 'function' && key !== 'constructor' && key !== 'undefined';
45
419
  }
46
420
  canExplore(descriptor) {
47
421
  if (typeof descriptor.value !== "object") {
@@ -64,8 +438,11 @@ class Capability {
64
438
  }
65
439
  getPath(info, propertyName) {
66
440
  let parent = info.parent;
67
- const path = [info.propertyName, propertyName];
68
- while (parent != null) {
441
+ const path = [
442
+ info.propertyName,
443
+ propertyName
444
+ ];
445
+ while(parent != null){
69
446
  path.unshift(parent.propertyName);
70
447
  parent = parent.parent;
71
448
  }
@@ -75,9 +452,14 @@ class Capability {
75
452
  if (!this.isValidObject(instance)) {
76
453
  return;
77
454
  }
78
- const explore = [{ instance, propertyName: this.getName(instance) }];
455
+ const explore = [
456
+ {
457
+ instance,
458
+ propertyName: this.getName(instance)
459
+ }
460
+ ];
79
461
  const visited = new Set();
80
- for (let i = 0; i < explore.length; i++) {
462
+ for(let i = 0; i < explore.length; i++){
81
463
  const info = explore[i];
82
464
  const item = info.instance;
83
465
  if (visited.has(item)) {
@@ -85,9 +467,9 @@ class Capability {
85
467
  }
86
468
  const allKeys = [
87
469
  ...Object.getOwnPropertyNames(item),
88
- ...Object.getOwnPropertySymbols(item),
470
+ ...Object.getOwnPropertySymbols(item)
89
471
  ];
90
- for (const key of allKeys) {
472
+ for (const key of allKeys){
91
473
  const descriptor = Object.getOwnPropertyDescriptor(item, key);
92
474
  const isCallable = this.isCallableMethod(descriptor, key);
93
475
  onDiscover(info, {
@@ -98,53 +480,166 @@ class Capability {
98
480
  continue;
99
481
  }
100
482
  const path = this.getPath(info, key);
101
- explore.push({ instance: descriptor.value, parent: info, propertyName: key, path });
483
+ explore.push({
484
+ instance: descriptor.value,
485
+ parent: info,
486
+ propertyName: key,
487
+ path
488
+ });
102
489
  }
103
490
  visited.add(item);
104
491
  }
105
492
  }
106
493
  }
107
494
 
108
-
109
- },
110
- "./src/capabilities/PerformanceCapability.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
111
- __webpack_require__.r(__webpack_exports__);
112
- __webpack_require__.d(__webpack_exports__, {
113
- PerformanceCapability: () => (PerformanceCapability)
114
- });
115
- /* import */ var _utilities__rspack_import_4 = __webpack_require__("./src/utilities/strings.ts");
116
- /* import */ var _Capability__rspack_import_0 = __webpack_require__("./src/capabilities/Capability.ts");
117
- /* import */ var _performance_PerformanceTracker__rspack_import_2 = __webpack_require__("./src/capabilities/performance/PerformanceTracker.ts");
118
- /* import */ var _tracing_CallTraceManager__rspack_import_1 = __webpack_require__("./src/capabilities/tracing/CallTraceManager.ts");
119
- /* import */ var _utilities__rspack_import_3 = __webpack_require__("./src/utilities/logger.ts");
120
-
121
-
122
-
123
-
124
-
125
- class PerformanceCapability extends _Capability__rspack_import_0.Capability {
126
- callTraceManager;
127
- performanceTracker;
128
- filter;
129
- childDurations = new Map();
130
- constructor(options) {
131
- super();
132
- this.filter = options?.filter ?? (() => true);
133
- this.callTraceManager = new _tracing_CallTraceManager__rspack_import_1.CallTraceManager();
134
- this.performanceTracker = new _performance_PerformanceTracker__rspack_import_2.PerformanceTracker();
135
- }
136
- apply(instance) {
137
- this.explore(instance, (meta, info) => {
138
- if (info.isCallable) {
139
- const originalMethod = meta.instance[info.name].bind(meta.instance);
140
- meta.instance[info.name] = (...args) => {
141
- const path = `${meta.path}.${String(info.name)}()`;
142
- if (this.filter(path, info, meta) === false) {
143
- return originalMethod(...args);
144
- }
145
- const isNewOperation = this.callTraceManager.isNewOperation();
146
- let operationId;
147
- let callTrace;
495
+ // EXTERNAL MODULE: ./src/utilities/strings.ts
496
+ var strings = __webpack_require__(615);
497
+ ;// CONCATENATED MODULE: ./src/capabilities/performance/PerformanceTracker.ts
498
+ class PerformanceTracker {
499
+ methodTimings = new Map();
500
+ operationStartTimes = new Map();
501
+ startMethodTiming(operationId, methodPath) {
502
+ const startTime = performance.now();
503
+ const key = `${operationId}:${methodPath}`;
504
+ // Track operation start time for delta calculations
505
+ if (!this.operationStartTimes.has(operationId)) {
506
+ this.operationStartTimes.set(operationId, startTime);
507
+ }
508
+ this.methodTimings.set(key, {
509
+ startTime
510
+ });
511
+ return startTime;
512
+ }
513
+ recordNextMethodStart(operationId, methodPath) {
514
+ const key = `${operationId}:${methodPath}`;
515
+ const timing = this.methodTimings.get(key);
516
+ if (timing) {
517
+ timing.nextMethodStartTime = performance.now();
518
+ }
519
+ }
520
+ endMethodTiming(operationId, methodPath) {
521
+ const endTime = performance.now();
522
+ const key = `${operationId}:${methodPath}`;
523
+ const timing = this.methodTimings.get(key);
524
+ if (!timing) {
525
+ return {
526
+ startTime: endTime
527
+ };
528
+ }
529
+ const duration = endTime - timing.startTime;
530
+ const timeToNextCall = timing.nextMethodStartTime ? timing.nextMethodStartTime - timing.startTime : undefined;
531
+ // Clean up
532
+ this.methodTimings.delete(key);
533
+ return {
534
+ startTime: timing.startTime,
535
+ endTime,
536
+ duration,
537
+ nextMethodStartTime: timing.nextMethodStartTime,
538
+ timeToNextCall
539
+ };
540
+ }
541
+ formatDuration(milliseconds) {
542
+ if (milliseconds < 1) {
543
+ return `${(milliseconds * 1000).toFixed(1)}μs`;
544
+ } else if (milliseconds < 1000) {
545
+ return `${milliseconds.toFixed(2)}ms`;
546
+ } else {
547
+ return `${(milliseconds / 1000).toFixed(2)}s`;
548
+ }
549
+ }
550
+ getDeltaFromOperationStart(operationId, currentTime) {
551
+ const operationStartTime = this.operationStartTimes.get(operationId);
552
+ return operationStartTime ? currentTime - operationStartTime : 0;
553
+ }
554
+ cleanupOperation(operationId) {
555
+ this.operationStartTimes.delete(operationId);
556
+ }
557
+ }
558
+
559
+ // EXTERNAL MODULE: ./src/utilities/uuid.ts
560
+ var uuid = __webpack_require__(618);
561
+ ;// CONCATENATED MODULE: ./src/capabilities/tracing/CallTraceManager.ts
562
+
563
+ class CallTraceManager {
564
+ activeOperationId = null;
565
+ activeCallStack = [];
566
+ startNewOperation() {
567
+ const operationId = (0,uuid/* .uuid */.u)(8);
568
+ this.activeOperationId = operationId;
569
+ this.activeCallStack = [];
570
+ return operationId;
571
+ }
572
+ isNewOperation() {
573
+ return this.activeOperationId === null;
574
+ }
575
+ getActiveOperationId() {
576
+ if (!this.activeOperationId) {
577
+ throw new Error('No active operation context');
578
+ }
579
+ return this.activeOperationId;
580
+ }
581
+ addMethodToTrace(methodPath) {
582
+ if (this.isNewOperation()) {
583
+ this.activeCallStack = [
584
+ methodPath
585
+ ];
586
+ } else {
587
+ this.activeCallStack.push(methodPath);
588
+ }
589
+ return [
590
+ ...this.activeCallStack
591
+ ];
592
+ }
593
+ removeMethodFromTrace() {
594
+ if (!this.isNewOperation()) {
595
+ this.activeCallStack.pop();
596
+ }
597
+ }
598
+ endOperation() {
599
+ this.activeOperationId = null;
600
+ this.activeCallStack = [];
601
+ }
602
+ formatMethodPaths(methodPaths) {
603
+ return methodPaths.map((path)=>path.replace(/ → /g, '.'));
604
+ }
605
+ getCurrentTrace() {
606
+ return [
607
+ ...this.activeCallStack
608
+ ];
609
+ }
610
+ }
611
+
612
+ // EXTERNAL MODULE: ./src/utilities/logger.ts
613
+ var logger = __webpack_require__(581);
614
+ ;// CONCATENATED MODULE: ./src/capabilities/PerformanceCapability.ts
615
+
616
+
617
+
618
+
619
+
620
+ class PerformanceCapability extends Capability {
621
+ callTraceManager;
622
+ performanceTracker;
623
+ filter;
624
+ childDurations = new Map();
625
+ constructor(options){
626
+ super();
627
+ this.filter = options?.filter ?? (()=>true);
628
+ this.callTraceManager = new CallTraceManager();
629
+ this.performanceTracker = new PerformanceTracker();
630
+ }
631
+ apply(instance) {
632
+ this.explore(instance, (meta, info)=>{
633
+ if (info.isCallable) {
634
+ const originalMethod = meta.instance[info.name].bind(meta.instance);
635
+ meta.instance[info.name] = (...args)=>{
636
+ const path = `${meta.path}.${String(info.name)}()`;
637
+ if (this.filter(path, info, meta) === false) {
638
+ return originalMethod(...args);
639
+ }
640
+ const isNewOperation = this.callTraceManager.isNewOperation();
641
+ let operationId;
642
+ let callTrace;
148
643
  let depth;
149
644
  if (isNewOperation) {
150
645
  operationId = this.callTraceManager.startNewOperation();
@@ -153,14 +648,13 @@ class PerformanceCapability extends _Capability__rspack_import_0.Capability {
153
648
  depth = callTrace.length - 1;
154
649
  const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);
155
650
  this.performanceTracker.startMethodTiming(operationId, path);
156
- _utilities__rspack_import_3.logger.log(`\n${'═'.repeat(60)}`);
157
- _utilities__rspack_import_3.logger.log(`▶ ORIGIN [${operationId}] ${path}`);
651
+ logger/* .logger.log */.vF.log(`\n${'═'.repeat(60)}`);
652
+ logger/* .logger.log */.vF.log(`▶ ORIGIN [${operationId}] ${path}`);
158
653
  if (args.length > 0) {
159
- _utilities__rspack_import_3.logger.log(` Args:`, (0,_utilities__rspack_import_4.stringifyObject)(args, 4, 0));
654
+ logger/* .logger.log */.vF.log(` Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
160
655
  }
161
- _utilities__rspack_import_3.logger.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);
162
- }
163
- else {
656
+ logger/* .logger.log */.vF.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);
657
+ } else {
164
658
  operationId = this.callTraceManager.getActiveOperationId();
165
659
  callTrace = this.callTraceManager.addMethodToTrace(path);
166
660
  depth = callTrace.length - 1;
@@ -169,47 +663,45 @@ class PerformanceCapability extends _Capability__rspack_import_0.Capability {
169
663
  const childMethodKey = `${operationId}:${path}`;
170
664
  this.childDurations.set(childMethodKey, []);
171
665
  this.performanceTracker.startMethodTiming(operationId, path);
172
- _utilities__rspack_import_3.logger.log(`${indent}└─ CHILD [${operationId}] ${path}`);
666
+ logger/* .logger.log */.vF.log(`${indent}└─ CHILD [${operationId}] ${path}`);
173
667
  if (args.length > 0) {
174
- _utilities__rspack_import_3.logger.log(`${indent} Args:`, (0,_utilities__rspack_import_4.stringifyObject)(args, 4, 0));
668
+ logger/* .logger.log */.vF.log(`${indent} Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
175
669
  }
176
670
  }
177
671
  try {
178
672
  return originalMethod(...args);
179
- }
180
- finally {
673
+ } finally{
181
674
  const metrics = this.performanceTracker.endMethodTiming(operationId, path);
182
675
  const duration = metrics.duration ?? 0;
183
676
  const formattedDuration = this.performanceTracker.formatDuration(duration);
184
677
  if (isNewOperation) {
185
678
  const childDurations = this.childDurations.get(operationId) ?? [];
186
- const totalChildTime = childDurations.reduce((sum, d) => sum + d, 0);
679
+ const totalChildTime = childDurations.reduce((sum, d)=>sum + d, 0);
187
680
  const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);
188
681
  const overhead = duration - totalChildTime;
189
682
  const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));
190
- _utilities__rspack_import_3.logger.log(`\n${'═'.repeat(60)}`);
191
- _utilities__rspack_import_3.logger.log(`◀ COMPLETE [${operationId}] ${path}`);
192
- _utilities__rspack_import_3.logger.log(` Total Duration: ${formattedDuration}`);
683
+ logger/* .logger.log */.vF.log(`\n${'═'.repeat(60)}`);
684
+ logger/* .logger.log */.vF.log(`◀ COMPLETE [${operationId}] ${path}`);
685
+ logger/* .logger.log */.vF.log(` Total Duration: ${formattedDuration}`);
193
686
  if (childDurations.length > 0) {
194
- _utilities__rspack_import_3.logger.log(` Children Duration: ${formattedTotalChildTime} (${childDurations.length} calls)`);
195
- _utilities__rspack_import_3.logger.log(` Overhead: ${formattedOverhead}`);
687
+ logger/* .logger.log */.vF.log(` Children Duration: ${formattedTotalChildTime} (${childDurations.length} calls)`);
688
+ logger/* .logger.log */.vF.log(` Overhead: ${formattedOverhead}`);
196
689
  }
197
- _utilities__rspack_import_3.logger.log(`${'═'.repeat(60)}\n`);
690
+ logger/* .logger.log */.vF.log(`${'═'.repeat(60)}\n`);
198
691
  this.childDurations.delete(operationId);
199
692
  this.performanceTracker.cleanupOperation(operationId);
200
693
  this.callTraceManager.endOperation();
201
- }
202
- else {
694
+ } else {
203
695
  const indent = ' '.repeat(Math.min(depth, 4));
204
696
  const childMethodKey = `${operationId}:${path}`;
205
697
  const childDurations = this.childDurations.get(childMethodKey) ?? [];
206
- const totalChildTime = childDurations.reduce((sum, d) => sum + d, 0);
698
+ const totalChildTime = childDurations.reduce((sum, d)=>sum + d, 0);
207
699
  const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);
208
700
  const overhead = duration - totalChildTime;
209
701
  const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));
210
- _utilities__rspack_import_3.logger.log(`${indent} ✓ ${formattedDuration}`);
702
+ logger/* .logger.log */.vF.log(`${indent} ✓ ${formattedDuration}`);
211
703
  if (childDurations.length > 0) {
212
- _utilities__rspack_import_3.logger.log(`${indent} Children: ${formattedTotalChildTime} (${childDurations.length} calls), Overhead: ${formattedOverhead}`);
704
+ logger/* .logger.log */.vF.log(`${indent} Children: ${formattedTotalChildTime} (${childDurations.length} calls), Overhead: ${formattedOverhead}`);
213
705
  }
214
706
  // Clean up child method tracking
215
707
  this.childDurations.delete(childMethodKey);
@@ -226,8 +718,7 @@ class PerformanceCapability extends _Capability__rspack_import_0.Capability {
226
718
  if (rootChildDurations) {
227
719
  rootChildDurations.push(duration);
228
720
  }
229
- }
230
- else {
721
+ } else {
231
722
  // Nested child - add to parent method's children list
232
723
  const parentMethodKey = `${operationId}:${parentPath}`;
233
724
  const parentChildDurations = this.childDurations.get(parentMethodKey);
@@ -245,32 +736,23 @@ class PerformanceCapability extends _Capability__rspack_import_0.Capability {
245
736
  }
246
737
  }
247
738
 
248
-
249
- },
250
- "./src/capabilities/TracingCapability.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
251
- __webpack_require__.r(__webpack_exports__);
252
- __webpack_require__.d(__webpack_exports__, {
253
- TracingCapability: () => (TracingCapability)
254
- });
255
- /* import */ var _Capability__rspack_import_0 = __webpack_require__("./src/capabilities/Capability.ts");
256
- /* import */ var _tracing_CallTraceManager__rspack_import_1 = __webpack_require__("./src/capabilities/tracing/CallTraceManager.ts");
257
- /* import */ var _utilities_strings__rspack_import_2 = __webpack_require__("./src/utilities/strings.ts");
739
+ ;// CONCATENATED MODULE: ./src/capabilities/TracingCapability.ts
258
740
 
259
741
 
260
742
 
261
- class TracingCapability extends _Capability__rspack_import_0.Capability {
743
+ class TracingCapability extends Capability {
262
744
  callTraceManager;
263
745
  filter;
264
- constructor(options) {
746
+ constructor(options){
265
747
  super();
266
- this.filter = options?.filter ?? (() => true);
267
- this.callTraceManager = new _tracing_CallTraceManager__rspack_import_1.CallTraceManager();
748
+ this.filter = options?.filter ?? (()=>true);
749
+ this.callTraceManager = new CallTraceManager();
268
750
  }
269
751
  apply(instance) {
270
- this.explore(instance, (meta, info) => {
752
+ this.explore(instance, (meta, info)=>{
271
753
  if (info.isCallable) {
272
754
  const originalMethod = meta.instance[info.name].bind(meta.instance);
273
- meta.instance[info.name] = (...args) => {
755
+ meta.instance[info.name] = (...args)=>{
274
756
  const path = `${meta.path}.${String(info.name)}()`;
275
757
  if (this.filter(path, info, meta) === false) {
276
758
  return originalMethod(...args);
@@ -284,23 +766,21 @@ class TracingCapability extends _Capability__rspack_import_0.Capability {
284
766
  console.log(`\n${'═'.repeat(60)}`);
285
767
  console.log(`▶ ORIGIN [${operationId}] ${path}`);
286
768
  if (args.length > 0) {
287
- console.log(` Args:`, (0,_utilities_strings__rspack_import_2.stringifyObject)(args, 4, 0));
769
+ console.log(` Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
288
770
  }
289
771
  console.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);
290
- }
291
- else {
772
+ } else {
292
773
  operationId = this.callTraceManager.getActiveOperationId();
293
774
  const callTrace = this.callTraceManager.addMethodToTrace(path);
294
775
  const indent = ' '.repeat(Math.min(callTrace.length - 1, 4));
295
776
  console.log(`${indent}└─ CHILD [${operationId}] ${path}`);
296
777
  if (args.length > 0) {
297
- console.log(`${indent} Args:`, (0,_utilities_strings__rspack_import_2.stringifyObject)(args, 4, 0));
778
+ console.log(`${indent} Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
298
779
  }
299
780
  }
300
781
  try {
301
782
  return originalMethod(...args);
302
- }
303
- finally {
783
+ } finally{
304
784
  this.callTraceManager.removeMethodFromTrace();
305
785
  if (isNewOperation) {
306
786
  this.callTraceManager.endOperation();
@@ -312,461 +792,7 @@ class TracingCapability extends _Capability__rspack_import_0.Capability {
312
792
  }
313
793
  }
314
794
 
315
-
316
- },
317
- "./src/capabilities/performance/PerformanceTracker.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
318
- __webpack_require__.r(__webpack_exports__);
319
- __webpack_require__.d(__webpack_exports__, {
320
- PerformanceTracker: () => (PerformanceTracker)
321
- });
322
- class PerformanceTracker {
323
- methodTimings = new Map();
324
- operationStartTimes = new Map();
325
- startMethodTiming(operationId, methodPath) {
326
- const startTime = performance.now();
327
- const key = `${operationId}:${methodPath}`;
328
- // Track operation start time for delta calculations
329
- if (!this.operationStartTimes.has(operationId)) {
330
- this.operationStartTimes.set(operationId, startTime);
331
- }
332
- this.methodTimings.set(key, { startTime });
333
- return startTime;
334
- }
335
- recordNextMethodStart(operationId, methodPath) {
336
- const key = `${operationId}:${methodPath}`;
337
- const timing = this.methodTimings.get(key);
338
- if (timing) {
339
- timing.nextMethodStartTime = performance.now();
340
- }
341
- }
342
- endMethodTiming(operationId, methodPath) {
343
- const endTime = performance.now();
344
- const key = `${operationId}:${methodPath}`;
345
- const timing = this.methodTimings.get(key);
346
- if (!timing) {
347
- return { startTime: endTime };
348
- }
349
- const duration = endTime - timing.startTime;
350
- const timeToNextCall = timing.nextMethodStartTime ?
351
- timing.nextMethodStartTime - timing.startTime : undefined;
352
- // Clean up
353
- this.methodTimings.delete(key);
354
- return {
355
- startTime: timing.startTime,
356
- endTime,
357
- duration,
358
- nextMethodStartTime: timing.nextMethodStartTime,
359
- timeToNextCall
360
- };
361
- }
362
- formatDuration(milliseconds) {
363
- if (milliseconds < 1) {
364
- return `${(milliseconds * 1000).toFixed(1)}μs`;
365
- }
366
- else if (milliseconds < 1000) {
367
- return `${milliseconds.toFixed(2)}ms`;
368
- }
369
- else {
370
- return `${(milliseconds / 1000).toFixed(2)}s`;
371
- }
372
- }
373
- getDeltaFromOperationStart(operationId, currentTime) {
374
- const operationStartTime = this.operationStartTimes.get(operationId);
375
- return operationStartTime ? currentTime - operationStartTime : 0;
376
- }
377
- cleanupOperation(operationId) {
378
- this.operationStartTimes.delete(operationId);
379
- }
380
- }
381
-
382
-
383
- },
384
- "./src/capabilities/tracing/CallTraceManager.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
385
- __webpack_require__.r(__webpack_exports__);
386
- __webpack_require__.d(__webpack_exports__, {
387
- CallTraceManager: () => (CallTraceManager)
388
- });
389
- /* import */ var _utilities__rspack_import_0 = __webpack_require__("./src/utilities/uuid.ts");
390
-
391
- class CallTraceManager {
392
- activeOperationId = null;
393
- activeCallStack = [];
394
- startNewOperation() {
395
- const operationId = (0,_utilities__rspack_import_0.uuid)(8);
396
- this.activeOperationId = operationId;
397
- this.activeCallStack = [];
398
- return operationId;
399
- }
400
- isNewOperation() {
401
- return this.activeOperationId === null;
402
- }
403
- getActiveOperationId() {
404
- if (!this.activeOperationId) {
405
- throw new Error('No active operation context');
406
- }
407
- return this.activeOperationId;
408
- }
409
- addMethodToTrace(methodPath) {
410
- if (this.isNewOperation()) {
411
- this.activeCallStack = [methodPath];
412
- }
413
- else {
414
- this.activeCallStack.push(methodPath);
415
- }
416
- return [...this.activeCallStack];
417
- }
418
- removeMethodFromTrace() {
419
- if (!this.isNewOperation()) {
420
- this.activeCallStack.pop();
421
- }
422
- }
423
- endOperation() {
424
- this.activeOperationId = null;
425
- this.activeCallStack = [];
426
- }
427
- formatMethodPaths(methodPaths) {
428
- return methodPaths.map(path => path.replace(/ → /g, '.'));
429
- }
430
- getCurrentTrace() {
431
- return [...this.activeCallStack];
432
- }
433
- }
434
-
435
-
436
- },
437
- "./src/utilities/logger.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
438
- __webpack_require__.r(__webpack_exports__);
439
- __webpack_require__.d(__webpack_exports__, {
440
- logger: () => (logger)
441
- });
442
- /**
443
- * Enable logging by setting `globalThis.__ROUTIER_DEBUG__ = true` before any routier code runs.
444
- */
445
- const shouldLog = () => {
446
- if (typeof globalThis !== 'undefined') {
447
- const g = globalThis;
448
- if (g.__ROUTIER_DEBUG__ === true)
449
- return true;
450
- }
451
- if (typeof process !== 'undefined' && process.env != null) {
452
- const debug = process.env.DEBUG;
453
- if (debug === 'routier' || debug === '*')
454
- return true;
455
- const env = "development"?.toLowerCase();
456
- if (env === 'dev' || env === 'development' || env === 'test')
457
- return true;
458
- }
459
- return false;
460
- };
461
- const tryLog = (type, ...args) => {
462
- if (shouldLog()) {
463
- console[type](...args);
464
- }
465
- };
466
- const logger = {
467
- log: (...args) => {
468
- tryLog("log", ...args);
469
- },
470
- info: (...args) => {
471
- tryLog("info", ...args);
472
- },
473
- warn: (...args) => {
474
- tryLog("warn", ...args);
475
- },
476
- error: (...args) => {
477
- tryLog("error", ...args);
478
- },
479
- debug: (...args) => {
480
- tryLog("debug", ...args);
481
- },
482
- table: (...args) => {
483
- tryLog("table", ...args);
484
- },
485
- };
486
-
487
-
488
- },
489
- "./src/utilities/strings.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
490
- __webpack_require__.r(__webpack_exports__);
491
- __webpack_require__.d(__webpack_exports__, {
492
- fastHash: () => (fastHash),
493
- hash: () => (hash),
494
- stringifyObject: () => (stringifyObject)
495
- });
496
- const hash = (value, seed = 0) => {
497
- // From Stack Overflow
498
- // https://stackoverflow.com/a/52171480/3329760
499
- let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
500
- for (let i = 0, ch; i < value.length; i++) {
501
- ch = value.charCodeAt(i);
502
- h1 = Math.imul(h1 ^ ch, 2654435761);
503
- h2 = Math.imul(h2 ^ ch, 1597334677);
504
- }
505
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
506
- h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
507
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
508
- h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
509
- return 4294967296 * (2097151 & h2) + (h1 >>> 0);
510
- };
511
- /**
512
- * Fast string hash optimized for comparisons.
513
- * Uses djb2 algorithm - very fast and good distribution for short to medium strings.
514
- * Same input always produces same output (deterministic).
515
- *
516
- * @param value - The string to hash
517
- * @param seed - Optional seed value (default: 5381)
518
- * @returns A positive 32-bit integer hash value
519
- *
520
- * @example
521
- * ```ts
522
- * fastHash("test") === fastHash("test") // true
523
- * fastHash("test") !== fastHash("test2") // true
524
- * ```
525
- */
526
- const fastHash = (value, seed = 5381) => {
527
- let hash = seed;
528
- for (let i = 0; i < value.length; i++) {
529
- hash = ((hash << 5) + hash) + value.charCodeAt(i);
530
- }
531
- return hash >>> 0; // Convert to unsigned 32-bit integer
532
- };
533
- /**
534
- * Converts any value to a readable string representation.
535
- * Handles primitives, objects, arrays, classes, dates, errors, and functions.
536
- * Supports depth limiting to prevent infinite recursion on circular references.
537
- *
538
- * @param obj - The value to stringify
539
- * @param maxDepth - Maximum depth for nested objects (default: 3)
540
- * @param currentDepth - Current recursion depth (default: 0)
541
- * @returns String representation of the value
542
- *
543
- * @example
544
- * ```ts
545
- * stringifyObject({ name: "test", count: 5 }) // '{ name: "test", count: 5 }'
546
- * stringifyObject([1, 2, 3]) // '[1, 2, 3]'
547
- * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'
548
- * ```
549
- */
550
- function stringifyObject(obj, maxDepth = 3, currentDepth = 0) {
551
- if (obj === null)
552
- return 'null';
553
- if (obj === undefined)
554
- return 'undefined';
555
- const type = typeof obj;
556
- switch (type) {
557
- case 'string':
558
- return `"${obj}"`;
559
- case 'number':
560
- case 'boolean':
561
- return String(obj);
562
- case 'function':
563
- return `[Function: ${getFunctionName(obj)}]`;
564
- case 'object':
565
- if (currentDepth >= maxDepth) {
566
- return '[Max Depth Reached]';
567
- }
568
- return stringifyObjectValue(obj, maxDepth, currentDepth);
569
- default:
570
- return `[${type}]`;
571
- }
572
- }
573
- function getFunctionName(fn) {
574
- const name = fn.name;
575
- return name || 'anonymous';
576
- }
577
- function getObjectProperties(obj) {
578
- const properties = {};
579
- for (const key in obj) {
580
- if (obj.hasOwnProperty(key)) {
581
- properties[key] = obj[key];
582
- }
583
- }
584
- return properties;
585
- }
586
- function stringifyObjectValue(obj, maxDepth, currentDepth) {
587
- if (obj === null)
588
- return 'null';
589
- if (obj instanceof Date) {
590
- return `Date(${obj.toISOString()})`;
591
- }
592
- if (obj instanceof Error) {
593
- return `Error(${obj.message})`;
594
- }
595
- if (obj instanceof RegExp) {
596
- return obj.toString();
597
- }
598
- if (Array.isArray(obj)) {
599
- return stringifyArray(obj, maxDepth, currentDepth);
600
- }
601
- if (obj.constructor && obj.constructor.name !== 'Object') {
602
- return stringifyClassInstance(obj, maxDepth, currentDepth);
603
- }
604
- return stringifyPlainObject(obj, maxDepth, currentDepth);
605
- }
606
- function stringifyArray(arr, maxDepth, currentDepth) {
607
- if (arr.length === 0)
608
- return '[]';
609
- const items = arr.slice(0, 5).map(item => stringifyObject(item, maxDepth, currentDepth + 1));
610
- const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';
611
- return `[${items.join(', ')}${suffix}]`;
612
- }
613
- function stringifyClassInstance(obj, maxDepth, currentDepth) {
614
- const className = obj.constructor.name;
615
- const properties = getObjectProperties(obj);
616
- if (Object.keys(properties).length === 0) {
617
- return `${className} {}`;
618
- }
619
- const props = Object.entries(properties)
620
- .slice(0, 5)
621
- .map(([key, value]) => {
622
- const isPrimitive = value === null || value === undefined ||
623
- (typeof value !== 'object' && typeof value !== 'function');
624
- const depth = isPrimitive ? currentDepth : currentDepth + 1;
625
- return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
626
- });
627
- const suffix = Object.keys(properties).length > 5 ?
628
- `... (+${Object.keys(properties).length - 5} more)` : '';
629
- return `${className} { ${props.join(', ')}${suffix} }`;
630
- }
631
- function stringifyPlainObject(obj, maxDepth, currentDepth) {
632
- const properties = getObjectProperties(obj);
633
- if (Object.keys(properties).length === 0) {
634
- return '{}';
635
- }
636
- const props = Object.entries(properties)
637
- .slice(0, 5)
638
- .map(([key, value]) => {
639
- const isPrimitive = value === null || value === undefined ||
640
- (typeof value !== 'object' && typeof value !== 'function');
641
- const depth = isPrimitive ? currentDepth : currentDepth + 1;
642
- return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
643
- });
644
- const suffix = Object.keys(properties).length > 5 ?
645
- `... (+${Object.keys(properties).length - 5} more)` : '';
646
- return `{ ${props.join(', ')}${suffix} }`;
647
- }
648
-
649
-
650
- },
651
- "./src/utilities/uuid.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
652
- __webpack_require__.r(__webpack_exports__);
653
- __webpack_require__.d(__webpack_exports__, {
654
- uuid: () => (uuid),
655
- uuidv4: () => (uuidv4)
656
- });
657
- const uuid = (length = 16) => {
658
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
659
- const charLength = chars.length;
660
- let result = '';
661
- for (let i = 0; i < length; i++) {
662
- result += chars[Math.random() * charLength | 0];
663
- }
664
- return result;
665
- };
666
- const HEX_CHARS = '0123456789abcdef';
667
- const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
668
- const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
669
- const uuidv4 = () => {
670
- let randomBytes = null;
671
- if (hasCrypto) {
672
- randomBytes = crypto.getRandomValues(new Uint8Array(16));
673
- }
674
- let byteIndex = 0;
675
- let uuid = '';
676
- for (let i = 0; i < UUID_TEMPLATE.length; i++) {
677
- const c = UUID_TEMPLATE[i];
678
- if (c === '-') {
679
- uuid += '-';
680
- continue;
681
- }
682
- let r;
683
- if (hasCrypto && randomBytes) {
684
- // Each byte gives two hex digits (nibbles)
685
- r =
686
- (i % 2 === 0
687
- ? randomBytes[byteIndex] >> 4
688
- : randomBytes[byteIndex++] & 0x0f);
689
- }
690
- else {
691
- r = Math.floor(Math.random() * 16);
692
- }
693
- if (c === 'x') {
694
- uuid += HEX_CHARS[r];
695
- }
696
- else if (c === 'y') {
697
- // Variant bits: 8, 9, A, or B
698
- uuid += HEX_CHARS[(r & 0x3) | 0x8];
699
- }
700
- else if (c === '4') {
701
- uuid += '4';
702
- }
703
- }
704
- return uuid;
705
- };
706
-
707
-
708
- },
709
-
710
- });
711
- // The module cache
712
- var __webpack_module_cache__ = {};
713
-
714
- // The require function
715
- function __webpack_require__(moduleId) {
716
-
717
- // Check if module is in cache
718
- var cachedModule = __webpack_module_cache__[moduleId];
719
- if (cachedModule !== undefined) {
720
- return cachedModule.exports;
721
- }
722
- // Create a new module (and put it into the cache)
723
- var module = (__webpack_module_cache__[moduleId] = {
724
- exports: {}
725
- });
726
- // Execute the module function
727
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
728
-
729
- // Return the exports of the module
730
- return module.exports;
731
-
732
- }
733
-
734
- // webpack/runtime/define_property_getters
735
- (() => {
736
- __webpack_require__.d = (exports, definition) => {
737
- for(var key in definition) {
738
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
739
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
740
- }
741
- }
742
- };
743
- })();
744
- // webpack/runtime/has_own_property
745
- (() => {
746
- __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
747
- })();
748
- // webpack/runtime/make_namespace_object
749
- (() => {
750
- // define __esModule on exports
751
- __webpack_require__.r = (exports) => {
752
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
753
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
754
- }
755
- Object.defineProperty(exports, '__esModule', { value: true });
756
- };
757
- })();
758
- var __webpack_exports__ = {};
759
- // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
760
- (() => {
761
- __webpack_require__.r(__webpack_exports__);
762
- __webpack_require__.d(__webpack_exports__, {
763
- Capability: () => (/* reexport safe */ _Capability__rspack_import_0.Capability),
764
- PerformanceCapability: () => (/* reexport safe */ _PerformanceCapability__rspack_import_1.PerformanceCapability),
765
- TracingCapability: () => (/* reexport safe */ _TracingCapability__rspack_import_2.TracingCapability)
766
- });
767
- /* import */ var _Capability__rspack_import_0 = __webpack_require__("./src/capabilities/Capability.ts");
768
- /* import */ var _PerformanceCapability__rspack_import_1 = __webpack_require__("./src/capabilities/PerformanceCapability.ts");
769
- /* import */ var _TracingCapability__rspack_import_2 = __webpack_require__("./src/capabilities/TracingCapability.ts");
795
+ ;// CONCATENATED MODULE: ./src/capabilities/index.ts
770
796
 
771
797
 
772
798
 
@@ -774,9 +800,9 @@ __webpack_require__.d(__webpack_exports__, {
774
800
 
775
801
  })();
776
802
 
777
- var __webpack_exports__Capability = __webpack_exports__.Capability;
778
- var __webpack_exports__PerformanceCapability = __webpack_exports__.PerformanceCapability;
779
- var __webpack_exports__TracingCapability = __webpack_exports__.TracingCapability;
803
+ var __webpack_exports__Capability = __webpack_exports__.nS;
804
+ var __webpack_exports__PerformanceCapability = __webpack_exports__.VP;
805
+ var __webpack_exports__TracingCapability = __webpack_exports__.XO;
780
806
  export { __webpack_exports__Capability as Capability, __webpack_exports__PerformanceCapability as PerformanceCapability, __webpack_exports__TracingCapability as TracingCapability };
781
807
 
782
808
  //# sourceMappingURL=index.js.map