@blac/core 2.0.3 → 2.0.5

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 (64) hide show
  1. package/README.md +2 -0
  2. package/dist/constants.d.ts +81 -0
  3. package/dist/core/Cubit.d.ts +24 -0
  4. package/dist/core/StateContainer.d.ts +127 -0
  5. package/dist/core/StateContainerRegistry.d.ts +189 -0
  6. package/dist/debug.d.ts +35 -0
  7. package/dist/decorators/blac.d.ts +40 -0
  8. package/dist/decorators/index.d.ts +1 -0
  9. package/dist/index.cjs +1509 -47
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +18 -794
  12. package/dist/index.d.ts +18 -794
  13. package/dist/index.js +1463 -10
  14. package/dist/index.js.map +1 -1
  15. package/dist/plugin/BlacPlugin.d.ts +110 -0
  16. package/dist/plugin/PluginManager.d.ts +81 -0
  17. package/dist/plugins.d.ts +25 -0
  18. package/dist/registry/acquire.d.ts +2 -0
  19. package/dist/registry/borrow.d.ts +9 -0
  20. package/dist/registry/config.d.ts +8 -0
  21. package/dist/registry/ensure.d.ts +2 -0
  22. package/dist/registry/index.d.ts +7 -0
  23. package/dist/registry/management.d.ts +4 -0
  24. package/dist/registry/queries.d.ts +5 -0
  25. package/dist/registry/release.d.ts +2 -0
  26. package/dist/tracking/index.d.ts +2 -1
  27. package/dist/tracking/resolve-dependencies.d.ts +7 -0
  28. package/dist/tracking/tracking-proxy.d.ts +0 -14
  29. package/dist/types/branded.d.ts +26 -0
  30. package/dist/types/utilities.d.ts +51 -0
  31. package/dist/utils/idGenerator.d.ts +73 -0
  32. package/dist/utils/static-props.d.ts +35 -0
  33. package/dist/watch/index.d.ts +2 -0
  34. package/dist/watch/watch.d.ts +50 -0
  35. package/dist/watch-entry.d.ts +26 -0
  36. package/package.json +6 -82
  37. package/dist/StateContainerRegistry.cjs.map +0 -1
  38. package/dist/StateContainerRegistry.js.map +0 -1
  39. package/dist/debug.cjs +0 -27
  40. package/dist/debug.cjs.map +0 -1
  41. package/dist/debug.js +0 -19
  42. package/dist/debug.js.map +0 -1
  43. package/dist/dependency-manager.cjs.map +0 -1
  44. package/dist/dependency-manager.js.map +0 -1
  45. package/dist/management.cjs.map +0 -1
  46. package/dist/management.js.map +0 -1
  47. package/dist/plugins.cjs +0 -4
  48. package/dist/plugins.js +0 -3
  49. package/dist/tracking-proxy.cjs.map +0 -1
  50. package/dist/tracking-proxy.js.map +0 -1
  51. package/dist/tracking.cjs +0 -19
  52. package/dist/tracking.d.cts +0 -9
  53. package/dist/tracking.js +0 -4
  54. package/dist/types.cjs +0 -14
  55. package/dist/types.cjs.map +0 -1
  56. package/dist/types.d.cts +0 -8
  57. package/dist/types.js +0 -13
  58. package/dist/types.js.map +0 -1
  59. package/dist/watch-entry.cjs +0 -111
  60. package/dist/watch-entry.cjs.map +0 -1
  61. package/dist/watch-entry.js +0 -107
  62. package/dist/watch-entry.js.map +0 -1
  63. package/dist/watch.cjs.map +0 -1
  64. package/dist/watch.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,9 +1,3 @@
1
- const require_StateContainerRegistry = require('./StateContainerRegistry.cjs');
2
- const require_tracking_proxy = require('./tracking-proxy.cjs');
3
- const require_management = require('./management.cjs');
4
- const require_watch = require('./watch.cjs');
5
- const require_dependency_manager = require('./dependency-manager.cjs');
6
- require('./tracking.cjs');
7
1
 
8
2
  //#region src/utils/idGenerator.ts
9
3
  /**
@@ -37,8 +31,576 @@ function generateIsolatedKey() {
37
31
  return `isolated-${Math.random().toString(36).slice(2, 11)}`;
38
32
  }
39
33
 
34
+ //#endregion
35
+ //#region src/constants.ts
36
+ /**
37
+ * Default configuration constants for BlaC
38
+ *
39
+ * Centralized location for all magic numbers and default values.
40
+ */
41
+ /**
42
+ * Default configuration constants for BlaC
43
+ */
44
+ const BLAC_DEFAULTS = {
45
+ DEFAULT_INSTANCE_KEY: "default",
46
+ MAX_GETTER_DEPTH: 10,
47
+ CLEANUP_INTERVAL_MS: 3e4,
48
+ WEAKREF_CLEANUP_INTERVAL_MS: 1e4,
49
+ MAX_SUBSCRIPTIONS: 1e3,
50
+ MAX_SUBSCRIPTIONS_HIGH_PERF: 1e4,
51
+ PIPELINE_TIMEOUT_MS: 5e3,
52
+ CLEANUP_INTERVAL_HIGH_PERF_MS: 5e3,
53
+ MAX_PIPELINE_STAGES: 30
54
+ };
55
+ /**
56
+ * Static property names for StateContainer classes
57
+ * Used for feature flags and configuration on bloc classes
58
+ */
59
+ const BLAC_STATIC_PROPS = {
60
+ ISOLATED: "isolated",
61
+ KEEP_ALIVE: "keepAlive",
62
+ EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools"
63
+ };
64
+ /**
65
+ * Standard error message prefix
66
+ */
67
+ const BLAC_ERROR_PREFIX = "[BlaC]";
68
+
69
+ //#endregion
70
+ //#region src/plugin/PluginManager.ts
71
+ /**
72
+ * Manages plugin lifecycle for the BlaC state management system.
73
+ * Plugins receive notifications about state container lifecycle events.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * const manager = createPluginManager(registry);
78
+ * manager.install(myPlugin, { environment: 'development' });
79
+ * ```
80
+ */
81
+ var PluginManager = class {
82
+ /**
83
+ * Create a new PluginManager
84
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
85
+ */
86
+ constructor(registry) {
87
+ this.plugins = /* @__PURE__ */ new Map();
88
+ this.registry = registry;
89
+ this.setupLifecycleHooks();
90
+ }
91
+ /**
92
+ * Install a plugin with optional configuration
93
+ * @param plugin - The plugin to install
94
+ * @param config - Optional plugin configuration
95
+ * @throws Error if plugin is already installed
96
+ */
97
+ install(plugin, config = {}) {
98
+ const effectiveConfig = {
99
+ enabled: true,
100
+ environment: "all",
101
+ ...config
102
+ };
103
+ if (!this.shouldEnablePlugin(effectiveConfig)) {
104
+ console.log(`[BlaC] Plugin "${plugin.name}" skipped (environment mismatch)`);
105
+ return;
106
+ }
107
+ if (this.plugins.has(plugin.name)) throw new Error(`Plugin "${plugin.name}" is already installed`);
108
+ const context = this.createPluginContext();
109
+ this.plugins.set(plugin.name, {
110
+ plugin,
111
+ config: effectiveConfig,
112
+ context
113
+ });
114
+ if (plugin.onInstall) try {
115
+ plugin.onInstall(context);
116
+ } catch (error) {
117
+ console.error(`[BlaC] Error installing plugin "${plugin.name}":`, error);
118
+ this.plugins.delete(plugin.name);
119
+ throw error;
120
+ }
121
+ console.log(`[BlaC] Plugin "${plugin.name}" v${plugin.version} installed`);
122
+ }
123
+ /**
124
+ * Uninstall a plugin by name
125
+ * @param pluginName - The name of the plugin to uninstall
126
+ * @throws Error if plugin is not installed
127
+ */
128
+ uninstall(pluginName) {
129
+ const installed = this.plugins.get(pluginName);
130
+ if (!installed) throw new Error(`Plugin "${pluginName}" is not installed`);
131
+ if (installed.plugin.onUninstall) try {
132
+ installed.plugin.onUninstall();
133
+ } catch (error) {
134
+ console.error(`[BlaC] Error uninstalling plugin "${pluginName}":`, error);
135
+ }
136
+ this.plugins.delete(pluginName);
137
+ console.log(`[BlaC] Plugin "${pluginName}" uninstalled`);
138
+ }
139
+ /**
140
+ * Get an installed plugin by name
141
+ * @param pluginName - The name of the plugin to retrieve
142
+ * @returns The plugin instance or undefined if not found
143
+ */
144
+ getPlugin(pluginName) {
145
+ return this.plugins.get(pluginName)?.plugin;
146
+ }
147
+ /**
148
+ * Get all installed plugins
149
+ * @returns Array of all installed plugins
150
+ */
151
+ getAllPlugins() {
152
+ return Array.from(this.plugins.values()).map((p) => p.plugin);
153
+ }
154
+ /**
155
+ * Check if a plugin is installed
156
+ * @param pluginName - The name of the plugin to check
157
+ * @returns true if the plugin is installed
158
+ */
159
+ hasPlugin(pluginName) {
160
+ return this.plugins.has(pluginName);
161
+ }
162
+ /**
163
+ * Uninstall all plugins
164
+ */
165
+ clear() {
166
+ for (const name of this.plugins.keys()) this.uninstall(name);
167
+ }
168
+ /**
169
+ * Setup lifecycle hooks to notify plugins
170
+ */
171
+ setupLifecycleHooks() {
172
+ this.registry.on("created", (instance) => {
173
+ this.notifyPlugins("onInstanceCreated", instance);
174
+ });
175
+ this.registry.on("stateChanged", (instance, previousState, currentState, callstack) => {
176
+ this.notifyPlugins("onStateChanged", instance, previousState, currentState, callstack);
177
+ });
178
+ this.registry.on("disposed", (instance) => {
179
+ this.notifyPlugins("onInstanceDisposed", instance);
180
+ });
181
+ }
182
+ /**
183
+ * Notify all plugins of a lifecycle event
184
+ */
185
+ notifyPlugins(hookName, ...args) {
186
+ for (const { plugin, config, context } of this.plugins.values()) {
187
+ if (!config.enabled) continue;
188
+ const hook = plugin[hookName];
189
+ if (typeof hook === "function") try {
190
+ hook.apply(plugin, [...args, context]);
191
+ } catch (error) {
192
+ console.error(`[BlaC] Error in plugin "${plugin.name}" ${hookName}:`, error);
193
+ }
194
+ }
195
+ }
196
+ /**
197
+ * Create plugin context with safe API access
198
+ */
199
+ createPluginContext() {
200
+ return {
201
+ getInstanceMetadata: (instance) => {
202
+ return {
203
+ id: instance.instanceId,
204
+ className: instance.constructor.name,
205
+ isDisposed: instance.isDisposed,
206
+ name: instance.name,
207
+ lastStateChangeTimestamp: instance.lastUpdateTimestamp,
208
+ createdAt: instance.createdAt,
209
+ state: instance.state,
210
+ isIsolated: instance.instanceId.startsWith("isolated-")
211
+ };
212
+ },
213
+ getState: (instance) => {
214
+ return instance.state;
215
+ },
216
+ queryInstances: (typeClass) => {
217
+ return this.registry.getAll(typeClass);
218
+ },
219
+ getAllTypes: () => {
220
+ return this.registry.getTypes();
221
+ },
222
+ getStats: () => {
223
+ return this.registry.getStats();
224
+ }
225
+ };
226
+ }
227
+ /**
228
+ * Check if plugin should be enabled based on environment
229
+ */
230
+ shouldEnablePlugin(config) {
231
+ if (!config.enabled) return false;
232
+ if (config.environment === "all") return true;
233
+ return this.getCurrentEnvironment() === config.environment;
234
+ }
235
+ /**
236
+ * Get current environment
237
+ */
238
+ getCurrentEnvironment() {
239
+ if (typeof process !== "undefined") {
240
+ if (process.env.NODE_ENV === "test") return "test";
241
+ if (process.env.NODE_ENV === "production") return "production";
242
+ return "development";
243
+ }
244
+ return "development";
245
+ }
246
+ };
247
+ /**
248
+ * Create a plugin manager instance
249
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
250
+ * @returns A new PluginManager instance
251
+ */
252
+ function createPluginManager(registry) {
253
+ return new PluginManager(registry);
254
+ }
255
+
256
+ //#endregion
257
+ //#region src/utils/static-props.ts
258
+ /**
259
+ * Utility functions for accessing static properties on StateContainer classes
260
+ */
261
+ /**
262
+ * Get a static property from a class constructor
263
+ * Type-safe helper that avoids (Type as any) casts
264
+ *
265
+ * @param Type - The class constructor
266
+ * @param propName - The property name to access
267
+ * @param defaultValue - Optional default value if property is undefined
268
+ * @returns The property value or default
269
+ */
270
+ function getStaticProp(Type, propName, defaultValue) {
271
+ return Type[propName] ?? defaultValue;
272
+ }
273
+ /**
274
+ * Check if a class is marked as isolated.
275
+ * Isolated classes create separate instances per component.
276
+ * @param Type - The class constructor to check
277
+ * @returns true if the class has `static isolated = true`
278
+ */
279
+ function isIsolatedClass(Type) {
280
+ return getStaticProp(Type, BLAC_STATIC_PROPS.ISOLATED) === true;
281
+ }
282
+ /**
283
+ * Check if a class is marked as keepAlive.
284
+ * KeepAlive classes are never auto-disposed when ref count reaches 0.
285
+ * @param Type - The class constructor to check
286
+ * @returns true if the class has `static keepAlive = true`
287
+ */
288
+ function isKeepAliveClass(Type) {
289
+ return getStaticProp(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;
290
+ }
291
+
292
+ //#endregion
293
+ //#region src/core/StateContainerRegistry.ts
294
+ /**
295
+ * Central registry for managing StateContainer instances.
296
+ * Handles instance lifecycle, ref counting, and lifecycle event emission.
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * const registry = new StateContainerRegistry();
301
+ * const instance = registry.acquire(MyBloc); // ownership, must release
302
+ * const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc
303
+ * registry.on('stateChanged', (container, prev, next) => {
304
+ * console.log('State changed:', prev, '->', next);
305
+ * });
306
+ * ```
307
+ */
308
+ var StateContainerRegistry = class {
309
+ constructor() {
310
+ this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
311
+ this.types = /* @__PURE__ */ new Set();
312
+ this.typeConfigs = /* @__PURE__ */ new Map();
313
+ this.listeners = /* @__PURE__ */ new Map();
314
+ }
315
+ /**
316
+ * Register a type for lifecycle event tracking
317
+ * @param constructor - The StateContainer class constructor
318
+ */
319
+ registerType(constructor) {
320
+ this.types.add(constructor);
321
+ }
322
+ /**
323
+ * Register a StateContainer class with configuration
324
+ * @param constructor - The StateContainer class constructor
325
+ * @param isolated - Whether instances should be isolated (component-scoped)
326
+ * @throws Error if type is already registered
327
+ */
328
+ register(constructor, isolated = false) {
329
+ const className = constructor.name;
330
+ if (!isolated && isIsolatedClass(constructor)) isolated = true;
331
+ if (this.typeConfigs.has(className)) throw new Error(`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`);
332
+ this.typeConfigs.set(className, { isolated });
333
+ this.registerType(constructor);
334
+ }
335
+ ensureInstancesMap(Type) {
336
+ let instances = this.instancesByConstructor.get(Type);
337
+ if (!instances) {
338
+ instances = /* @__PURE__ */ new Map();
339
+ this.instancesByConstructor.set(Type, instances);
340
+ }
341
+ return instances;
342
+ }
343
+ /**
344
+ * Get the instances Map for a specific class (public API for stats/debugging)
345
+ */
346
+ getInstancesMap(Type) {
347
+ return this.instancesByConstructor.get(Type) || /* @__PURE__ */ new Map();
348
+ }
349
+ /**
350
+ * Acquire an instance with ref counting (ownership semantics).
351
+ * Creates a new instance if one doesn't exist, or returns existing and increments ref count.
352
+ * You must call `release()` when done to decrement the ref count.
353
+ * @param Type - The StateContainer class constructor
354
+ * @param instanceKey - Instance key (defaults to 'default')
355
+ * @param options - Acquisition options
356
+ * @param options.canCreate - Whether to create new instance if not found (default: true)
357
+ * @param options.countRef - Whether to increment ref count (default: true)
358
+ * @returns The state container instance
359
+ */
360
+ acquire(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY, options = {}) {
361
+ const { canCreate = true, countRef = true } = options;
362
+ const registryConfig = this.typeConfigs.get(Type.name);
363
+ const isolated = isIsolatedClass(Type) || registryConfig?.isolated === true;
364
+ const config = { instanceId: instanceKey };
365
+ if (isolated && !canCreate) throw new Error(`${BLAC_ERROR_PREFIX} Cannot get isolated instance "${instanceKey}" of ${Type.name} when creation is disabled.`);
366
+ if (isolated) {
367
+ const instance = new Type();
368
+ instance.initConfig(config);
369
+ this.registerType(Type);
370
+ return instance;
371
+ }
372
+ const instances = this.ensureInstancesMap(Type);
373
+ let entry = instances.get(instanceKey);
374
+ if (entry?.instance.isDisposed) {
375
+ instances.delete(instanceKey);
376
+ entry = void 0;
377
+ }
378
+ if (entry && countRef) entry.refCount++;
379
+ if (entry) return entry.instance;
380
+ if (!canCreate) throw new Error(`${BLAC_ERROR_PREFIX} ${Type.name} instance "${instanceKey}" not found and creation is disabled.`);
381
+ const instance = new Type();
382
+ instance.initConfig(config);
383
+ instances.set(instanceKey, {
384
+ instance,
385
+ refCount: 1
386
+ });
387
+ this.registerType(Type);
388
+ return instance;
389
+ }
390
+ /**
391
+ * Borrow an existing instance without incrementing ref count (borrowing semantics).
392
+ * Tracks cross-bloc dependency for reactive updates.
393
+ * @param Type - The StateContainer class constructor
394
+ * @param instanceKey - Instance key (defaults to 'default')
395
+ * @returns The state container instance
396
+ * @throws Error if instance doesn't exist
397
+ */
398
+ borrow(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
399
+ return this.acquire(Type, instanceKey, {
400
+ canCreate: false,
401
+ countRef: false
402
+ });
403
+ }
404
+ /**
405
+ * Safely borrow an existing instance (borrowing semantics with error handling).
406
+ * Returns discriminated union for type-safe conditional access.
407
+ * @param Type - The StateContainer class constructor
408
+ * @param instanceKey - Instance key (defaults to 'default')
409
+ * @returns Discriminated union with either the instance or an error
410
+ */
411
+ borrowSafe(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
412
+ try {
413
+ return {
414
+ error: null,
415
+ instance: this.borrow(Type, instanceKey)
416
+ };
417
+ } catch (error) {
418
+ return {
419
+ error,
420
+ instance: null
421
+ };
422
+ }
423
+ }
424
+ /**
425
+ * Ensure an instance exists without taking ownership (for bloc-to-bloc communication).
426
+ * Gets existing instance OR creates it if it doesn't exist, without incrementing ref count.
427
+ * Tracks cross-bloc dependency for reactive updates.
428
+ *
429
+ * Use this in bloc-to-bloc communication when you need to ensure an instance exists
430
+ * but don't want to claim ownership (no ref count increment).
431
+ * @param Type - The StateContainer class constructor
432
+ * @param instanceKey - Instance key (defaults to 'default')
433
+ * @returns The state container instance
434
+ */
435
+ ensure(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
436
+ return this.acquire(Type, instanceKey, {
437
+ canCreate: true,
438
+ countRef: false
439
+ });
440
+ }
441
+ /**
442
+ * Release a reference to an instance.
443
+ * Decrements ref count and disposes when it reaches 0 (unless keepAlive).
444
+ * @param Type - The StateContainer class constructor
445
+ * @param instanceKey - Instance key (defaults to 'default')
446
+ * @param forceDispose - Force immediate disposal regardless of ref count
447
+ */
448
+ release(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY, forceDispose = false) {
449
+ const instances = this.ensureInstancesMap(Type);
450
+ const entry = instances.get(instanceKey);
451
+ if (!entry) return;
452
+ if (forceDispose) {
453
+ if (!entry.instance.isDisposed) entry.instance.dispose();
454
+ instances.delete(instanceKey);
455
+ return;
456
+ }
457
+ entry.refCount--;
458
+ const keepAlive = isKeepAliveClass(Type);
459
+ if (entry.refCount <= 0 && !keepAlive) {
460
+ if (!entry.instance.isDisposed) entry.instance.dispose();
461
+ instances.delete(instanceKey);
462
+ }
463
+ }
464
+ /**
465
+ * Get all instances of a specific type.
466
+ * @param Type - The StateContainer class constructor
467
+ * @returns Array of all instances
468
+ */
469
+ getAll(Type) {
470
+ const instances = this.ensureInstancesMap(Type);
471
+ const result = [];
472
+ for (const entry of instances.values()) result.push(entry.instance);
473
+ return result;
474
+ }
475
+ /**
476
+ * Safely iterate over all instances of a type.
477
+ * Skips disposed instances and catches callback errors.
478
+ * @param Type - The StateContainer class constructor
479
+ * @param callback - Function to call for each instance
480
+ */
481
+ forEach(Type, callback) {
482
+ const instances = this.ensureInstancesMap(Type);
483
+ for (const entry of instances.values()) {
484
+ const instance = entry.instance;
485
+ if (!instance.isDisposed) try {
486
+ callback(instance);
487
+ } catch (error) {
488
+ console.error(`${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`, error);
489
+ }
490
+ }
491
+ }
492
+ /**
493
+ * Clear all instances of a specific type (disposes them).
494
+ * @param Type - The StateContainer class constructor
495
+ */
496
+ clear(Type) {
497
+ const instances = this.ensureInstancesMap(Type);
498
+ for (const entry of instances.values()) if (!entry.instance.isDisposed) entry.instance.dispose();
499
+ instances.clear();
500
+ }
501
+ /**
502
+ * Get reference count for an instance.
503
+ * @param Type - The StateContainer class constructor
504
+ * @param instanceKey - Instance key (defaults to 'default')
505
+ * @returns Current ref count (0 if instance doesn't exist)
506
+ */
507
+ getRefCount(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
508
+ return this.ensureInstancesMap(Type).get(instanceKey)?.refCount ?? 0;
509
+ }
510
+ /**
511
+ * Check if an instance exists.
512
+ * @param Type - The StateContainer class constructor
513
+ * @param instanceKey - Instance key (defaults to 'default')
514
+ * @returns true if instance exists
515
+ */
516
+ hasInstance(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
517
+ return this.ensureInstancesMap(Type).has(instanceKey);
518
+ }
519
+ /**
520
+ * Clear all instances from all types (for testing)
521
+ *
522
+ * Iterates all registered types and clears their instances.
523
+ * Also clears type tracking to reset the registry state.
524
+ */
525
+ clearAll() {
526
+ for (const Type of this.types) this.clear(Type);
527
+ this.types.clear();
528
+ this.typeConfigs.clear();
529
+ }
530
+ /**
531
+ * Get registry statistics for debugging.
532
+ * @returns Object with registeredTypes, totalInstances, and typeBreakdown
533
+ */
534
+ getStats() {
535
+ const typeBreakdown = {};
536
+ let totalInstances = 0;
537
+ for (const Type of this.types) {
538
+ const typeName = Type.name;
539
+ const count = this.getInstancesMap(Type).size;
540
+ typeBreakdown[typeName] = count;
541
+ totalInstances += count;
542
+ }
543
+ return {
544
+ registeredTypes: this.types.size,
545
+ totalInstances,
546
+ typeBreakdown
547
+ };
548
+ }
549
+ /**
550
+ * Get all registered types (for plugin system).
551
+ * @returns Array of all registered StateContainer class constructors
552
+ */
553
+ getTypes() {
554
+ return Array.from(this.types);
555
+ }
556
+ /**
557
+ * Subscribe to lifecycle events
558
+ * @param event - The lifecycle event to listen for
559
+ * @param listener - The listener function to call when the event occurs
560
+ * @returns Unsubscribe function
561
+ */
562
+ on(event, listener) {
563
+ if (!this.listeners.has(event)) this.listeners.set(event, /* @__PURE__ */ new Set());
564
+ const instance = this.listeners.get(event);
565
+ if (!instance) throw new Error(`${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`);
566
+ instance.add(listener);
567
+ return () => {
568
+ this.listeners.get(event)?.delete(listener);
569
+ };
570
+ }
571
+ /**
572
+ * Emit lifecycle event to all listeners
573
+ * @internal - Called by StateContainer lifecycle methods
574
+ */
575
+ emit(event, ...args) {
576
+ const listeners = this.listeners.get(event);
577
+ if (!listeners || listeners.size === 0) return;
578
+ for (const listener of listeners) try {
579
+ listener(...args);
580
+ } catch (error) {
581
+ console.error(`${BLAC_ERROR_PREFIX} Listener error for '${event}':`, error);
582
+ }
583
+ }
584
+ };
585
+ /**
586
+ * Global default registry instance
587
+ */
588
+ const globalRegistry = new StateContainerRegistry();
589
+ /**
590
+ * Global plugin manager (initialized lazily)
591
+ */
592
+ let _globalPluginManager = null;
593
+ /**
594
+ * Get the global plugin manager
595
+ */
596
+ function getPluginManager() {
597
+ if (!_globalPluginManager) _globalPluginManager = createPluginManager(globalRegistry);
598
+ return _globalPluginManager;
599
+ }
600
+
40
601
  //#endregion
41
602
  //#region src/core/StateContainer.ts
603
+ const EMPTY_DEPS = /* @__PURE__ */ new Map();
42
604
  /**
43
605
  * Abstract base class for all state containers in BlaC.
44
606
  * Provides lifecycle management, subscription handling, ref counting,
@@ -65,6 +627,14 @@ var StateContainer = class StateContainer {
65
627
  static {
66
628
  this.enableStackTrace = true;
67
629
  }
630
+ get dependencies() {
631
+ return this._dependencies ?? EMPTY_DEPS;
632
+ }
633
+ depend(Type, instanceKey) {
634
+ if (!this._dependencies) this._dependencies = /* @__PURE__ */ new Map();
635
+ this._dependencies.set(Type, instanceKey ?? BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY);
636
+ return () => globalRegistry.ensure(Type, instanceKey);
637
+ }
68
638
  constructor(initialState) {
69
639
  this.listeners = /* @__PURE__ */ new Set();
70
640
  this._disposed = false;
@@ -74,6 +644,7 @@ var StateContainer = class StateContainer {
74
644
  this.debug = false;
75
645
  this.instanceId = generateSimpleId(this.constructor.name, "main");
76
646
  this.createdAt = Date.now();
647
+ this._dependencies = null;
77
648
  this.lastUpdateTimestamp = Date.now();
78
649
  this.onSystemEvent = (event, handler) => {
79
650
  let handlers = this.systemEventHandlers.get(event);
@@ -98,7 +669,7 @@ var StateContainer = class StateContainer {
98
669
  this.name = this.config.name || this.constructor.name;
99
670
  this.debug = this.config.debug ?? false;
100
671
  this.instanceId = generateSimpleId(this.constructor.name, this.config.instanceId);
101
- require_StateContainerRegistry.globalRegistry.emit("created", this);
672
+ globalRegistry.emit("created", this);
102
673
  }
103
674
  /** Current state value */
104
675
  get state() {
@@ -129,7 +700,7 @@ var StateContainer = class StateContainer {
129
700
  this.emitSystemEvent("dispose", void 0);
130
701
  this.listeners.clear();
131
702
  this.systemEventHandlers.clear();
132
- require_StateContainerRegistry.globalRegistry.emit("disposed", this);
703
+ globalRegistry.emit("disposed", this);
133
704
  if (this.debug) console.log(`[${this.name}] Disposed successfully`);
134
705
  }
135
706
  /**
@@ -152,7 +723,7 @@ var StateContainer = class StateContainer {
152
723
  console.error(`[${this.name}] Error in listener:`, error);
153
724
  }
154
725
  const stackTrace = this.captureStackTrace();
155
- require_StateContainerRegistry.globalRegistry.emit("stateChanged", this, previousState, newState, stackTrace);
726
+ globalRegistry.emit("stateChanged", this, previousState, newState, stackTrace);
156
727
  this.lastUpdateTimestamp = Date.now();
157
728
  }
158
729
  captureStackTrace() {
@@ -226,8 +797,14 @@ var Cubit = class extends StateContainer {
226
797
  super(initialState);
227
798
  this.patch = ((partial) => {
228
799
  if (typeof this.state !== "object" || this.state === null) throw new Error("patch() is only available for object state types");
229
- this.update((current) => ({
230
- ...current,
800
+ const current = this.state;
801
+ let hasChanges = false;
802
+ for (const key in partial) if (!Object.is(current[key], partial[key])) {
803
+ hasChanges = true;
804
+ break;
805
+ }
806
+ if (hasChanges) this.update((c) => ({
807
+ ...c,
231
808
  ...partial
232
809
  }));
233
810
  });
@@ -251,7 +828,7 @@ var Cubit = class extends StateContainer {
251
828
  //#endregion
252
829
  //#region src/registry/acquire.ts
253
830
  function acquire(BlocClass, instanceKey) {
254
- return require_StateContainerRegistry.globalRegistry.acquire(BlocClass, instanceKey, {
831
+ return globalRegistry.acquire(BlocClass, instanceKey, {
255
832
  canCreate: true,
256
833
  countRef: true
257
834
  });
@@ -260,16 +837,63 @@ function acquire(BlocClass, instanceKey) {
260
837
  //#endregion
261
838
  //#region src/registry/borrow.ts
262
839
  function borrow(BlocClass, instanceKey) {
263
- return require_StateContainerRegistry.globalRegistry.borrow(BlocClass, instanceKey);
840
+ return globalRegistry.borrow(BlocClass, instanceKey);
264
841
  }
265
842
  function borrowSafe(BlocClass, instanceKey) {
266
- return require_StateContainerRegistry.globalRegistry.borrowSafe(BlocClass, instanceKey);
843
+ return globalRegistry.borrowSafe(BlocClass, instanceKey);
844
+ }
845
+
846
+ //#endregion
847
+ //#region src/registry/ensure.ts
848
+ function ensure(BlocClass, instanceKey) {
849
+ return globalRegistry.ensure(BlocClass, instanceKey);
267
850
  }
268
851
 
269
852
  //#endregion
270
853
  //#region src/registry/release.ts
271
854
  function release(BlocClass, instanceKey, forceDispose = false) {
272
- require_StateContainerRegistry.globalRegistry.release(BlocClass, instanceKey, forceDispose);
855
+ globalRegistry.release(BlocClass, instanceKey, forceDispose);
856
+ }
857
+
858
+ //#endregion
859
+ //#region src/registry/queries.ts
860
+ function hasInstance(BlocClass, instanceKey) {
861
+ return globalRegistry.hasInstance(BlocClass, instanceKey);
862
+ }
863
+ function getRefCount(BlocClass, instanceKey) {
864
+ return globalRegistry.getRefCount(BlocClass, instanceKey);
865
+ }
866
+ function getAll(BlocClass) {
867
+ return globalRegistry.getAll(BlocClass);
868
+ }
869
+ function forEach(BlocClass, callback) {
870
+ globalRegistry.forEach(BlocClass, callback);
871
+ }
872
+
873
+ //#endregion
874
+ //#region src/registry/management.ts
875
+ function clear(BlocClass) {
876
+ globalRegistry.clear(BlocClass);
877
+ }
878
+ function clearAll() {
879
+ globalRegistry.clearAll();
880
+ }
881
+ function register(BlocClass, isolated = false) {
882
+ globalRegistry.register(BlocClass, isolated);
883
+ }
884
+
885
+ //#endregion
886
+ //#region src/registry/config.ts
887
+ let _registry = globalRegistry;
888
+ function getRegistry() {
889
+ return _registry;
890
+ }
891
+ function setRegistry(registry) {
892
+ _registry.clearAll();
893
+ _registry = registry;
894
+ }
895
+ function getStats() {
896
+ return _registry.getStats();
273
897
  }
274
898
 
275
899
  //#endregion
@@ -298,49 +922,887 @@ function release(BlocClass, instanceKey, forceDispose = false) {
298
922
  */
299
923
  function blac(options) {
300
924
  return function(target, _context) {
301
- if ("isolated" in options && options.isolated) target[require_tracking_proxy.BLAC_STATIC_PROPS.ISOLATED] = true;
302
- if ("keepAlive" in options && options.keepAlive) target[require_tracking_proxy.BLAC_STATIC_PROPS.KEEP_ALIVE] = true;
303
- if ("excludeFromDevTools" in options && options.excludeFromDevTools) target[require_tracking_proxy.BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;
925
+ if ("isolated" in options && options.isolated) target[BLAC_STATIC_PROPS.ISOLATED] = true;
926
+ if ("keepAlive" in options && options.keepAlive) target[BLAC_STATIC_PROPS.KEEP_ALIVE] = true;
927
+ if ("excludeFromDevTools" in options && options.excludeFromDevTools) target[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;
304
928
  return target;
305
929
  };
306
930
  }
307
931
 
932
+ //#endregion
933
+ //#region src/tracking/path-utils.ts
934
+ /**
935
+ * Path utilities for dependency tracking
936
+ *
937
+ * Provides utilities for parsing property paths and extracting values
938
+ * from nested objects using path strings.
939
+ *
940
+ * @internal
941
+ */
942
+ /**
943
+ * Parse a property path string into an array of segments
944
+ *
945
+ * @internal
946
+ *
947
+ * Handles both dot notation (a.b.c) and bracket notation (a[0].b)
948
+ *
949
+ * @example
950
+ * ```ts
951
+ * parsePath('user.name') // ['user', 'name']
952
+ * parsePath('items[0].name') // ['items', '0', 'name']
953
+ * parsePath('data.users[2].address.city') // ['data', 'users', '2', 'address', 'city']
954
+ * ```
955
+ */
956
+ function parsePath(path) {
957
+ const segments = [];
958
+ let current = "";
959
+ let i = 0;
960
+ while (i < path.length) {
961
+ const char = path[i];
962
+ if (char === ".") {
963
+ if (current) segments.push(current);
964
+ current = "";
965
+ } else if (char === "[") {
966
+ if (current) segments.push(current);
967
+ current = "";
968
+ i++;
969
+ while (i < path.length && path[i] !== "]") current += path[i++];
970
+ if (current) segments.push(current);
971
+ current = "";
972
+ } else current += char;
973
+ i++;
974
+ }
975
+ if (current) segments.push(current);
976
+ return segments;
977
+ }
978
+ /**
979
+ * Get a value from an object using a path of segments
980
+ *
981
+ * @example
982
+ * ```ts
983
+ * const obj = { user: { name: 'Alice', age: 30 } }
984
+ * getValueAtPath(obj, ['user', 'name']) // 'Alice'
985
+ * getValueAtPath(obj, ['user', 'age']) // 30
986
+ * getValueAtPath(obj, ['user', 'missing']) // undefined
987
+ * ```
988
+ *
989
+ * @internal
990
+ */
991
+ function getValueAtPath(obj, segments) {
992
+ if (obj == null) return void 0;
993
+ let current = obj;
994
+ for (let i = 0; i < segments.length; i++) {
995
+ current = current[segments[i]];
996
+ if (current == null) return void 0;
997
+ }
998
+ return current;
999
+ }
1000
+ /**
1001
+ * Shallow equality comparison for arrays
1002
+ *
1003
+ * Compares two arrays element-by-element using Object.is
1004
+ *
1005
+ * @example
1006
+ * ```ts
1007
+ * shallowEqual([1, 2, 3], [1, 2, 3]) // true
1008
+ * shallowEqual([1, 2, 3], [1, 2, 4]) // false
1009
+ * shallowEqual([1, 2], [1, 2, 3]) // false
1010
+ * ```
1011
+ *
1012
+ * @internal
1013
+ */
1014
+ function shallowEqual(arr1, arr2) {
1015
+ if (arr1.length !== arr2.length) return false;
1016
+ for (let i = 0; i < arr1.length; i++) if (!Object.is(arr1[i], arr2[i])) return false;
1017
+ return true;
1018
+ }
1019
+
1020
+ //#endregion
1021
+ //#region src/tracking/tracking-proxy.ts
1022
+ /**
1023
+ * Consolidated Tracking System
1024
+ *
1025
+ * This module provides all dependency and getter tracking functionality:
1026
+ * - Proxy creation for automatic property access tracking
1027
+ * - Dependency path tracking and change detection
1028
+ * - Getter execution tracking for computed properties
1029
+ * - Combined tracking proxy for watch/waitUntil use cases
1030
+ */
1031
+ /**
1032
+ * Check if a value can be proxied
1033
+ * Returns true for plain objects and arrays only.
1034
+ * @internal
1035
+ */
1036
+ function isProxyable(value) {
1037
+ if (typeof value !== "object" || value === null) return false;
1038
+ const proto = Object.getPrototypeOf(value);
1039
+ return proto === Object.prototype || proto === Array.prototype;
1040
+ }
1041
+ /**
1042
+ * Create a new proxy tracker state
1043
+ * @internal
1044
+ */
1045
+ function createProxyState() {
1046
+ return {
1047
+ trackedPaths: /* @__PURE__ */ new Set(),
1048
+ isTracking: false,
1049
+ proxyCache: /* @__PURE__ */ new WeakMap(),
1050
+ boundFunctionsCache: null,
1051
+ lastProxiedState: null,
1052
+ lastProxy: null,
1053
+ maxDepth: 10
1054
+ };
1055
+ }
1056
+ /**
1057
+ * Start tracking property accesses
1058
+ * @internal
1059
+ */
1060
+ function startProxy(state) {
1061
+ state.isTracking = true;
1062
+ state.trackedPaths.clear();
1063
+ }
1064
+ /**
1065
+ * Stop tracking and return the tracked paths
1066
+ * @internal
1067
+ */
1068
+ function stopProxy(state) {
1069
+ state.isTracking = false;
1070
+ return new Set(state.trackedPaths);
1071
+ }
1072
+ /**
1073
+ * Create a proxy for an array with property access tracking
1074
+ * @internal
1075
+ */
1076
+ function createArrayProxy(state, target, path, depth = 0) {
1077
+ const proxy = new Proxy(target, { get: (arr, prop) => {
1078
+ if (typeof prop === "symbol") return Reflect.get(arr, prop);
1079
+ const value = Reflect.get(arr, prop);
1080
+ if (typeof value === "function") {
1081
+ if (!state.boundFunctionsCache) state.boundFunctionsCache = /* @__PURE__ */ new WeakMap();
1082
+ const cached = state.boundFunctionsCache.get(value);
1083
+ if (cached) return cached;
1084
+ const bound = value.bind(arr);
1085
+ state.boundFunctionsCache.set(value, bound);
1086
+ return bound;
1087
+ }
1088
+ if (prop === "length") {
1089
+ if (state.isTracking) {
1090
+ const fullPath = path ? `${path}.length` : "length";
1091
+ state.trackedPaths.add(fullPath);
1092
+ }
1093
+ return value;
1094
+ }
1095
+ let fullPath;
1096
+ if (typeof prop === "string") {
1097
+ const index = Number(prop);
1098
+ if (!isNaN(index) && index >= 0) fullPath = path ? `${path}[${index}]` : `[${index}]`;
1099
+ else fullPath = path ? `${path}.${prop}` : prop;
1100
+ } else return value;
1101
+ if (isProxyable(value)) return createInternal(state, value, fullPath, depth + 1);
1102
+ if (state.isTracking) state.trackedPaths.add(fullPath);
1103
+ return value;
1104
+ } });
1105
+ state.proxyCache.set(target, proxy);
1106
+ return proxy;
1107
+ }
1108
+ /**
1109
+ * Create a proxy for an object with property access tracking
1110
+ * @internal
1111
+ */
1112
+ function createInternal(state, target, path = "", depth = 0) {
1113
+ if (!state.isTracking || !isProxyable(target)) return target;
1114
+ if (depth >= state.maxDepth) return target;
1115
+ if (state.proxyCache.has(target)) return state.proxyCache.get(target);
1116
+ if (Array.isArray(target)) return createArrayProxy(state, target, path, depth);
1117
+ const proxy = new Proxy(target, {
1118
+ get: (obj, prop) => {
1119
+ if (typeof prop === "symbol") return Reflect.get(obj, prop);
1120
+ const value = Reflect.get(obj, prop);
1121
+ if (typeof value === "function") {
1122
+ if (!state.boundFunctionsCache) state.boundFunctionsCache = /* @__PURE__ */ new WeakMap();
1123
+ const cached = state.boundFunctionsCache.get(value);
1124
+ if (cached) return cached;
1125
+ const bound = value.bind(obj);
1126
+ state.boundFunctionsCache.set(value, bound);
1127
+ return bound;
1128
+ }
1129
+ const fullPath = path ? `${path}.${String(prop)}` : String(prop);
1130
+ if (typeof prop === "string" && state.isTracking) {
1131
+ if (!prop.startsWith("_") && !prop.startsWith("$$")) state.trackedPaths.add(fullPath);
1132
+ }
1133
+ if (isProxyable(value)) return createInternal(state, value, fullPath, depth + 1);
1134
+ return value;
1135
+ },
1136
+ has: (obj, prop) => {
1137
+ if (typeof prop === "string" && state.isTracking) {
1138
+ const fullPath = path ? `${path}.${prop}` : prop;
1139
+ state.trackedPaths.add(fullPath);
1140
+ }
1141
+ return Reflect.has(obj, prop);
1142
+ },
1143
+ ownKeys: (obj) => {
1144
+ if (state.isTracking && path) state.trackedPaths.add(path);
1145
+ return Reflect.ownKeys(obj);
1146
+ }
1147
+ });
1148
+ state.proxyCache.set(target, proxy);
1149
+ return proxy;
1150
+ }
1151
+ /**
1152
+ * Create a proxy for a target with caching
1153
+ * @internal
1154
+ */
1155
+ function createForTarget(state, target) {
1156
+ if (state.lastProxiedState === target && state.lastProxy) return state.lastProxy;
1157
+ state.proxyCache = /* @__PURE__ */ new WeakMap();
1158
+ state.boundFunctionsCache = null;
1159
+ const proxy = createInternal(state, target, "", 0);
1160
+ state.lastProxiedState = target;
1161
+ state.lastProxy = proxy;
1162
+ return proxy;
1163
+ }
1164
+ function isChildPath(child, parent) {
1165
+ if (child === parent) return false;
1166
+ return child.startsWith(parent + ".") || child.startsWith(parent + "[");
1167
+ }
1168
+ function getArrayParentPath(path) {
1169
+ if (path.endsWith(".length")) return path.slice(0, -7);
1170
+ const arrayIndexMatch = path.match(/^(.+?)\[\d+\]/);
1171
+ if (arrayIndexMatch) return arrayIndexMatch[1];
1172
+ return null;
1173
+ }
1174
+ /**
1175
+ * @internal
1176
+ */
1177
+ function optimizeTrackedPaths(paths) {
1178
+ if (paths.size === 0) return /* @__PURE__ */ new Set();
1179
+ if (paths.size === 1) return new Set(paths);
1180
+ const sortedPaths = Array.from(paths).sort((a, b) => b.length - a.length);
1181
+ const optimized = /* @__PURE__ */ new Set();
1182
+ for (const path of sortedPaths) {
1183
+ let hasMoreSpecificChild = false;
1184
+ for (const optimizedPath of optimized) if (isChildPath(optimizedPath, path)) {
1185
+ hasMoreSpecificChild = true;
1186
+ break;
1187
+ }
1188
+ if (!hasMoreSpecificChild) optimized.add(path);
1189
+ }
1190
+ const arrayParents = /* @__PURE__ */ new Set();
1191
+ for (const path of optimized) {
1192
+ const arrayParent = getArrayParentPath(path);
1193
+ if (arrayParent) arrayParents.add(arrayParent);
1194
+ }
1195
+ for (const arrayParent of arrayParents) optimized.add(arrayParent);
1196
+ return optimized;
1197
+ }
1198
+ /**
1199
+ * @internal
1200
+ */
1201
+ function createDependencyState() {
1202
+ return {
1203
+ proxyState: createProxyState(),
1204
+ previousRenderPaths: /* @__PURE__ */ new Set(),
1205
+ currentRenderPaths: /* @__PURE__ */ new Set(),
1206
+ pathCache: /* @__PURE__ */ new Map(),
1207
+ lastCheckedState: null,
1208
+ lastCheckedValues: /* @__PURE__ */ new Map()
1209
+ };
1210
+ }
1211
+ /**
1212
+ * @internal
1213
+ */
1214
+ function startDependency(tracker) {
1215
+ startProxy(tracker.proxyState);
1216
+ }
1217
+ /**
1218
+ * @internal
1219
+ */
1220
+ function createDependencyProxy(tracker, state) {
1221
+ return createForTarget(tracker.proxyState, state);
1222
+ }
1223
+ /**
1224
+ * @internal
1225
+ */
1226
+ function capturePaths(tracker, state) {
1227
+ tracker.previousRenderPaths = tracker.currentRenderPaths;
1228
+ tracker.currentRenderPaths = optimizeTrackedPaths(stopProxy(tracker.proxyState));
1229
+ if (tracker.previousRenderPaths.size === 0 && tracker.currentRenderPaths.size === 0) return;
1230
+ const trackedPathsUnion = new Set(tracker.previousRenderPaths);
1231
+ for (const path of tracker.currentRenderPaths) trackedPathsUnion.add(path);
1232
+ const canReuseCache = tracker.lastCheckedState === state;
1233
+ for (const path of trackedPathsUnion) if (!tracker.pathCache.has(path)) {
1234
+ const segments = parsePath(path);
1235
+ const value = canReuseCache && tracker.lastCheckedValues.has(path) ? tracker.lastCheckedValues.get(path) : getValueAtPath(state, segments);
1236
+ tracker.pathCache.set(path, {
1237
+ segments,
1238
+ value
1239
+ });
1240
+ } else {
1241
+ const info = tracker.pathCache.get(path);
1242
+ info.value = canReuseCache && tracker.lastCheckedValues.has(path) ? tracker.lastCheckedValues.get(path) : getValueAtPath(state, info.segments);
1243
+ }
1244
+ tracker.lastCheckedValues.clear();
1245
+ }
1246
+ /**
1247
+ * @internal
1248
+ */
1249
+ function hasDependencyChanges(tracker, state) {
1250
+ if (tracker.pathCache.size === 0) return true;
1251
+ tracker.lastCheckedValues.clear();
1252
+ for (const [path, info] of tracker.pathCache.entries()) {
1253
+ const currentValue = getValueAtPath(state, info.segments);
1254
+ tracker.lastCheckedValues.set(path, currentValue);
1255
+ if (!Object.is(currentValue, info.value)) {
1256
+ tracker.lastCheckedState = state;
1257
+ return true;
1258
+ }
1259
+ }
1260
+ tracker.lastCheckedState = state;
1261
+ return false;
1262
+ }
1263
+ /**
1264
+ * @internal
1265
+ */
1266
+ function hasTrackedData(tracker) {
1267
+ return tracker.proxyState.trackedPaths.size > 0 || tracker.pathCache.size > 0 || tracker.previousRenderPaths.size > 0;
1268
+ }
1269
+ const descriptorCache = /* @__PURE__ */ new WeakMap();
1270
+ const blocProxyCache = /* @__PURE__ */ new WeakMap();
1271
+ const activeTrackerMap = /* @__PURE__ */ new WeakMap();
1272
+ const MAX_GETTER_DEPTH = BLAC_DEFAULTS.MAX_GETTER_DEPTH;
1273
+ /**
1274
+ * @internal
1275
+ */
1276
+ function getDescriptor(obj, prop) {
1277
+ const constructor = obj.constructor;
1278
+ let constructorCache = descriptorCache.get(constructor);
1279
+ if (constructorCache?.has(prop)) return constructorCache.get(prop);
1280
+ let current = obj;
1281
+ let descriptor;
1282
+ while (current && current !== Object.prototype) {
1283
+ descriptor = Object.getOwnPropertyDescriptor(current, prop);
1284
+ if (descriptor) break;
1285
+ current = Object.getPrototypeOf(current);
1286
+ }
1287
+ if (!constructorCache) {
1288
+ constructorCache = /* @__PURE__ */ new Map();
1289
+ descriptorCache.set(constructor, constructorCache);
1290
+ }
1291
+ constructorCache.set(prop, descriptor);
1292
+ return descriptor;
1293
+ }
1294
+ /**
1295
+ * @internal
1296
+ */
1297
+ function isGetter(obj, prop) {
1298
+ return getDescriptor(obj, prop)?.get !== void 0;
1299
+ }
1300
+ /**
1301
+ * @internal
1302
+ */
1303
+ function createGetterState() {
1304
+ return {
1305
+ trackedValues: /* @__PURE__ */ new Map(),
1306
+ currentlyAccessing: /* @__PURE__ */ new Set(),
1307
+ trackedGetters: /* @__PURE__ */ new Set(),
1308
+ isTracking: false,
1309
+ renderCache: /* @__PURE__ */ new Map(),
1310
+ cacheValid: false,
1311
+ depth: 0,
1312
+ visitedBlocs: /* @__PURE__ */ new Set()
1313
+ };
1314
+ }
1315
+ /**
1316
+ * @internal
1317
+ */
1318
+ function setActiveTracker(bloc, tracker) {
1319
+ activeTrackerMap.set(bloc, tracker);
1320
+ }
1321
+ /**
1322
+ * @internal
1323
+ */
1324
+ function clearActiveTracker(bloc) {
1325
+ activeTrackerMap.delete(bloc);
1326
+ }
1327
+ /**
1328
+ * @internal
1329
+ */
1330
+ function commitTrackedGetters(tracker) {
1331
+ if (tracker.currentlyAccessing.size > 0) tracker.trackedGetters = new Set(tracker.currentlyAccessing);
1332
+ tracker.currentlyAccessing.clear();
1333
+ }
1334
+ /**
1335
+ * Execute a tracked getter with depth/circular dependency checks and context management.
1336
+ * @internal
1337
+ */
1338
+ function executeTrackedGetter(target, prop, tracker) {
1339
+ tracker.currentlyAccessing.add(prop);
1340
+ if (tracker.cacheValid && tracker.renderCache.has(prop)) {
1341
+ const cachedValue = tracker.renderCache.get(prop);
1342
+ tracker.trackedValues.set(prop, cachedValue);
1343
+ return cachedValue;
1344
+ }
1345
+ if (tracker.depth >= MAX_GETTER_DEPTH) {
1346
+ console.warn(`${BLAC_ERROR_PREFIX} Maximum getter depth (${MAX_GETTER_DEPTH}) exceeded. Possible circular dependency in getter "${String(prop)}" on ${target.constructor.name}.`);
1347
+ return;
1348
+ }
1349
+ if (tracker.visitedBlocs.has(target)) {
1350
+ console.warn(`${BLAC_ERROR_PREFIX} Circular dependency detected: getter "${String(prop)}" on ${target.constructor.name}.`);
1351
+ return;
1352
+ }
1353
+ const prevDepth = tracker.depth;
1354
+ const prevVisited = new Set(tracker.visitedBlocs);
1355
+ tracker.depth++;
1356
+ tracker.visitedBlocs.add(target);
1357
+ try {
1358
+ const value = getDescriptor(target, prop).get.call(target);
1359
+ tracker.trackedValues.set(prop, value);
1360
+ return value;
1361
+ } catch (error) {
1362
+ tracker.currentlyAccessing.delete(prop);
1363
+ throw error;
1364
+ } finally {
1365
+ tracker.depth = prevDepth;
1366
+ tracker.visitedBlocs = prevVisited;
1367
+ }
1368
+ }
1369
+ /**
1370
+ * @internal
1371
+ */
1372
+ function createBlocProxy(bloc) {
1373
+ const cached = blocProxyCache.get(bloc);
1374
+ if (cached) return cached;
1375
+ const proxy = new Proxy(bloc, { get(target, prop, receiver) {
1376
+ const tracker = activeTrackerMap.get(target);
1377
+ if (tracker?.isTracking && isGetter(target, prop)) return executeTrackedGetter(target, prop, tracker);
1378
+ return Reflect.get(target, prop, receiver);
1379
+ } });
1380
+ blocProxyCache.set(bloc, proxy);
1381
+ return proxy;
1382
+ }
1383
+ /**
1384
+ * @internal
1385
+ */
1386
+ function hasGetterChanges(bloc, tracker) {
1387
+ if (!tracker || tracker.trackedGetters.size === 0) return false;
1388
+ tracker.renderCache.clear();
1389
+ let hasAnyChange = false;
1390
+ for (const prop of tracker.trackedGetters) try {
1391
+ const descriptor = getDescriptor(bloc, prop);
1392
+ if (!descriptor?.get) continue;
1393
+ const newValue = descriptor.get.call(bloc);
1394
+ const oldValue = tracker.trackedValues.get(prop);
1395
+ tracker.renderCache.set(prop, newValue);
1396
+ tracker.trackedValues.set(prop, newValue);
1397
+ if (!Object.is(newValue, oldValue)) hasAnyChange = true;
1398
+ } catch (error) {
1399
+ console.warn(`${BLAC_ERROR_PREFIX} Getter "${String(prop)}" threw error during change detection. Stopping tracking for this getter.`, error);
1400
+ tracker.trackedGetters.delete(prop);
1401
+ tracker.trackedValues.delete(prop);
1402
+ tracker.cacheValid = false;
1403
+ return true;
1404
+ }
1405
+ tracker.cacheValid = true;
1406
+ return hasAnyChange;
1407
+ }
1408
+ /**
1409
+ * @internal
1410
+ */
1411
+ function invalidateRenderCache(tracker) {
1412
+ tracker.cacheValid = false;
1413
+ }
1414
+ /**
1415
+ * Create a new tracking proxy state.
1416
+ */
1417
+ function createState() {
1418
+ return {
1419
+ dependencyState: createDependencyState(),
1420
+ getterState: createGetterState(),
1421
+ dependencies: /* @__PURE__ */ new Set(),
1422
+ isTracking: false
1423
+ };
1424
+ }
1425
+ /**
1426
+ * Start tracking on a tracking proxy.
1427
+ */
1428
+ function startTracking(tracker) {
1429
+ tracker.isTracking = true;
1430
+ tracker.dependencies.clear();
1431
+ tracker.getterState.isTracking = true;
1432
+ startDependency(tracker.dependencyState);
1433
+ }
1434
+ /**
1435
+ * Stop tracking and collect all dependencies.
1436
+ */
1437
+ function stopTracking(tracker, bloc) {
1438
+ tracker.isTracking = false;
1439
+ tracker.getterState.isTracking = false;
1440
+ capturePaths(tracker.dependencyState, bloc.state);
1441
+ commitTrackedGetters(tracker.getterState);
1442
+ return new Set(tracker.dependencies);
1443
+ }
1444
+ /**
1445
+ * Check if tracked state or getters have changed.
1446
+ */
1447
+ function hasChanges(tracker, bloc) {
1448
+ invalidateRenderCache(tracker.getterState);
1449
+ const stateChanged = hasDependencyChanges(tracker.dependencyState, bloc.state);
1450
+ const getterChanged = hasGetterChanges(bloc, tracker.getterState);
1451
+ return stateChanged || getterChanged;
1452
+ }
1453
+ /**
1454
+ * Create a tracking proxy for a bloc instance.
1455
+ * Tracks both state property access and getter access.
1456
+ */
1457
+ function createTrackingProxy(bloc, tracker) {
1458
+ tracker.dependencies.add(bloc);
1459
+ const stateProxyCache = /* @__PURE__ */ new WeakMap();
1460
+ return new Proxy(bloc, { get(target, prop, receiver) {
1461
+ if (prop === "state") {
1462
+ if (!tracker.isTracking) return target.state;
1463
+ const rawState = target.state;
1464
+ if (rawState === null || typeof rawState !== "object") return rawState;
1465
+ if (stateProxyCache.has(rawState)) return stateProxyCache.get(rawState);
1466
+ const stateProxy = createDependencyProxy(tracker.dependencyState, rawState);
1467
+ stateProxyCache.set(rawState, stateProxy);
1468
+ return stateProxy;
1469
+ }
1470
+ if (typeof prop === "symbol") return Reflect.get(target, prop, receiver);
1471
+ const value = Reflect.get(target, prop, receiver);
1472
+ if (typeof value === "function") return value.bind(target);
1473
+ if (tracker.isTracking && isGetter(target, prop)) return executeTrackedGetter(target, prop, tracker.getterState);
1474
+ return value;
1475
+ } });
1476
+ }
1477
+
1478
+ //#endregion
1479
+ //#region src/tracking/dependency-manager.ts
1480
+ /**
1481
+ * Manages subscriptions to state container dependencies.
1482
+ * Provides efficient sync mechanism to add/remove subscriptions
1483
+ * as dependencies change between callback invocations.
1484
+ */
1485
+ var DependencyManager = class {
1486
+ constructor() {
1487
+ this.subscriptions = /* @__PURE__ */ new Map();
1488
+ this.currentDeps = /* @__PURE__ */ new Set();
1489
+ }
1490
+ /**
1491
+ * Sync subscriptions with a new set of dependencies.
1492
+ * Adds subscriptions for new deps, removes subscriptions for stale deps.
1493
+ *
1494
+ * @param newDeps - The new set of dependencies to subscribe to
1495
+ * @param onChange - Callback to invoke when any dependency changes
1496
+ * @param exclude - Optional instance to exclude from subscriptions (e.g., primary bloc)
1497
+ * @returns true if the dependency set changed, false if unchanged
1498
+ */
1499
+ sync(newDeps, onChange, exclude) {
1500
+ const filteredNewDeps = /* @__PURE__ */ new Set();
1501
+ for (const dep of newDeps) if (dep !== exclude && !dep.isDisposed) filteredNewDeps.add(dep);
1502
+ if (this.areSetsEqual(this.currentDeps, filteredNewDeps)) return false;
1503
+ for (const dep of this.currentDeps) if (!filteredNewDeps.has(dep)) {
1504
+ const unsub = this.subscriptions.get(dep);
1505
+ if (unsub) {
1506
+ unsub();
1507
+ this.subscriptions.delete(dep);
1508
+ }
1509
+ }
1510
+ for (const dep of filteredNewDeps) if (!this.currentDeps.has(dep) && !this.subscriptions.has(dep)) {
1511
+ const unsub = dep.subscribe(onChange);
1512
+ this.subscriptions.set(dep, unsub);
1513
+ }
1514
+ this.currentDeps = filteredNewDeps;
1515
+ return true;
1516
+ }
1517
+ /**
1518
+ * Add a single dependency subscription.
1519
+ */
1520
+ add(dep, onChange) {
1521
+ if (this.subscriptions.has(dep) || dep.isDisposed) return;
1522
+ const unsub = dep.subscribe(onChange);
1523
+ this.subscriptions.set(dep, unsub);
1524
+ this.currentDeps.add(dep);
1525
+ }
1526
+ /**
1527
+ * Check if a dependency is currently subscribed.
1528
+ */
1529
+ has(dep) {
1530
+ return this.currentDeps.has(dep);
1531
+ }
1532
+ /**
1533
+ * Get the current set of dependencies.
1534
+ */
1535
+ getDependencies() {
1536
+ return new Set(this.currentDeps);
1537
+ }
1538
+ /**
1539
+ * Clean up all active subscriptions.
1540
+ */
1541
+ cleanup() {
1542
+ for (const unsub of this.subscriptions.values()) unsub();
1543
+ this.subscriptions.clear();
1544
+ this.currentDeps.clear();
1545
+ }
1546
+ areSetsEqual(a, b) {
1547
+ if (a.size !== b.size) return false;
1548
+ for (const item of a) if (!b.has(item)) return false;
1549
+ return true;
1550
+ }
1551
+ };
1552
+
1553
+ //#endregion
1554
+ //#region src/tracking/resolve-dependencies.ts
1555
+ /**
1556
+ * Resolve all transitive dependencies of a bloc via BFS over `dependencies` maps.
1557
+ * Uses cycle detection to avoid infinite loops.
1558
+ * @internal
1559
+ */
1560
+ function resolveDependencies(bloc) {
1561
+ const result = /* @__PURE__ */ new Set();
1562
+ const visited = /* @__PURE__ */ new Set();
1563
+ const queue = [bloc];
1564
+ while (queue.length > 0) {
1565
+ const current = queue.shift();
1566
+ for (const [Type, key] of current.dependencies) {
1567
+ if (visited.has(Type)) continue;
1568
+ visited.add(Type);
1569
+ const dep = globalRegistry.ensure(Type, key);
1570
+ result.add(dep);
1571
+ if (dep.dependencies.size > 0) queue.push(dep);
1572
+ }
1573
+ }
1574
+ result.delete(bloc);
1575
+ return result;
1576
+ }
1577
+
1578
+ //#endregion
1579
+ //#region src/watch/watch.ts
1580
+ const STOP = Symbol("watch.STOP");
1581
+ const BLOC_REF_MARKER = Symbol("BlocRef");
1582
+ /**
1583
+ * Create a reference to a specific bloc instance.
1584
+ *
1585
+ * @example
1586
+ * ```ts
1587
+ * watch(instance(UserBloc, 'user-123'), (userBloc) => {
1588
+ * console.log(userBloc.state.name);
1589
+ * });
1590
+ * ```
1591
+ */
1592
+ function instance(BlocClass, instanceId) {
1593
+ return {
1594
+ [BLOC_REF_MARKER]: true,
1595
+ blocClass: BlocClass,
1596
+ instanceId
1597
+ };
1598
+ }
1599
+ function isBlocRef(input) {
1600
+ return typeof input === "object" && input !== null && BLOC_REF_MARKER in input;
1601
+ }
1602
+ function resolveBloc(input) {
1603
+ if (isBlocRef(input)) return ensure(input.blocClass, input.instanceId);
1604
+ return ensure(input, BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY);
1605
+ }
1606
+ function isArray(input) {
1607
+ return Array.isArray(input);
1608
+ }
1609
+ function watchImpl(blocsOrBloc, callback) {
1610
+ const isSingle = !isArray(blocsOrBloc);
1611
+ const instances = (isSingle ? [blocsOrBloc] : blocsOrBloc).map(resolveBloc);
1612
+ const tracker = createState();
1613
+ const proxiedInstances = instances.map((inst) => createTrackingProxy(inst, tracker));
1614
+ const externalDepsManager = new DependencyManager();
1615
+ let disposed = false;
1616
+ const primarySubscriptions = [];
1617
+ const cleanup = () => {
1618
+ if (disposed) return;
1619
+ disposed = true;
1620
+ primarySubscriptions.forEach((unsub) => unsub());
1621
+ externalDepsManager.cleanup();
1622
+ };
1623
+ const runCallback = () => {
1624
+ if (disposed) return;
1625
+ startTracking(tracker);
1626
+ let result;
1627
+ try {
1628
+ result = callback(isSingle ? proxiedInstances[0] : proxiedInstances);
1629
+ } finally {
1630
+ const externalDeps = /* @__PURE__ */ new Set();
1631
+ for (const inst of instances) {
1632
+ const deps = stopTracking(tracker, inst);
1633
+ for (const dep of deps) externalDeps.add(dep);
1634
+ for (const dep of resolveDependencies(inst)) externalDeps.add(dep);
1635
+ }
1636
+ for (const inst of instances) externalDeps.delete(inst);
1637
+ externalDepsManager.sync(externalDeps, runCallback);
1638
+ }
1639
+ if (result === STOP) cleanup();
1640
+ };
1641
+ const onChange = () => {
1642
+ if (disposed) return;
1643
+ runCallback();
1644
+ };
1645
+ for (const inst of instances) primarySubscriptions.push(inst.subscribe(onChange));
1646
+ runCallback();
1647
+ return cleanup;
1648
+ }
1649
+ const watch = Object.assign(watchImpl, { STOP });
1650
+
1651
+ //#endregion
1652
+ //#region src/tracking/tracked.ts
1653
+ /**
1654
+ * Run a callback while tracking all bloc dependencies accessed.
1655
+ * Returns both the result and the set of discovered dependencies.
1656
+ *
1657
+ * @example
1658
+ * ```ts
1659
+ * const { result, dependencies } = tracked(() => {
1660
+ * const user = ensure(UserBloc);
1661
+ * return user.fullName; // getter that may access other blocs
1662
+ * });
1663
+ * // dependencies contains UserBloc + any blocs accessed in fullName getter
1664
+ * ```
1665
+ */
1666
+ function tracked(callback, options) {
1667
+ const tracker = createState();
1668
+ startTracking(tracker);
1669
+ let result;
1670
+ try {
1671
+ result = callback();
1672
+ } finally {
1673
+ stopTracking(tracker, { state: null });
1674
+ }
1675
+ const dependencies = new Set(tracker.dependencies);
1676
+ if (options?.exclude) dependencies.delete(options.exclude);
1677
+ return {
1678
+ result,
1679
+ dependencies
1680
+ };
1681
+ }
1682
+ /**
1683
+ * Context for running tracked callbacks with bloc proxies.
1684
+ * Provides methods to create proxies and check for changes.
1685
+ */
1686
+ var TrackedContext = class {
1687
+ constructor() {
1688
+ this.proxiedBlocs = /* @__PURE__ */ new WeakMap();
1689
+ this.primaryBlocs = /* @__PURE__ */ new Set();
1690
+ this.tracker = createState();
1691
+ }
1692
+ /**
1693
+ * Get a tracking proxy for a bloc instance.
1694
+ * The proxy will track state and getter accesses.
1695
+ */
1696
+ proxy(bloc) {
1697
+ const cached = this.proxiedBlocs.get(bloc);
1698
+ if (cached) return cached;
1699
+ const proxied = createTrackingProxy(bloc, this.tracker);
1700
+ this.proxiedBlocs.set(bloc, proxied);
1701
+ this.primaryBlocs.add(bloc);
1702
+ return proxied;
1703
+ }
1704
+ /**
1705
+ * Start tracking for a new callback execution.
1706
+ */
1707
+ start() {
1708
+ startTracking(this.tracker);
1709
+ }
1710
+ /**
1711
+ * Stop tracking and get discovered dependencies.
1712
+ * Excludes primary blocs (those explicitly proxied via proxy()).
1713
+ */
1714
+ stop() {
1715
+ const allDeps = /* @__PURE__ */ new Set();
1716
+ for (const bloc of this.primaryBlocs) {
1717
+ const deps = stopTracking(this.tracker, bloc);
1718
+ for (const dep of deps) if (!this.primaryBlocs.has(dep)) allDeps.add(dep);
1719
+ }
1720
+ return allDeps;
1721
+ }
1722
+ /**
1723
+ * Check if any tracked state or getters have changed.
1724
+ */
1725
+ changed() {
1726
+ for (const bloc of this.primaryBlocs) if (hasChanges(this.tracker, bloc)) return true;
1727
+ return false;
1728
+ }
1729
+ /**
1730
+ * Get all primary blocs (those explicitly proxied).
1731
+ */
1732
+ getPrimaryBlocs() {
1733
+ return new Set(this.primaryBlocs);
1734
+ }
1735
+ /**
1736
+ * Reset the context for reuse.
1737
+ */
1738
+ reset() {
1739
+ this.tracker = createState();
1740
+ this.proxiedBlocs = /* @__PURE__ */ new WeakMap();
1741
+ this.primaryBlocs.clear();
1742
+ }
1743
+ };
1744
+ /**
1745
+ * Create a new tracked context for manual control over tracking.
1746
+ */
1747
+ function createTrackedContext() {
1748
+ return new TrackedContext();
1749
+ }
1750
+
1751
+ //#endregion
1752
+ //#region src/types/branded.ts
1753
+ /**
1754
+ * Create a branded InstanceId from a string
1755
+ * @param id - The string ID to brand
1756
+ * @returns Branded InstanceId
1757
+ */
1758
+ function instanceId(id) {
1759
+ return id;
1760
+ }
1761
+
308
1762
  //#endregion
309
1763
  exports.Cubit = Cubit;
310
- exports.DependencyManager = require_dependency_manager.DependencyManager;
311
- exports.PluginManager = require_StateContainerRegistry.PluginManager;
1764
+ exports.DependencyManager = DependencyManager;
1765
+ exports.PluginManager = PluginManager;
312
1766
  exports.StateContainer = StateContainer;
1767
+ exports.TrackedContext = TrackedContext;
313
1768
  exports.acquire = acquire;
314
1769
  exports.blac = blac;
315
1770
  exports.borrow = borrow;
316
1771
  exports.borrowSafe = borrowSafe;
317
- exports.capturePaths = require_tracking_proxy.capturePaths;
318
- exports.clear = require_management.clear;
319
- exports.clearActiveTracker = require_tracking_proxy.clearActiveTracker;
320
- exports.clearAll = require_management.clearAll;
321
- exports.clearExternalDependencies = require_tracking_proxy.clearExternalDependencies;
322
- exports.commitTrackedGetters = require_tracking_proxy.commitTrackedGetters;
323
- exports.createBlocProxy = require_tracking_proxy.createBlocProxy;
324
- exports.createDependencyProxy = require_tracking_proxy.createDependencyProxy;
325
- exports.createDependencyState = require_tracking_proxy.createDependencyState;
326
- exports.createGetterState = require_tracking_proxy.createGetterState;
327
- exports.ensure = require_watch.ensure;
328
- exports.forEach = require_management.forEach;
1772
+ exports.capturePaths = capturePaths;
1773
+ exports.clear = clear;
1774
+ exports.clearActiveTracker = clearActiveTracker;
1775
+ exports.clearAll = clearAll;
1776
+ exports.commitTrackedGetters = commitTrackedGetters;
1777
+ exports.createBlocProxy = createBlocProxy;
1778
+ exports.createDependencyProxy = createDependencyProxy;
1779
+ exports.createDependencyState = createDependencyState;
1780
+ exports.createGetterState = createGetterState;
1781
+ exports.createTrackedContext = createTrackedContext;
1782
+ exports.ensure = ensure;
1783
+ exports.forEach = forEach;
329
1784
  exports.generateIsolatedKey = generateIsolatedKey;
330
- exports.getAll = require_management.getAll;
331
- exports.getPluginManager = require_StateContainerRegistry.getPluginManager;
332
- exports.getRefCount = require_management.getRefCount;
333
- exports.globalRegistry = require_StateContainerRegistry.globalRegistry;
334
- exports.hasDependencyChanges = require_tracking_proxy.hasDependencyChanges;
335
- exports.hasGetterChanges = require_tracking_proxy.hasGetterChanges;
336
- exports.hasInstance = require_management.hasInstance;
337
- exports.hasTrackedData = require_tracking_proxy.hasTrackedData;
338
- exports.instance = require_watch.instance;
339
- exports.invalidateRenderCache = require_tracking_proxy.invalidateRenderCache;
340
- exports.isIsolatedClass = require_StateContainerRegistry.isIsolatedClass;
1785
+ exports.getAll = getAll;
1786
+ exports.getPluginManager = getPluginManager;
1787
+ exports.getRefCount = getRefCount;
1788
+ exports.getRegistry = getRegistry;
1789
+ exports.getStats = getStats;
1790
+ exports.globalRegistry = globalRegistry;
1791
+ exports.hasDependencyChanges = hasDependencyChanges;
1792
+ exports.hasGetterChanges = hasGetterChanges;
1793
+ exports.hasInstance = hasInstance;
1794
+ exports.hasTrackedData = hasTrackedData;
1795
+ exports.instance = instance;
1796
+ exports.instanceId = instanceId;
1797
+ exports.invalidateRenderCache = invalidateRenderCache;
1798
+ exports.isIsolatedClass = isIsolatedClass;
1799
+ exports.register = register;
341
1800
  exports.release = release;
342
- exports.setActiveTracker = require_tracking_proxy.setActiveTracker;
343
- exports.shallowEqual = require_tracking_proxy.shallowEqual;
344
- exports.startDependency = require_tracking_proxy.startDependency;
345
- exports.watch = require_watch.watch;
1801
+ exports.resolveDependencies = resolveDependencies;
1802
+ exports.setActiveTracker = setActiveTracker;
1803
+ exports.setRegistry = setRegistry;
1804
+ exports.shallowEqual = shallowEqual;
1805
+ exports.startDependency = startDependency;
1806
+ exports.tracked = tracked;
1807
+ exports.watch = watch;
346
1808
  //# sourceMappingURL=index.cjs.map