@oxog/utils 1.0.0 → 1.1.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/CHANGELOG.md +72 -0
  2. package/README.md +101 -43
  3. package/dist/chunk-25WW2FCA.js +34 -0
  4. package/dist/chunk-25WW2FCA.js.map +1 -0
  5. package/dist/chunk-DEVWOLUI.cjs +112 -0
  6. package/dist/chunk-DEVWOLUI.cjs.map +1 -0
  7. package/dist/chunk-IUDFQZIP.js +99 -0
  8. package/dist/chunk-IUDFQZIP.js.map +1 -0
  9. package/dist/chunk-PZ5AY32C.js +9 -0
  10. package/dist/chunk-PZ5AY32C.js.map +1 -0
  11. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  12. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  13. package/dist/chunk-SWG777R6.cjs +40 -0
  14. package/dist/chunk-SWG777R6.cjs.map +1 -0
  15. package/dist/index.cjs +482 -191
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +288 -15
  18. package/dist/index.d.ts +288 -15
  19. package/dist/index.js +428 -186
  20. package/dist/index.js.map +1 -1
  21. package/dist/plugins/async.cjs +90 -107
  22. package/dist/plugins/async.cjs.map +1 -1
  23. package/dist/plugins/async.d.cts +19 -6
  24. package/dist/plugins/async.d.ts +19 -6
  25. package/dist/plugins/async.js +89 -106
  26. package/dist/plugins/async.js.map +1 -1
  27. package/dist/plugins/deep.cjs +183 -59
  28. package/dist/plugins/deep.cjs.map +1 -1
  29. package/dist/plugins/deep.d.cts +25 -7
  30. package/dist/plugins/deep.d.ts +25 -7
  31. package/dist/plugins/deep.js +183 -59
  32. package/dist/plugins/deep.js.map +1 -1
  33. package/dist/plugins/guard.cjs +2 -0
  34. package/dist/plugins/guard.cjs.map +1 -1
  35. package/dist/plugins/guard.js +2 -0
  36. package/dist/plugins/guard.js.map +1 -1
  37. package/dist/plugins/transform.cjs +6 -3
  38. package/dist/plugins/transform.cjs.map +1 -1
  39. package/dist/plugins/transform.js +6 -3
  40. package/dist/plugins/transform.js.map +1 -1
  41. package/dist/{types-XmRC5wYO.d.cts → types-B-i5UbJo.d.cts} +24 -7
  42. package/dist/{types-XmRC5wYO.d.ts → types-B-i5UbJo.d.ts} +24 -7
  43. package/package.json +15 -10
package/CHANGELOG.md CHANGED
@@ -2,6 +2,78 @@
2
2
 
3
3
  All notable changes to @oxog/utils will be documented in this file.
4
4
 
5
+ ## [1.1.0] - 2026-11-30
6
+
7
+ ### Fixed
8
+ - **Security:** `setMut()` no longer pollutes `Object.prototype` (`setMut({}, '__proto__.x', 1)` added `x` to every object). `set()` and `setMut()` now throw `InvalidPathError` for paths containing `__proto__`, `constructor` or `prototype`.
9
+ - **Security:** `cloneDeep()` no longer turns an own `"__proto__"` key (e.g. from `JSON.parse`) into the clone's prototype; `groupBy`, `keyBy`, `mapKeys`, `mapValues`, `invert`, `pick` and `diff` store such keys as data. `mergeDeep()` skips `__proto__`/`constructor`/`prototype` at every nesting level.
10
+ - `chunk(arr, 0)` (or a negative/`NaN` size) looped forever and exhausted memory; it now returns `[]`. Fractional sizes are truncated.
11
+ - `groupBy()` threw `TypeError` for group names such as `"constructor"`, `"toString"` or `"__proto__"`.
12
+ - `has()` returned `true` for any path after an array index (`has(o, 'items[0].missing')`) and for out-of-range indexes; it now checks every segment and only own properties (`has({}, 'toString')` is `false`).
13
+ - `set()` converted arrays on the path into plain objects and did not support bracket indexes in the middle of a path (`set(o, 'items[0].id', 2)` created an `"items[0]"` key). `setMut()` gained bracket support too; missing containers are created as arrays for numeric bracket segments.
14
+ - `get()`/`template()` no longer expose prototypes (`get(o, '__proto__')`, `template('{{constructor}}', {})` printed `function Object() ...`).
15
+ - `cloneDeep()` crashed when used as an `Array#map` callback, turned typed arrays/`Buffer`s into plain objects, dropped class prototypes, symbol keys and `Error` messages. It now also clones `ArrayBuffer` and `DataView`, and returns `WeakMap`/`WeakSet`/`Promise` by reference.
16
+ - `mergeDeep()` did not replace `Date`/`Map`/`Set` values (the target value was kept) and overflowed the stack on circular sources.
17
+ - `isEqual()` reported `[]` equal to `{}`, a `Date`/`Map` equal to `{}`, `Map` equal to `Set`, ignored prototypes, symbol keys and `Error` messages, compared Set members by reference only, treated two invalid Dates as different and overflowed the stack on circular structures.
18
+ - `diff()` reported nothing when a nested object gained or lost keys or an array changed length; those changes are now reported as `{ from, to }`.
19
+ - `slugify()` dropped upper-case Cyrillic and Greek letters (`slugify('Привет мир')` returned `rivet-mir`, the documented result is `privet-mir`) and accented Greek letters.
20
+ - `truncate()` could cut an emoji in half, leaving a lone surrogate.
21
+ - `first(arr, n)` returned a single element instead of an array when only one element was available (`first([1], 5)` is now `[1]`, as documented); `last(arr, 0)` returned the whole array; negative counts are treated as 0 in `first`, `last` and `sample`.
22
+ - `debounce()`: `flush()` left `pending()` stuck at `true` and suppressed later leading calls; the wrapper returned `undefined` instead of the last result; the `maxWait` option was accepted but ignored; `trailing: false` was not honoured by `flush()`.
23
+ - `throttle()`: returned `undefined` instead of the last result, ignored `leading: false` after the first window, and `cancel()` did not reset the window.
24
+ - `retry()` discarded the last error; `MaxRetriesExceededError` now carries it as `cause` and exposes `attempts`.
25
+ - Error classes are no longer duplicated per entry point: a `TimeoutError` thrown by `@oxog/utils/async` is now `instanceof` the `TimeoutError` exported by `@oxog/utils` (ESM and CommonJS).
26
+ - `Kernel`: the `kernel:destroyed` event was emitted after all listeners had been removed; a failed `init()` left rolled-back plugins inactive on the next `init()`, and a circular-dependency failure left the kernel stuck in `initializing` so the next `init()` resolved without initializing anything.
27
+
28
+ ### Added
29
+ - `debounce(fn, wait, { maxWait })` is implemented; `throttle()` returns a function with `flush()`.
30
+ - `DebouncedFunction` and `ThrottledFunction` types are exported from `@oxog/utils/async`.
31
+ - `"./package.json"` is exported.
32
+
33
+ ### Changed
34
+ - Types: `mergeDeep()` accepts sources that are not `Partial<target>` and returns the intersection of target and sources (the README "Safe Deep Merging" example did not compile); `diff()` accepts a second object with extra keys (its own JSDoc example did not compile); `groupBy`/`keyBy` key functions may return numbers and `uniqBy` key functions any value; plugin hooks are declared as methods and `onInit`/`onDestroy` may return any value or promise (e.g. `onInit: (ctx) => ctx.db.connect()`). `cloneDeep()` no longer declares its internal second parameter.
35
+ - Behaviour you may notice: `set`/`setMut` throw for `__proto__`/`constructor`/`prototype` path segments; `has()` is own-property based; `isEqual()` returns `false` for values with different prototypes (a class instance vs. an equal-looking plain object); `first(arr, n)` returns an array whenever `n !== 1`; debounce/throttle never run a leading call in the same `wait` window as a trailing call.
36
+ - Build: tsup code splitting is enabled; `dist/` now contains shared `chunk-*` files.
37
+ - Tooling: ESLint 9 flat config (the old `.eslintrc.js` was ignored and `npm run lint` failed), lint covers tests, tests are type-checked, Jest coverage thresholds are enforced (c8 removed), `npm run test:package` verifies the packed archive, CI runs on Node 18-24, and a manual `publish.yml` publishes with npm trusted publishing.
38
+
39
+ ## [1.0.1] - 2026-01-25
40
+
41
+ ### Added
42
+ - **Plugin State Tracking**: New `PluginState` type (`registered`, `initializing`, `active`, `error`, `destroyed`)
43
+ - **Scoped Event Bus**: Automatic listener cleanup when plugins are unregistered
44
+ - `ScopedEventBus` class for plugin-specific event handling
45
+ - `EventBus.onScoped()`, `EventBus.removeScope()`, `EventBus.hasScope()` methods
46
+ - **Kernel Options**: Constructor now accepts `KernelOptions<TContext>` for initial context
47
+ - **New API Methods**:
48
+ - `kernel.getPluginState(name)` - Get plugin lifecycle state
49
+ - `kernel.getState()` - Get kernel state (`idle`, `initializing`, `initialized`, `destroyed`)
50
+ - `kernel.isInitialized()` - Check if kernel is initialized
51
+ - `kernel.getScopedEventBus(name)` - Get scoped event bus for a plugin
52
+ - **New Error Classes**:
53
+ - `CircularDependencyError` - Thrown when circular dependency detected
54
+ - `PluginInitializationError` - Thrown with cause when plugin init fails
55
+ - `KernelAlreadyInitializedError` - Thrown when kernel already initialized
56
+ - `KernelInitializingError` - Thrown for race condition prevention
57
+
58
+ ### Changed
59
+ - **BREAKING**: `kernel.unregister()` is now async and returns `Promise<void>`
60
+ - **Topological Sort**: Plugins now initialize in dependency order
61
+ - **Rollback Mechanism**: Failed initialization triggers rollback of already-initialized plugins
62
+ - **Race Condition Prevention**: Concurrent `init()` calls are now properly handled
63
+ - **Late Registration**: Plugins registered after `kernel.init()` are automatically initialized
64
+
65
+ ### Fixed
66
+ - Plugins registered after `kernel.init()` now have their `onInit` called
67
+ - Event listeners are automatically cleaned up when plugins are unregistered
68
+ - Circular dependencies are now detected and throw clear errors
69
+ - Partial initialization failures now properly rollback
70
+
71
+ ### Testing
72
+ - Added 23 new test cases for Kernel improvements
73
+ - Added 8 new test cases for ScopedEventBus
74
+ - Added 6 new test cases for new error classes
75
+ - Test coverage: 98.36% statements, 100% functions
76
+
5
77
  ## [1.0.0] - 2026-01-15
6
78
 
7
79
  ### Added
package/README.md CHANGED
@@ -6,18 +6,18 @@
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)
8
8
  [![Node](https://img.shields.io/badge/node-%3E%2018.0.0-green.svg)](https://nodejs.org/)
9
- [![Tests](https://img.shields.io/badge/tests-216%20passed-success.svg)](https://github.com/ersinkoc/utils)
9
+ [![CI](https://github.com/ersinkoc/Utils/actions/workflows/ci.yml/badge.svg)](https://github.com/ersinkoc/Utils/actions/workflows/ci.yml)
10
10
 
11
- Modern, tree-shakeable utility library for Node.js backend development with zero dependencies. Full TypeScript support with automatic type inference.
11
+ Modern, tree-shakeable utility library for Node.js backend development with zero dependencies. Written in TypeScript, shipped as ESM and CommonJS with type definitions for both.
12
12
 
13
13
  ## ✨ Features
14
14
 
15
15
  - 📦 **Zero dependencies** - No runtime dependencies
16
- - 🔒 **Type-safe** - Written in TypeScript with full type inference
16
+ - 🔒 **Typed** - Written in TypeScript; ESM + CommonJS builds with matching `.d.ts` / `.d.cts`
17
17
  - 🌳 **Tree-shakeable** - Import only what you need
18
18
  - 🛡️ **Secure** - Prototype pollution protection built-in
19
19
  - ⚡ **Performant** - Immutable by default, optimized for Node.js backends
20
- - 🧪 **Well-tested** - 216 tests with 100% success rate
20
+ - 🧪 **Well-tested** - coverage thresholds enforced in CI, packed archive verified for ESM, CJS and TypeScript
21
21
  - 📝 **LLM-native** - Designed for AI/LLM code generation
22
22
 
23
23
  ## 📦 Installation
@@ -83,10 +83,10 @@ import { compose, pipe, flip } from '@oxog/utils/transform';
83
83
 
84
84
  | Function | Description |
85
85
  |----------|-------------|
86
- | `get(obj, path, defaultValue?)` | Safe nested property access with type inference |
87
- | `set(obj, path, value)` | Immutable property setter |
88
- | `setMut(obj, path, value)` | Mutable property setter |
89
- | `has(obj, path)` | Check if path exists in object |
86
+ | `get(obj, path, defaultValue?)` | Safe nested property access (dot and `[0]` paths; returns `any`) |
87
+ | `set(obj, path, value)` | Immutable property setter (arrays stay arrays; throws `InvalidPathError` for `__proto__`/`constructor`/`prototype` segments) |
88
+ | `setMut(obj, path, value)` | Mutable property setter (same path rules as `set`) |
89
+ | `has(obj, path)` | Check if an own-property path exists (inherited keys and out-of-range indexes are `false`) |
90
90
  | `pick(obj, keys)` | Create object with specified keys |
91
91
  | `omit(obj, keys)` | Create object excluding specified keys |
92
92
  | `merge(target, ...sources)` | Safe shallow merge with prototype pollution protection |
@@ -101,14 +101,14 @@ import { compose, pipe, flip } from '@oxog/utils/transform';
101
101
  |----------|-------------|
102
102
  | `groupBy(arr, key)` | Group array items by property or function |
103
103
  | `keyBy(arr, key)` | Index array by property value |
104
- | `chunk(arr, size)` | Split array into chunks |
104
+ | `chunk(arr, size)` | Split array into chunks (`size < 1` returns `[]`) |
105
105
  | `uniq(arr)` | Remove duplicate values |
106
106
  | `uniqBy(arr, key)` | Remove duplicates by key |
107
107
  | `flatten(arr, depth?)` | Flatten nested arrays |
108
108
  | `compact(arr)` | Remove falsy values |
109
- | `first(arr, n?)` | Get first n elements |
110
- | `last(arr, n?)` | Get last n elements |
111
- | `sample(arr, n?)` | Get random sample(s) |
109
+ | `first(arr, n?)` | First element, or an array of the first `n` elements when `n !== 1` |
110
+ | `last(arr, n?)` | Last element, or an array of the last `n` elements when `n !== 1` |
111
+ | `sample(arr, n?)` | Array of `n` random elements (default 1) |
112
112
 
113
113
  ### String Utilities
114
114
 
@@ -119,28 +119,28 @@ import { compose, pipe, flip } from '@oxog/utils/transform';
119
119
  | `snakeCase(str)` | Convert to snake_case |
120
120
  | `pascalCase(str)` | Convert to PascalCase |
121
121
  | `capitalize(str)` | Capitalize first letter |
122
- | `truncate(str, length, suffix?)` | Truncate string to length |
123
- | `slugify(str)` | URL-safe slug with Turkish/Unicode support |
124
- | `template(str, data)` | String interpolation with `{{variable}}` |
122
+ | `truncate(str, length, suffix?)` | Keep `length` characters, then append `suffix` (never splits an emoji) |
123
+ | `slugify(str)` | URL-safe slug with Turkish, Cyrillic, Greek and accented-Latin transliteration |
124
+ | `template(str, data)` | String interpolation with `{{variable}}` / `{{a.b}}` (own properties only) |
125
125
 
126
126
  ### Deep Utilities (`@oxog/utils/deep`)
127
127
 
128
128
  | Function | Description |
129
129
  |----------|-------------|
130
- | `cloneDeep(obj)` | Deep clone with circular reference support |
131
- | `mergeDeep(target, ...sources)` | Deep merge with prototype pollution protection |
132
- | `isEqual(a, b)` | Deep equality comparison |
133
- | `diff(a, b)` | Get differences between two objects |
130
+ | `cloneDeep(obj)` | Deep clone: circular refs, Date, RegExp, Map, Set, typed arrays/Buffer, ArrayBuffer, DataView, Error; keeps prototypes |
131
+ | `mergeDeep(target, ...sources)` | Deep merge of plain objects (arrays, Dates, Maps... are replaced) with prototype pollution protection |
132
+ | `isEqual(a, b)` | Deep equality (type- and prototype-aware, deep Set/Map, circular refs, `NaN === NaN`) |
133
+ | `diff(a, b)` | `{ changed, added, removed }` between two objects |
134
134
 
135
135
  ### Async Utilities (`@oxog/utils/async`)
136
136
 
137
137
  | Function | Description |
138
138
  |----------|-------------|
139
- | `debounce(fn, wait, options?)` | Debounce function execution |
140
- | `throttle(fn, wait, options?)` | Throttle function execution |
139
+ | `debounce(fn, wait, options?)` | Debounce (`leading`, `trailing`, `maxWait`; `cancel`/`flush`/`pending`) |
140
+ | `throttle(fn, wait, options?)` | Throttle (`leading`, `trailing`; `cancel`/`flush`/`pending`) |
141
141
  | `sleep(ms)` | Sleep for specified milliseconds |
142
- | `retry(options)` | Retry function with backoff |
143
- | `timeout(promise, ms)` | Add timeout to promise |
142
+ | `retry(options)` | Retry with backoff; throws `MaxRetriesExceededError` with the last error as `cause` |
143
+ | `timeout(promise, ms)` | Reject with `TimeoutError` if `promise` does not settle in `ms` |
144
144
 
145
145
  ### Type Guards (`@oxog/utils/guard`)
146
146
 
@@ -166,6 +166,51 @@ import { compose, pipe, flip } from '@oxog/utils/transform';
166
166
  | `compose(...fns)` | Compose functions right-to-left |
167
167
  | `pipe(...fns)` | Compose functions left-to-right |
168
168
 
169
+ ### Kernel (Plugin System)
170
+
171
+ | Function/Class | Description |
172
+ |----------------|-------------|
173
+ | `Kernel<TContext>` | Micro-kernel for plugin management |
174
+ | `kernel.register(plugin)` | Register a plugin |
175
+ | `kernel.init()` | Initialize all plugins (async) |
176
+ | `kernel.unregister(name)` | Unregister a plugin (async) |
177
+ | `kernel.destroy()` | Destroy kernel and all plugins (async) |
178
+ | `kernel.getPluginState(name)` | Get plugin lifecycle state |
179
+ | `kernel.getScopedEventBus(name)` | Get scoped event bus for plugin |
180
+ | `ScopedEventBus` | Auto-cleanup event bus for plugins |
181
+
182
+ ```typescript
183
+ import { Kernel, type Plugin } from '@oxog/utils';
184
+
185
+ interface AppContext {
186
+ db: Database;
187
+ }
188
+
189
+ const kernel = new Kernel<AppContext>({
190
+ context: { db: myDatabase }
191
+ });
192
+
193
+ const loggerPlugin: Plugin<AppContext> = {
194
+ name: 'logger',
195
+ version: '1.0.0',
196
+ install: (kernel) => {
197
+ // Setup during registration
198
+ },
199
+ onInit: async (ctx) => {
200
+ // Async initialization
201
+ },
202
+ onDestroy: async () => {
203
+ // Cleanup on unregister
204
+ }
205
+ };
206
+
207
+ kernel.register(loggerPlugin);
208
+ await kernel.init();
209
+
210
+ // Plugin states: 'registered' | 'initializing' | 'active' | 'error' | 'destroyed'
211
+ console.log(kernel.getPluginState('logger')); // 'active'
212
+ ```
213
+
169
214
  ## 💡 Usage Examples
170
215
 
171
216
  ### Type-Safe Property Access
@@ -184,7 +229,7 @@ interface User {
184
229
 
185
230
  const user: User = { profile: { name: 'Ersin' } };
186
231
 
187
- // TypeScript infers return type automatically
232
+ // get() returns `any`: annotate the result you expect
188
233
  const theme: 'light' | 'dark' | undefined = get(user, 'profile.settings.theme');
189
234
  const updated = set(user, 'profile.settings.theme', 'dark' as const);
190
235
  ```
@@ -238,21 +283,20 @@ npm run test:watch
238
283
  npm run test:coverage
239
284
  ```
240
285
 
241
- - **216 tests** with 100% success rate
242
- - **99.41% statement coverage**
243
- - **100% function coverage**
244
- - **95.36% branch coverage**
286
+ Coverage thresholds (statements/lines 99.5%, branches 97%, functions 100%) are enforced by `npm run test:coverage`.
245
287
 
246
288
  ## 🔧 Scripts
247
289
 
248
290
  ```bash
249
- npm run build # Build the project
250
- npm test # Run tests
251
- npm run test:watch # Watch mode
252
- npm run test:coverage # Coverage report
253
- npm run lint # Lint source code
254
- npm run format # Format code with Prettier
255
- npm run typecheck # TypeScript type checking
291
+ npm run build # Build the project
292
+ npm test # Run tests once
293
+ npm run test:watch # Watch mode
294
+ npm run test:coverage # Tests with enforced coverage thresholds
295
+ npm run test:package # Pack, install and import the archive (ESM, CJS, TypeScript)
296
+ npm run lint # Lint src, tests and scripts
297
+ npm run format # Format code with Prettier
298
+ npm run typecheck # Type-check source and tests
299
+ npm run check # lint + typecheck + test:coverage
256
300
  ```
257
301
 
258
302
  ## 🏗️ Build Output
@@ -263,34 +307,48 @@ dist/
263
307
  ├── index.cjs # CommonJS entry
264
308
  ├── index.d.ts # TypeScript definitions
265
309
  ├── index.d.cts # CommonJS definitions
310
+ ├── chunk-*.js / *.cjs # Shared code (one copy of errors/helpers for every entry)
266
311
  ├── plugins/
267
- │ ├── deep.js # Deep operations
312
+ │ ├── deep.js # Deep operations (+ .cjs, .d.ts, .d.cts)
268
313
  │ ├── async.js # Async utilities
269
314
  │ ├── guard.js # Type guards
270
315
  │ └── transform.js # Transform utilities
271
316
  ```
272
317
 
318
+ Entry points share code chunks, so `error instanceof TimeoutError` works no matter
319
+ whether the error came from `@oxog/utils/async` and the class from `@oxog/utils`.
320
+
273
321
  ## 🛡️ Security
274
322
 
275
323
  This library includes built-in protection against prototype pollution attacks:
276
324
 
277
325
  ```typescript
278
- import { merge } from '@oxog/utils';
326
+ import { merge, setMut } from '@oxog/utils';
327
+ import { mergeDeep } from '@oxog/utils/deep';
279
328
 
280
- // Dangerous keys are filtered automatically
281
- const result = merge({}, { __proto__: { evil: true } });
282
- console.log(result.evil); // undefined
329
+ const payload = JSON.parse('{"__proto__": {"isAdmin": true}}');
330
+
331
+ // Dangerous keys (__proto__, constructor, prototype) are skipped by merge/mergeDeep
332
+ merge({}, payload);
333
+ mergeDeep({}, payload);
334
+ console.log(({} as any).isAdmin); // undefined
335
+
336
+ // Paths through them are rejected by set/setMut
337
+ setMut({}, '__proto__.isAdmin', true); // throws InvalidPathError
283
338
  ```
284
339
 
340
+ `groupBy`, `keyBy`, `mapKeys`, `invert`, `cloneDeep` and `diff` store a `"__proto__"`
341
+ key as ordinary data instead of replacing the result's prototype.
342
+
285
343
  ## 📄 License
286
344
 
287
- MIT © [Ersin Koç](https://github.com/ersinkoc/utils)
345
+ MIT © [Ersin Koç](https://github.com/ersinkoc/Utils)
288
346
 
289
347
  ## 🔗 Links
290
348
 
291
349
  - **Documentation**: [https://utils.oxog.dev](https://utils.oxog.dev)
292
- - **GitHub**: [https://github.com/ersinkoc/utils](https://github.com/ersinkoc/utils)
293
- - **Issues**: [https://github.com/ersinkoc/utils/issues](https://github.com/ersinkoc/utils/issues)
350
+ - **GitHub**: [https://github.com/ersinkoc/Utils](https://github.com/ersinkoc/Utils)
351
+ - **Issues**: [https://github.com/ersinkoc/Utils/issues](https://github.com/ersinkoc/Utils/issues)
294
352
 
295
353
  ---
296
354
 
@@ -0,0 +1,34 @@
1
+ // src/internal.ts
2
+ var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
3
+ var hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
4
+ function assignOwn(obj, key, value) {
5
+ if (key === "__proto__") {
6
+ Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });
7
+ } else {
8
+ obj[key] = value;
9
+ }
10
+ }
11
+ function parsePath(path) {
12
+ const segments = [];
13
+ const source = String(path);
14
+ const pattern = /\[\s*(?:'([^']*)'|"([^"]*)"|([^\]]*?))\s*\]|([^.[\]]+)/g;
15
+ let match;
16
+ while ((match = pattern.exec(source)) !== null) {
17
+ const [, single, double, bare, dotted] = match;
18
+ if (dotted !== void 0) {
19
+ segments.push({ key: dotted, index: false });
20
+ } else {
21
+ const key = single ?? double ?? bare ?? "";
22
+ if (key === "") continue;
23
+ segments.push({ key, index: single === void 0 && double === void 0 && /^\d+$/.test(key) });
24
+ }
25
+ }
26
+ return segments;
27
+ }
28
+ function hasUnsafeSegment(segments) {
29
+ return segments.some((segment) => UNSAFE_KEYS.has(segment.key));
30
+ }
31
+
32
+ export { UNSAFE_KEYS, assignOwn, hasOwn, hasUnsafeSegment, parsePath };
33
+ //# sourceMappingURL=chunk-25WW2FCA.js.map
34
+ //# sourceMappingURL=chunk-25WW2FCA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal.ts"],"names":[],"mappings":";AAMO,IAAM,8BAAmC,IAAI,GAAA,CAAI,CAAC,WAAA,EAAa,aAAA,EAAe,WAAW,CAAC;AAE1F,IAAM,MAAA,GAAS,CAAC,GAAA,EAAa,GAAA,KAClC,OAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,G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AO,QAAA,CAAS,KAAK,CAAC,OAAA,KAAY,YAAY,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAC,CAAA;AAChE","file":"chunk-25WW2FCA.js","sourcesContent":["/**\n * Internal helpers shared by the public modules. Not part of the public API.\n * @internal\n */\n\n/** Keys that can reach or replace an object's prototype. */\nexport const UNSAFE_KEYS: ReadonlySet<string> = new Set(['__proto__', 'constructor', 'prototype']);\n\nexport const hasOwn = (obj: object, key: PropertyKey): boolean =>\n Object.prototype.hasOwnProperty.call(obj, key);\n\n/**\n * Assign `obj[key] = value` as an own data property.\n *\n * Plain assignment of `\"__proto__\"` would replace the prototype of `obj`\n * instead of storing a value; this helper always stores data.\n */\nexport function assignOwn(obj: any, key: PropertyKey, value: unknown): void {\n if (key === '__proto__') {\n Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });\n } else {\n obj[key] = value;\n }\n}\n\n/** One segment of a parsed property path. */\nexport interface PathSegment {\n key: string;\n /** True when the segment was written as a numeric bracket index (`[0]`). */\n index: boolean;\n}\n\n/**\n * Parse a property path such as `a.b[0].c` or `a['b'].c`.\n *\n * Empty segments are ignored, so `a..b` is the same as `a.b`.\n */\nexport function parsePath(path: string | number): PathSegment[] {\n const segments: PathSegment[] = [];\n const source = String(path);\n const pattern = /\\[\\s*(?:'([^']*)'|\"([^\"]*)\"|([^\\]]*?))\\s*\\]|([^.[\\]]+)/g;\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(source)) !== null) {\n const [, single, double, bare, dotted] = match;\n if (dotted !== undefined) {\n segments.push({ key: dotted, index: false });\n } else {\n const key = single ?? double ?? bare ?? '';\n if (key === '') continue;\n segments.push({ key, index: single === undefined && double === undefined && /^\\d+$/.test(key) });\n }\n }\n return segments;\n}\n\n/** True when any segment of the path is `__proto__`, `constructor` or `prototype`. */\nexport function hasUnsafeSegment(segments: readonly PathSegment[]): boolean {\n return segments.some((segment) => UNSAFE_KEYS.has(segment.key));\n}\n"]}
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+
3
+ // src/errors.ts
4
+ var UtilsError = class extends Error {
5
+ code;
6
+ constructor(message, code) {
7
+ super(message);
8
+ this.name = "UtilsError";
9
+ this.code = code;
10
+ Error.captureStackTrace(this, this.constructor);
11
+ }
12
+ };
13
+ var InvalidPathError = class extends UtilsError {
14
+ constructor(path) {
15
+ super(`Invalid path: ${path}`, "INVALID_PATH");
16
+ this.name = "InvalidPathError";
17
+ }
18
+ };
19
+ var CircularReferenceError = class extends UtilsError {
20
+ constructor() {
21
+ super("Circular reference detected", "CIRCULAR_REF");
22
+ this.name = "CircularReferenceError";
23
+ }
24
+ };
25
+ var TimeoutError = class extends UtilsError {
26
+ constructor(ms) {
27
+ super(`Operation timed out after ${ms}ms`, "TIMEOUT");
28
+ this.name = "TimeoutError";
29
+ }
30
+ };
31
+ var PluginAlreadyRegisteredError = class extends UtilsError {
32
+ constructor(name) {
33
+ super(`Plugin "${name}" already registered`, "PLUGIN_ALREADY_REGISTERED");
34
+ this.name = "PluginAlreadyRegisteredError";
35
+ }
36
+ };
37
+ var PluginNotFoundError = class extends UtilsError {
38
+ constructor(name) {
39
+ super(`Plugin "${name}" not found`, "PLUGIN_NOT_FOUND");
40
+ this.name = "PluginNotFoundError";
41
+ }
42
+ };
43
+ var PluginDependencyMissingError = class extends UtilsError {
44
+ constructor(plugin, dependency) {
45
+ super(`Plugin "${plugin}" requires "${dependency}" to be registered first`, "PLUGIN_DEPENDENCY_MISSING");
46
+ this.name = "PluginDependencyMissingError";
47
+ }
48
+ };
49
+ var MaxRetriesExceededError = class extends UtilsError {
50
+ /** Number of attempts that were made. */
51
+ attempts;
52
+ /**
53
+ * @param attempts - Number of attempts that were made
54
+ * @param cause - The error thrown by the last attempt (available as `error.cause`)
55
+ */
56
+ constructor(attempts, cause) {
57
+ super(`Maximum retry attempts (${attempts}) exceeded`, "MAX_RETRIES_EXCEEDED");
58
+ this.name = "MaxRetriesExceededError";
59
+ this.attempts = attempts;
60
+ if (cause !== void 0) {
61
+ Object.defineProperty(this, "cause", {
62
+ value: cause,
63
+ writable: true,
64
+ enumerable: false,
65
+ configurable: true
66
+ });
67
+ }
68
+ }
69
+ };
70
+ var CircularDependencyError = class extends UtilsError {
71
+ constructor(cycle) {
72
+ super(`Circular dependency detected: ${cycle.join(" -> ")}`, "CIRCULAR_DEPENDENCY");
73
+ this.name = "CircularDependencyError";
74
+ }
75
+ };
76
+ var PluginInitializationError = class extends UtilsError {
77
+ pluginName;
78
+ cause;
79
+ constructor(pluginName, cause) {
80
+ super(`Plugin "${pluginName}" failed to initialize: ${cause.message}`, "PLUGIN_INIT_FAILED");
81
+ this.name = "PluginInitializationError";
82
+ this.pluginName = pluginName;
83
+ this.cause = cause;
84
+ }
85
+ };
86
+ var KernelAlreadyInitializedError = class extends UtilsError {
87
+ constructor() {
88
+ super("Kernel is already initialized", "KERNEL_ALREADY_INITIALIZED");
89
+ this.name = "KernelAlreadyInitializedError";
90
+ }
91
+ };
92
+ var KernelInitializingError = class extends UtilsError {
93
+ constructor() {
94
+ super("Kernel is currently initializing", "KERNEL_INITIALIZING");
95
+ this.name = "KernelInitializingError";
96
+ }
97
+ };
98
+
99
+ exports.CircularDependencyError = CircularDependencyError;
100
+ exports.CircularReferenceError = CircularReferenceError;
101
+ exports.InvalidPathError = InvalidPathError;
102
+ exports.KernelAlreadyInitializedError = KernelAlreadyInitializedError;
103
+ exports.KernelInitializingError = KernelInitializingError;
104
+ exports.MaxRetriesExceededError = MaxRetriesExceededError;
105
+ exports.PluginAlreadyRegisteredError = PluginAlreadyRegisteredError;
106
+ exports.PluginDependencyMissingError = PluginDependencyMissingError;
107
+ exports.PluginInitializationError = PluginInitializationError;
108
+ exports.PluginNotFoundError = PluginNotFoundError;
109
+ exports.TimeoutError = TimeoutError;
110
+ exports.UtilsError = UtilsError;
111
+ //# sourceMappingURL=chunk-DEVWOLUI.cjs.map
112
+ //# sourceMappingURL=chunk-DEVWOLUI.cjs.map
@@ -0,0 +1 @@
1
+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cAAwC,UAAA,CAAW;AAAA,EAC/C,UAAA;AAAA,EACS,KAAA;AAAA,EAElB,WAAA,CAAY,YAAoB,KAAA,EAAc;AAC5C,IAAA,KAAA,CAAM,WAAW,UAAU,CAAA,wBAAA,EAA2B,KAAA,CAAM,OAAO,IAAI,oBAAoB,CAAA;AAC3F,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF;AAKO,IAAM,6BAAA,GAAN,cAA4C,UAAA,CAAW;AAAA,EAC5D,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,iCAAiC,4BAA4B,CAAA;AACnE,IAAA,IAAA,CAAK,IAAA,GAAO,+BAAA;AAAA,EACd;AACF;AAKO,IAAM,uBAAA,GAAN,cAAsC,UAAA,CAAW;AAAA,EACtD,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,oCAAoC,qBAAqB,CAAA;AAC/D,IAAA,IAAA,CAAK,IAAA,GAAO,yBAAA;AAAA,EACd;AACF","file":"chunk-DEVWOLUI.cjs","sourcesContent":["/**\n * Base error class for all @oxog/utils errors.\n */\nexport class UtilsError extends Error {\n code: string;\n\n constructor(message: string, code: string) {\n super(message);\n this.name = 'UtilsError';\n this.code = code;\n Error.captureStackTrace(this, this.constructor);\n }\n}\n\n/**\n * Error thrown when an invalid path is provided to get/set/has functions.\n */\nexport class InvalidPathError extends UtilsError {\n constructor(path: string) {\n super(`Invalid path: ${path}`, 'INVALID_PATH');\n this.name = 'InvalidPathError';\n }\n}\n\n/**\n * Error thrown when a circular reference is detected during deep operations.\n */\nexport class CircularReferenceError extends UtilsError {\n constructor() {\n super('Circular reference detected', 'CIRCULAR_REF');\n this.name = 'CircularReferenceError';\n }\n}\n\n/**\n * Error thrown when an operation times out.\n */\nexport class TimeoutError extends UtilsError {\n constructor(ms: number) {\n super(`Operation timed out after ${ms}ms`, 'TIMEOUT');\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Error thrown when a plugin is already registered.\n */\nexport class PluginAlreadyRegisteredError extends UtilsError {\n constructor(name: string) {\n super(`Plugin \"${name}\" already registered`, 'PLUGIN_ALREADY_REGISTERED');\n this.name = 'PluginAlreadyRegisteredError';\n }\n}\n\n/**\n * Error thrown when a requested plugin is not found.\n */\nexport class PluginNotFoundError extends UtilsError {\n constructor(name: string) {\n super(`Plugin \"${name}\" not found`, 'PLUGIN_NOT_FOUND');\n this.name = 'PluginNotFoundError';\n }\n}\n\n/**\n * Error thrown when a plugin dependency is missing.\n */\nexport class PluginDependencyMissingError extends UtilsError {\n constructor(plugin: string, dependency: string) {\n super(`Plugin \"${plugin}\" requires \"${dependency}\" to be registered first`, 'PLUGIN_DEPENDENCY_MISSING');\n this.name = 'PluginDependencyMissingError';\n }\n}\n\n/**\n * Error thrown when retry attempts are exhausted.\n */\nexport class MaxRetriesExceededError extends UtilsError {\n /** Number of attempts that were made. */\n readonly attempts: number;\n\n /**\n * @param attempts - Number of attempts that were made\n * @param cause - The error thrown by the last attempt (available as `error.cause`)\n */\n constructor(attempts: number, cause?: unknown) {\n super(`Maximum retry attempts (${attempts}) exceeded`, 'MAX_RETRIES_EXCEEDED');\n this.name = 'MaxRetriesExceededError';\n this.attempts = attempts;\n if (cause !== undefined) {\n Object.defineProperty(this, 'cause', {\n value: cause,\n writable: true,\n enumerable: false,\n configurable: true,\n });\n }\n }\n}\n\n/**\n * Error thrown when circular dependency is detected between plugins.\n */\nexport class CircularDependencyError extends UtilsError {\n constructor(cycle: string[]) {\n super(`Circular dependency detected: ${cycle.join(' -> ')}`, 'CIRCULAR_DEPENDENCY');\n this.name = 'CircularDependencyError';\n }\n}\n\n/**\n * Error thrown when plugin initialization fails.\n */\nexport class PluginInitializationError extends UtilsError {\n readonly pluginName: string;\n override readonly cause: Error;\n\n constructor(pluginName: string, cause: Error) {\n super(`Plugin \"${pluginName}\" failed to initialize: ${cause.message}`, 'PLUGIN_INIT_FAILED');\n this.name = 'PluginInitializationError';\n this.pluginName = pluginName;\n this.cause = cause;\n }\n}\n\n/**\n * Error thrown when kernel is already initialized.\n */\nexport class KernelAlreadyInitializedError extends UtilsError {\n constructor() {\n super('Kernel is already initialized', 'KERNEL_ALREADY_INITIALIZED');\n this.name = 'KernelAlreadyInitializedError';\n }\n}\n\n/**\n * Error thrown when kernel is currently initializing (race condition prevention).\n */\nexport class KernelInitializingError extends UtilsError {\n constructor() {\n super('Kernel is currently initializing', 'KERNEL_INITIALIZING');\n this.name = 'KernelInitializingError';\n }\n}\n"]}
@@ -0,0 +1,99 @@
1
+ // src/errors.ts
2
+ var UtilsError = class extends Error {
3
+ code;
4
+ constructor(message, code) {
5
+ super(message);
6
+ this.name = "UtilsError";
7
+ this.code = code;
8
+ Error.captureStackTrace(this, this.constructor);
9
+ }
10
+ };
11
+ var InvalidPathError = class extends UtilsError {
12
+ constructor(path) {
13
+ super(`Invalid path: ${path}`, "INVALID_PATH");
14
+ this.name = "InvalidPathError";
15
+ }
16
+ };
17
+ var CircularReferenceError = class extends UtilsError {
18
+ constructor() {
19
+ super("Circular reference detected", "CIRCULAR_REF");
20
+ this.name = "CircularReferenceError";
21
+ }
22
+ };
23
+ var TimeoutError = class extends UtilsError {
24
+ constructor(ms) {
25
+ super(`Operation timed out after ${ms}ms`, "TIMEOUT");
26
+ this.name = "TimeoutError";
27
+ }
28
+ };
29
+ var PluginAlreadyRegisteredError = class extends UtilsError {
30
+ constructor(name) {
31
+ super(`Plugin "${name}" already registered`, "PLUGIN_ALREADY_REGISTERED");
32
+ this.name = "PluginAlreadyRegisteredError";
33
+ }
34
+ };
35
+ var PluginNotFoundError = class extends UtilsError {
36
+ constructor(name) {
37
+ super(`Plugin "${name}" not found`, "PLUGIN_NOT_FOUND");
38
+ this.name = "PluginNotFoundError";
39
+ }
40
+ };
41
+ var PluginDependencyMissingError = class extends UtilsError {
42
+ constructor(plugin, dependency) {
43
+ super(`Plugin "${plugin}" requires "${dependency}" to be registered first`, "PLUGIN_DEPENDENCY_MISSING");
44
+ this.name = "PluginDependencyMissingError";
45
+ }
46
+ };
47
+ var MaxRetriesExceededError = class extends UtilsError {
48
+ /** Number of attempts that were made. */
49
+ attempts;
50
+ /**
51
+ * @param attempts - Number of attempts that were made
52
+ * @param cause - The error thrown by the last attempt (available as `error.cause`)
53
+ */
54
+ constructor(attempts, cause) {
55
+ super(`Maximum retry attempts (${attempts}) exceeded`, "MAX_RETRIES_EXCEEDED");
56
+ this.name = "MaxRetriesExceededError";
57
+ this.attempts = attempts;
58
+ if (cause !== void 0) {
59
+ Object.defineProperty(this, "cause", {
60
+ value: cause,
61
+ writable: true,
62
+ enumerable: false,
63
+ configurable: true
64
+ });
65
+ }
66
+ }
67
+ };
68
+ var CircularDependencyError = class extends UtilsError {
69
+ constructor(cycle) {
70
+ super(`Circular dependency detected: ${cycle.join(" -> ")}`, "CIRCULAR_DEPENDENCY");
71
+ this.name = "CircularDependencyError";
72
+ }
73
+ };
74
+ var PluginInitializationError = class extends UtilsError {
75
+ pluginName;
76
+ cause;
77
+ constructor(pluginName, cause) {
78
+ super(`Plugin "${pluginName}" failed to initialize: ${cause.message}`, "PLUGIN_INIT_FAILED");
79
+ this.name = "PluginInitializationError";
80
+ this.pluginName = pluginName;
81
+ this.cause = cause;
82
+ }
83
+ };
84
+ var KernelAlreadyInitializedError = class extends UtilsError {
85
+ constructor() {
86
+ super("Kernel is already initialized", "KERNEL_ALREADY_INITIALIZED");
87
+ this.name = "KernelAlreadyInitializedError";
88
+ }
89
+ };
90
+ var KernelInitializingError = class extends UtilsError {
91
+ constructor() {
92
+ super("Kernel is currently initializing", "KERNEL_INITIALIZING");
93
+ this.name = "KernelInitializingError";
94
+ }
95
+ };
96
+
97
+ export { CircularDependencyError, CircularReferenceError, InvalidPathError, KernelAlreadyInitializedError, KernelInitializingError, MaxRetriesExceededError, PluginAlreadyRegisteredError, PluginDependencyMissingError, PluginInitializationError, PluginNotFoundError, T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,CAAC,IAAI,qBAAqB,CAAA;AAClF,IAAA,IAAA,CAAK,IAAA,GAAO,yBAAA;AAAA,EACd;AACF;AAKO,IAAM,yBAAA,GAAN,cAAwC,UAAA,CAAW;AAAA,EAC/C,UAAA;AAAA,EACS,KAAA;AAAA,EAElB,WAAA,CAAY,YAAoB,KAAA,EAAc;AAC5C,IAAA,KAAA,CAAM,WAAW,UAAU,CAAA,wBAAA,EAA2B,KAAA,CAAM,OAAO,IAAI,oBAAoB,CAAA;AAC3F,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF;AAKO,IAAM,6BAAA,GAAN,cAA4C,UAAA,CAAW;AAAA,EAC5D,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,iCAAiC,4BAA4B,CAAA;AACnE,IAAA,IAAA,CAAK,IAAA,GAAO,+BAAA;AAAA,EACd;AACF;AAKO,IAAM,uBAAA,GAAN,cAAsC,UAAA,CAAW;AAAA,EACtD,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,oCAAoC,qBAAqB,CAAA;AAC/D,IAAA,IAAA,CAAK,IAAA,GAAO,yBAAA;AAAA,EACd;AACF","file":"chunk-IUDFQZIP.js","sourcesContent":["/**\n * Base error class for all @oxog/utils errors.\n */\nexport class UtilsError extends Error {\n code: string;\n\n constructor(message: string, code: string) {\n super(message);\n this.name = 'UtilsError';\n this.code = code;\n Error.captureStackTrace(this, this.constructor);\n }\n}\n\n/**\n * Error thrown when an invalid path is provided to get/set/has functions.\n */\nexport class InvalidPathError extends UtilsError {\n constructor(path: string) {\n super(`Invalid path: ${path}`, 'INVALID_PATH');\n this.name = 'InvalidPathError';\n }\n}\n\n/**\n * Error thrown when a circular reference is detected during deep operations.\n */\nexport class CircularReferenceError extends UtilsError {\n constructor() {\n super('Circular reference detected', 'CIRCULAR_REF');\n this.name = 'CircularReferenceError';\n }\n}\n\n/**\n * Error thrown when an operation times out.\n */\nexport class TimeoutError extends UtilsError {\n constructor(ms: number) {\n super(`Operation timed out after ${ms}ms`, 'TIMEOUT');\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Error thrown when a plugin is already registered.\n */\nexport class PluginAlreadyRegisteredError extends UtilsError {\n constructor(name: string) {\n super(`Plugin \"${name}\" already registered`, 'PLUGIN_ALREADY_REGISTERED');\n this.name = 'PluginAlreadyRegisteredError';\n }\n}\n\n/**\n * Error thrown when a requested plugin is not found.\n */\nexport class PluginNotFoundError extends UtilsError {\n constructor(name: string) {\n super(`Plugin \"${name}\" not found`, 'PLUGIN_NOT_FOUND');\n this.name = 'PluginNotFoundError';\n }\n}\n\n/**\n * Error thrown when a plugin dependency is missing.\n */\nexport class PluginDependencyMissingError extends UtilsError {\n constructor(plugin: string, dependency: string) {\n super(`Plugin \"${plugin}\" requires \"${dependency}\" to be registered first`, 'PLUGIN_DEPENDENCY_MISSING');\n this.name = 'PluginDependencyMissingError';\n }\n}\n\n/**\n * Error thrown when retry attempts are exhausted.\n */\nexport class MaxRetriesExceededError extends UtilsError {\n /** Number of attempts that were made. */\n readonly attempts: number;\n\n /**\n * @param attempts - Number of attempts that were made\n * @param cause - The error thrown by the last attempt (available as `error.cause`)\n */\n constructor(attempts: number, cause?: unknown) {\n super(`Maximum retry attempts (${attempts}) exceeded`, 'MAX_RETRIES_EXCEEDED');\n this.name = 'MaxRetriesExceededError';\n this.attempts = attempts;\n if (cause !== undefined) {\n Object.defineProperty(this, 'cause', {\n value: cause,\n writable: true,\n enumerable: false,\n configurable: true,\n });\n }\n }\n}\n\n/**\n * Error thrown when circular dependency is detected between plugins.\n */\nexport class CircularDependencyError extends UtilsError {\n constructor(cycle: string[]) {\n super(`Circular dependency detected: ${cycle.join(' -> ')}`, 'CIRCULAR_DEPENDENCY');\n this.name = 'CircularDependencyError';\n }\n}\n\n/**\n * Error thrown when plugin initialization fails.\n */\nexport class PluginInitializationError extends UtilsError {\n readonly pluginName: string;\n override readonly cause: Error;\n\n constructor(pluginName: string, cause: Error) {\n super(`Plugin \"${pluginName}\" failed to initialize: ${cause.message}`, 'PLUGIN_INIT_FAILED');\n this.name = 'PluginInitializationError';\n this.pluginName = pluginName;\n this.cause = cause;\n }\n}\n\n/**\n * Error thrown when kernel is already initialized.\n */\nexport class KernelAlreadyInitializedError extends UtilsError {\n constructor() {\n super('Kernel is already initialized', 'KERNEL_ALREADY_INITIALIZED');\n this.name = 'KernelAlreadyInitializedError';\n }\n}\n\n/**\n * Error thrown when kernel is currently initializing (race condition prevention).\n */\nexport class KernelInitializingError extends UtilsError {\n constructor() {\n super('Kernel is currently initializing', 'KERNEL_INITIALIZING');\n this.name = 'KernelInitializingError';\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export { __export };
8
+ //# sourceMappingURL=chunk-PZ5AY32C.js.map
9
+ //# sourceMappingURL=chunk-PZ5AY32C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-PZ5AY32C.js"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __export = (target, all) => {
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+
9
+ exports.__export = __export;
10
+ //# sourceMappingURL=chunk-Q7SFCCGT.cjs.map
11
+ //# sourceMappingURL=chunk-Q7SFCCGT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-Q7SFCCGT.cjs"}