@blac/core 2.0.0-rc-16 → 2.0.0-rc.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 (157) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/Blac.d.ts +246 -0
  3. package/dist/Blac.d.ts.map +1 -0
  4. package/dist/Blac.js +625 -0
  5. package/dist/Blac.js.map +1 -0
  6. package/dist/Bloc.d.ts +41 -0
  7. package/dist/Bloc.d.ts.map +1 -0
  8. package/dist/Bloc.js +140 -0
  9. package/dist/Bloc.js.map +1 -0
  10. package/dist/BlocBase.d.ts +110 -0
  11. package/dist/BlocBase.d.ts.map +1 -0
  12. package/dist/BlocBase.js +287 -0
  13. package/dist/BlocBase.js.map +1 -0
  14. package/dist/Cubit.d.ts +25 -0
  15. package/dist/Cubit.d.ts.map +1 -0
  16. package/dist/Cubit.js +64 -0
  17. package/dist/Cubit.js.map +1 -0
  18. package/dist/adapter/BlacAdapter.d.ts +71 -0
  19. package/dist/adapter/BlacAdapter.d.ts.map +1 -0
  20. package/dist/adapter/BlacAdapter.js +373 -0
  21. package/dist/adapter/BlacAdapter.js.map +1 -0
  22. package/dist/adapter/ProxyFactory.d.ts +50 -0
  23. package/dist/adapter/ProxyFactory.d.ts.map +1 -0
  24. package/dist/adapter/ProxyFactory.js +150 -0
  25. package/dist/adapter/ProxyFactory.js.map +1 -0
  26. package/{src/adapter/index.ts → dist/adapter/index.d.ts} +1 -0
  27. package/dist/adapter/index.d.ts.map +1 -0
  28. package/dist/adapter/index.js +19 -0
  29. package/dist/adapter/index.js.map +1 -0
  30. package/dist/errors/BlacError.d.ts +38 -0
  31. package/dist/errors/BlacError.d.ts.map +1 -0
  32. package/dist/errors/BlacError.js +55 -0
  33. package/dist/errors/BlacError.js.map +1 -0
  34. package/dist/errors/ErrorManager.d.ts +39 -0
  35. package/dist/errors/ErrorManager.d.ts.map +1 -0
  36. package/dist/errors/ErrorManager.js +91 -0
  37. package/dist/errors/ErrorManager.js.map +1 -0
  38. package/dist/errors/handleError.d.ts +24 -0
  39. package/dist/errors/handleError.d.ts.map +1 -0
  40. package/dist/errors/handleError.js +62 -0
  41. package/dist/errors/handleError.js.map +1 -0
  42. package/dist/errors/index.d.ts +5 -0
  43. package/dist/errors/index.d.ts.map +1 -0
  44. package/dist/errors/index.js +13 -0
  45. package/dist/errors/index.js.map +1 -0
  46. package/{src/events.ts → dist/events.d.ts} +4 -2
  47. package/dist/events.d.ts.map +1 -0
  48. package/dist/events.js +17 -0
  49. package/dist/events.js.map +1 -0
  50. package/dist/index.cjs +38 -0
  51. package/{src/index.ts → dist/index.d.ts} +1 -10
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +38 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/lifecycle/BlocLifecycle.d.ts +51 -0
  56. package/dist/lifecycle/BlocLifecycle.d.ts.map +1 -0
  57. package/dist/lifecycle/BlocLifecycle.js +123 -0
  58. package/dist/lifecycle/BlocLifecycle.js.map +1 -0
  59. package/dist/lifecycle/index.d.ts +2 -0
  60. package/dist/lifecycle/index.d.ts.map +1 -0
  61. package/dist/lifecycle/index.js +18 -0
  62. package/dist/lifecycle/index.js.map +1 -0
  63. package/dist/plugins/BlocPluginRegistry.d.ts +58 -0
  64. package/dist/plugins/BlocPluginRegistry.d.ts.map +1 -0
  65. package/dist/plugins/BlocPluginRegistry.js +201 -0
  66. package/dist/plugins/BlocPluginRegistry.js.map +1 -0
  67. package/dist/plugins/SystemPluginRegistry.d.ts +79 -0
  68. package/dist/plugins/SystemPluginRegistry.d.ts.map +1 -0
  69. package/dist/plugins/SystemPluginRegistry.js +184 -0
  70. package/dist/plugins/SystemPluginRegistry.js.map +1 -0
  71. package/{src/plugins/index.ts → dist/plugins/index.d.ts} +1 -5
  72. package/dist/plugins/index.d.ts.map +1 -0
  73. package/dist/plugins/index.js +26 -0
  74. package/dist/plugins/index.js.map +1 -0
  75. package/dist/plugins/types.d.ts +103 -0
  76. package/dist/plugins/types.d.ts.map +1 -0
  77. package/dist/plugins/types.js +3 -0
  78. package/dist/plugins/types.js.map +1 -0
  79. package/dist/subscription/SubscriptionManager.d.ts +67 -0
  80. package/dist/subscription/SubscriptionManager.d.ts.map +1 -0
  81. package/dist/subscription/SubscriptionManager.js +317 -0
  82. package/dist/subscription/SubscriptionManager.js.map +1 -0
  83. package/{src/subscription/index.ts → dist/subscription/index.d.ts} +1 -0
  84. package/dist/subscription/index.d.ts.map +1 -0
  85. package/dist/subscription/index.js +19 -0
  86. package/dist/subscription/index.js.map +1 -0
  87. package/dist/subscription/types.d.ts +65 -0
  88. package/dist/subscription/types.d.ts.map +1 -0
  89. package/dist/subscription/types.js +3 -0
  90. package/dist/subscription/types.js.map +1 -0
  91. package/dist/testing.d.ts +85 -0
  92. package/dist/testing.d.ts.map +1 -0
  93. package/dist/testing.js +186 -0
  94. package/dist/testing.js.map +1 -0
  95. package/{src/types.ts → dist/types.d.ts} +11 -28
  96. package/dist/types.d.ts.map +1 -0
  97. package/dist/types.js +3 -0
  98. package/dist/types.js.map +1 -0
  99. package/dist/utils/BatchingManager.d.ts +28 -0
  100. package/dist/utils/BatchingManager.d.ts.map +1 -0
  101. package/dist/utils/BatchingManager.js +48 -0
  102. package/dist/utils/BatchingManager.js.map +1 -0
  103. package/dist/utils/RerenderLogger.d.ts +60 -0
  104. package/dist/utils/RerenderLogger.d.ts.map +1 -0
  105. package/dist/utils/RerenderLogger.js +205 -0
  106. package/dist/utils/RerenderLogger.js.map +1 -0
  107. package/dist/utils/generateInstanceId.d.ts +11 -0
  108. package/dist/utils/generateInstanceId.d.ts.map +1 -0
  109. package/dist/utils/generateInstanceId.js +50 -0
  110. package/dist/utils/generateInstanceId.js.map +1 -0
  111. package/dist/utils/shallowEqual.d.ts +9 -0
  112. package/dist/utils/shallowEqual.d.ts.map +1 -0
  113. package/dist/utils/shallowEqual.js +35 -0
  114. package/dist/utils/shallowEqual.js.map +1 -0
  115. package/dist/utils/uuid.d.ts +10 -0
  116. package/dist/utils/uuid.d.ts.map +1 -0
  117. package/dist/utils/uuid.js +24 -0
  118. package/dist/utils/uuid.js.map +1 -0
  119. package/package.json +17 -6
  120. package/src/Blac.ts +0 -802
  121. package/src/Bloc.ts +0 -180
  122. package/src/BlocBase.ts +0 -398
  123. package/src/Cubit.ts +0 -68
  124. package/src/__tests__/Blac.config.test.ts +0 -79
  125. package/src/__tests__/Bloc.event.test.ts +0 -394
  126. package/src/__tests__/BlocBase.subscription.test.ts +0 -349
  127. package/src/__tests__/Cubit.test.ts +0 -462
  128. package/src/__tests__/memory-leaks.test.ts +0 -383
  129. package/src/__tests__/plugins.test.ts +0 -464
  130. package/src/adapter/BlacAdapter.ts +0 -467
  131. package/src/adapter/ProxyFactory.ts +0 -249
  132. package/src/adapter/__tests__/BlacAdapter.test.ts +0 -555
  133. package/src/adapter/__tests__/ProxyFactory.test.ts +0 -655
  134. package/src/errors/BlacError.ts +0 -69
  135. package/src/errors/ErrorManager.ts +0 -101
  136. package/src/errors/handleError.ts +0 -114
  137. package/src/errors/index.ts +0 -13
  138. package/src/lifecycle/BlocLifecycle.ts +0 -156
  139. package/src/lifecycle/index.ts +0 -1
  140. package/src/plugins/BlocPluginRegistry.ts +0 -240
  141. package/src/plugins/SystemPluginRegistry.ts +0 -242
  142. package/src/plugins/__tests__/BlocPluginRegistry.test.ts +0 -450
  143. package/src/plugins/__tests__/SystemPluginRegistry.test.ts +0 -404
  144. package/src/plugins/types.ts +0 -129
  145. package/src/subscription/README.md +0 -132
  146. package/src/subscription/SubscriptionManager.ts +0 -395
  147. package/src/subscription/__tests__/SubscriptionManager.test.ts +0 -355
  148. package/src/subscription/types.ts +0 -90
  149. package/src/testing.ts +0 -246
  150. package/src/utils/BatchingManager.ts +0 -59
  151. package/src/utils/RerenderLogger.ts +0 -265
  152. package/src/utils/__tests__/generateInstanceId.test.ts +0 -104
  153. package/src/utils/__tests__/shallowEqual.test.ts +0 -171
  154. package/src/utils/__tests__/uuid.test.ts +0 -144
  155. package/src/utils/generateInstanceId.ts +0 -54
  156. package/src/utils/shallowEqual.ts +0 -40
  157. package/src/utils/uuid.ts +0 -22
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProxyFactory = exports.createBlocProxy = exports.createStateProxy = void 0;
4
+ // Minimal cache for backward compatibility
5
+ const proxyCache = new WeakMap();
6
+ // Minimal stats for backward compatibility
7
+ const stats = {
8
+ stateProxiesCreated: 0,
9
+ classProxiesCreated: 0,
10
+ cacheHits: 0,
11
+ cacheMisses: 0,
12
+ totalProxiesCreated: 0,
13
+ };
14
+ /**
15
+ * Creates a proxy for state objects that tracks property access
16
+ */
17
+ const createStateProxy = (target, consumerRef, consumerTracker, path = '') => {
18
+ if (!consumerRef ||
19
+ !consumerTracker ||
20
+ typeof target !== 'object' ||
21
+ target === null) {
22
+ return target;
23
+ }
24
+ // Check cache for backward compatibility with tests
25
+ if (!path) {
26
+ // Only cache root objects
27
+ let refCache = proxyCache.get(target);
28
+ if (!refCache) {
29
+ refCache = new WeakMap();
30
+ proxyCache.set(target, refCache);
31
+ }
32
+ const cached = refCache.get(consumerRef);
33
+ if (cached) {
34
+ stats.cacheHits++;
35
+ return cached;
36
+ }
37
+ stats.cacheMisses++;
38
+ }
39
+ const proxy = new Proxy(target, {
40
+ get(obj, prop) {
41
+ // Handle symbols and special properties
42
+ if (typeof prop === 'symbol' || prop === 'constructor') {
43
+ return Reflect.get(obj, prop);
44
+ }
45
+ const fullPath = path ? `${path}.${prop}` : prop;
46
+ const value = Reflect.get(obj, prop);
47
+ const isObject = value && typeof value === 'object';
48
+ // Track access with value for primitives
49
+ consumerTracker.trackAccess(consumerRef, 'state', fullPath, isObject ? undefined : value);
50
+ // Recursively proxy nested objects and arrays
51
+ if (isObject &&
52
+ (Array.isArray(value) ||
53
+ Object.getPrototypeOf(value) === Object.prototype)) {
54
+ return (0, exports.createStateProxy)(value, consumerRef, consumerTracker, fullPath);
55
+ }
56
+ return value;
57
+ },
58
+ set: () => false, // State should be immutable
59
+ deleteProperty: () => false, // State properties should not be deleted
60
+ });
61
+ // Cache root proxies
62
+ if (!path) {
63
+ const refCache = proxyCache.get(target);
64
+ refCache.set(consumerRef, proxy);
65
+ stats.stateProxiesCreated++;
66
+ stats.totalProxiesCreated++;
67
+ }
68
+ return proxy;
69
+ };
70
+ exports.createStateProxy = createStateProxy;
71
+ /**
72
+ * Creates a proxy for bloc instances that tracks getter access
73
+ */
74
+ const createBlocProxy = (target, consumerRef, consumerTracker) => {
75
+ if (!consumerRef || !consumerTracker) {
76
+ return target;
77
+ }
78
+ // Check cache
79
+ let refCache = proxyCache.get(target);
80
+ if (!refCache) {
81
+ refCache = new WeakMap();
82
+ proxyCache.set(target, refCache);
83
+ }
84
+ const cached = refCache.get(consumerRef);
85
+ if (cached) {
86
+ stats.cacheHits++;
87
+ return cached;
88
+ }
89
+ stats.cacheMisses++;
90
+ const proxy = new Proxy(target, {
91
+ get(obj, prop) {
92
+ const value = Reflect.get(obj, prop);
93
+ // Only track getters, not methods or regular properties
94
+ const descriptor = findPropertyDescriptor(obj, prop);
95
+ if (descriptor?.get) {
96
+ // Track getter access with value for primitives
97
+ const isPrimitive = value !== null && typeof value !== 'object';
98
+ consumerTracker.trackAccess(consumerRef, 'class', String(prop), isPrimitive ? value : undefined);
99
+ }
100
+ return value;
101
+ },
102
+ });
103
+ // Cache proxy
104
+ refCache.set(consumerRef, proxy);
105
+ stats.classProxiesCreated++;
106
+ stats.totalProxiesCreated++;
107
+ return proxy;
108
+ };
109
+ exports.createBlocProxy = createBlocProxy;
110
+ /**
111
+ * Helper to find property descriptor in prototype chain
112
+ */
113
+ const findPropertyDescriptor = (obj, prop, maxDepth = 10) => {
114
+ let current = obj;
115
+ let depth = 0;
116
+ while (current && depth < maxDepth) {
117
+ const descriptor = Object.getOwnPropertyDescriptor(current, prop);
118
+ if (descriptor)
119
+ return descriptor;
120
+ current = Object.getPrototypeOf(current);
121
+ depth++;
122
+ }
123
+ return undefined;
124
+ };
125
+ // Export compatibility functions for easier migration
126
+ exports.ProxyFactory = {
127
+ createStateProxy: (options) => (0, exports.createStateProxy)(options.target, options.consumerRef, options.consumerTracker, options.path),
128
+ createClassProxy: (options) => (0, exports.createBlocProxy)(options.target, options.consumerRef, options.consumerTracker),
129
+ getProxyState: (options) => (0, exports.createStateProxy)(options.state, options.consumerRef, options.consumerTracker),
130
+ getProxyBlocInstance: (options) => (0, exports.createBlocProxy)(options.blocInstance, options.consumerRef, options.consumerTracker),
131
+ // Compatibility functions that return expected structure
132
+ getStats: () => ({
133
+ ...stats,
134
+ propertyAccesses: 0,
135
+ nestedProxiesCreated: 0,
136
+ cacheEfficiency: stats.cacheHits + stats.cacheMisses > 0
137
+ ? `${((stats.cacheHits / (stats.cacheHits + stats.cacheMisses)) * 100).toFixed(1)}%`
138
+ : 'N/A',
139
+ lifetime: '0ms',
140
+ proxiesPerSecond: 'N/A',
141
+ }),
142
+ resetStats: () => {
143
+ stats.stateProxiesCreated = 0;
144
+ stats.classProxiesCreated = 0;
145
+ stats.cacheHits = 0;
146
+ stats.cacheMisses = 0;
147
+ stats.totalProxiesCreated = 0;
148
+ },
149
+ };
150
+ //# sourceMappingURL=ProxyFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyFactory.js","sourceRoot":"","sources":["../../src/adapter/ProxyFactory.ts"],"names":[],"mappings":";;;AAWA,2CAA2C;AAC3C,MAAM,UAAU,GAAG,IAAI,OAAO,EAAgC,CAAC;AAE/D,2CAA2C;AAC3C,MAAM,KAAK,GAAG;IACZ,mBAAmB,EAAE,CAAC;IACtB,mBAAmB,EAAE,CAAC;IACtB,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,CAAC;IACd,mBAAmB,EAAE,CAAC;CACvB,CAAC;AAEF;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAC9B,MAAS,EACT,WAAmB,EACnB,eAAgC,EAChC,IAAI,G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GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;YACpF,CAAC,CAAC,KAAK;QACX,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,KAAK;KACxB,CAAC;IACF,UAAU,EAAE,GAAG,EAAE;QACf,KAAK,CAAC,mBAAmB,GAAG,CAAC,CAAC;QAC9B,KAAK,CAAC,mBAAmB,GAAG,CAAC,CAAC;QAC9B,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;QACpB,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;QACtB,KAAK,CAAC,mBAAmB,GAAG,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './BlacAdapter';
2
2
  export * from './ProxyFactory';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./BlacAdapter"), exports);
18
+ __exportStar(require("./ProxyFactory"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,iDAA+B"}
@@ -0,0 +1,38 @@
1
+ export declare enum ErrorCategory {
2
+ LIFECYCLE = "LIFECYCLE",
3
+ STATE = "STATE",
4
+ PLUGIN = "PLUGIN",
5
+ VALIDATION = "VALIDATION",
6
+ DISPOSAL = "DISPOSAL",
7
+ CONSUMER = "CONSUMER"
8
+ }
9
+ export declare enum ErrorSeverity {
10
+ FATAL = "FATAL",// System cannot continue
11
+ ERROR = "ERROR",// Operation failed but system continues
12
+ WARNING = "WARNING",// Potential issue but operation succeeded
13
+ INFO = "INFO"
14
+ }
15
+ export type BlacErrorContext = {
16
+ blocName?: string;
17
+ blocId?: string;
18
+ consumerId?: string;
19
+ pluginName?: string;
20
+ operation?: string;
21
+ metadata?: Record<string, unknown>;
22
+ };
23
+ export declare class BlacError extends Error {
24
+ readonly category: ErrorCategory;
25
+ readonly severity: ErrorSeverity;
26
+ readonly context?: BlacErrorContext | undefined;
27
+ readonly cause?: unknown | undefined;
28
+ constructor(message: string, category: ErrorCategory, severity: ErrorSeverity, context?: BlacErrorContext | undefined, cause?: unknown | undefined);
29
+ toString(): string;
30
+ }
31
+ export type ErrorHandler = (error: BlacError) => void;
32
+ export type ErrorHandlingStrategy = {
33
+ shouldPropagate: (error: BlacError) => boolean;
34
+ shouldLog: (error: BlacError) => boolean;
35
+ handle: (error: BlacError) => void;
36
+ };
37
+ export declare const DefaultErrorStrategy: ErrorHandlingStrategy;
38
+ //# sourceMappingURL=BlacError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlacError.d.ts","sourceRoot":"","sources":["../../src/errors/BlacError.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB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value: true });
3
+ exports.DefaultErrorStrategy = exports.BlacError = exports.ErrorSeverity = exports.ErrorCategory = void 0;
4
+ var ErrorCategory;
5
+ (function (ErrorCategory) {
6
+ ErrorCategory["LIFECYCLE"] = "LIFECYCLE";
7
+ ErrorCategory["STATE"] = "STATE";
8
+ ErrorCategory["PLUGIN"] = "PLUGIN";
9
+ ErrorCategory["VALIDATION"] = "VALIDATION";
10
+ ErrorCategory["DISPOSAL"] = "DISPOSAL";
11
+ ErrorCategory["CONSUMER"] = "CONSUMER";
12
+ })(ErrorCategory || (exports.ErrorCategory = ErrorCategory = {}));
13
+ var ErrorSeverity;
14
+ (function (ErrorSeverity) {
15
+ ErrorSeverity["FATAL"] = "FATAL";
16
+ ErrorSeverity["ERROR"] = "ERROR";
17
+ ErrorSeverity["WARNING"] = "WARNING";
18
+ ErrorSeverity["INFO"] = "INFO";
19
+ })(ErrorSeverity || (exports.ErrorSeverity = ErrorSeverity = {}));
20
+ class BlacError extends Error {
21
+ category;
22
+ severity;
23
+ context;
24
+ cause;
25
+ constructor(message, category, severity, context, cause) {
26
+ super(message);
27
+ this.category = category;
28
+ this.severity = severity;
29
+ this.context = context;
30
+ this.cause = cause;
31
+ this.name = 'BlacError';
32
+ // Ensure proper prototype chain
33
+ Object.setPrototypeOf(this, BlacError.prototype);
34
+ }
35
+ toString() {
36
+ const contextStr = this.context
37
+ ? ` [${Object.entries(this.context)
38
+ .filter(([_, v]) => v !== undefined)
39
+ .map(([k, v]) => `${k}: ${v}`)
40
+ .join(', ')}]`
41
+ : '';
42
+ return `${this.name} [${this.severity}/${this.category}]: ${this.message}${contextStr}`;
43
+ }
44
+ }
45
+ exports.BlacError = BlacError;
46
+ exports.DefaultErrorStrategy = {
47
+ shouldPropagate: (error) => error.severity === ErrorSeverity.FATAL,
48
+ shouldLog: (error) => error.severity !== ErrorSeverity.INFO,
49
+ handle: (error) => {
50
+ if (exports.DefaultErrorStrategy.shouldLog(error)) {
51
+ console.error(error.toString(), error.cause);
52
+ }
53
+ },
54
+ };
55
+ //# sourceMappingURL=BlacError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlacError.js","sourceRoot":"","sources":["../../src/errors/BlacError.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,gCAAe,CAAA;IACf,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,sCAAqB,CAAA;IACrB,sCAAqB,CAAA;AACvB,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB;AAED,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,gCAAe,CAAA;IACf,oCAAmB,CAAA;IACnB,8BAAa,CAAA;AACf,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAWD,MAAa,SAAU,SAAQ,KAAK;IAGhB;IACA;IACA;IACA;IALlB,YACE,OAAe,EACC,QAAuB,EACvB,QAAuB,EACvB,OAA0B,EAC1B,KAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QALC,aAAQ,GAAR,QAAQ,CAAe;QACvB,aAAQ,GAAR,QAAQ,CAAe;QACvB,YAAO,GAAP,OAAO,CAAmB;QAC1B,UAAK,GAAL,KAAK,CAAU;QAG/B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QAExB,gCAAgC;QAChC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IAED,QAAQ;QACN,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO;YAC7B,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;iBAC9B,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;iBACnC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;iBAC7B,IAAI,CAAC,IAAI,CAAC,GAAG;YAClB,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,MAAM,IAAI,CAAC,OAAO,GAAG,UAAU,EAAE,CAAC;IAC1F,CAAC;CACF;AAzBD,8BAyBC;AAUY,QAAA,oBAAoB,GAA0B;IACzD,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,aAAa,CAAC,KAAK;IAClE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,aAAa,CAAC,IAAI;IAC3D,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAChB,IAAI,4BAAoB,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { BlacError, ErrorHandler, ErrorHandlingStrategy } from './BlacError';
2
+ /**
3
+ * Centralized error management system for BlaC framework.
4
+ * Handles error processing, logging, and propagation strategies.
5
+ */
6
+ export declare class ErrorManager {
7
+ private static instance;
8
+ private handlers;
9
+ private strategy;
10
+ /**
11
+ * Get the singleton instance of ErrorManager
12
+ */
13
+ static getInstance(): ErrorManager;
14
+ /**
15
+ * Set a custom error handling strategy
16
+ */
17
+ setStrategy(strategy: ErrorHandlingStrategy): void;
18
+ /**
19
+ * Add a custom error handler that will be called for all errors
20
+ */
21
+ addHandler(handler: ErrorHandler): void;
22
+ /**
23
+ * Remove a previously added error handler
24
+ */
25
+ removeHandler(handler: ErrorHandler): void;
26
+ /**
27
+ * Process an error through all handlers and apply the configured strategy
28
+ */
29
+ handle(error: BlacError): void;
30
+ /**
31
+ * Convenience method for wrapping operations with error handling
32
+ */
33
+ wrap<T>(operation: () => T, errorFactory: (error: unknown) => BlacError): T;
34
+ /**
35
+ * Async version of wrap
36
+ */
37
+ wrapAsync<T>(operation: () => Promise<T>, errorFactory: (error: unknown) => BlacError): Promise<T>;
38
+ }
39
+ //# sourceMappingURL=ErrorManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorManager.d.ts","sourceRoot":"","sources":["../../src/errors/ErrorManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,qBAAqB,EAEtB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,QAAQ,CAA+C;IAE/D;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,YAAY;IAOlC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IAIlD;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAIvC;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAI1C;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAoB9B;;OAEG;IACH,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,GAAG,CAAC;IAW3E;;OAEG;IACG,SAAS,CAAC,CAAC,EACf,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,GAC1C,OAAO,CAAC,CAAC,CAAC;CAUd"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorManager = void 0;
4
+ const BlacError_1 = require("./BlacError");
5
+ /**
6
+ * Centralized error management system for BlaC framework.
7
+ * Handles error processing, logging, and propagation strategies.
8
+ */
9
+ class ErrorManager {
10
+ static instance;
11
+ handlers = new Set();
12
+ strategy = BlacError_1.DefaultErrorStrategy;
13
+ /**
14
+ * Get the singleton instance of ErrorManager
15
+ */
16
+ static getInstance() {
17
+ if (!ErrorManager.instance) {
18
+ ErrorManager.instance = new ErrorManager();
19
+ }
20
+ return ErrorManager.instance;
21
+ }
22
+ /**
23
+ * Set a custom error handling strategy
24
+ */
25
+ setStrategy(strategy) {
26
+ this.strategy = strategy;
27
+ }
28
+ /**
29
+ * Add a custom error handler that will be called for all errors
30
+ */
31
+ addHandler(handler) {
32
+ this.handlers.add(handler);
33
+ }
34
+ /**
35
+ * Remove a previously added error handler
36
+ */
37
+ removeHandler(handler) {
38
+ this.handlers.delete(handler);
39
+ }
40
+ /**
41
+ * Process an error through all handlers and apply the configured strategy
42
+ */
43
+ handle(error) {
44
+ // Always notify handlers first
45
+ this.handlers.forEach((handler) => {
46
+ try {
47
+ handler(error);
48
+ }
49
+ catch (handlerError) {
50
+ // Prevent handler errors from breaking error handling
51
+ console.error('Error in error handler:', handlerError);
52
+ }
53
+ });
54
+ // Apply strategy
55
+ this.strategy.handle(error);
56
+ // Propagate if needed
57
+ if (this.strategy.shouldPropagate(error)) {
58
+ throw error;
59
+ }
60
+ }
61
+ /**
62
+ * Convenience method for wrapping operations with error handling
63
+ */
64
+ wrap(operation, errorFactory) {
65
+ try {
66
+ return operation();
67
+ }
68
+ catch (error) {
69
+ const blacError = errorFactory(error);
70
+ this.handle(blacError);
71
+ // Will only reach here if strategy says not to propagate
72
+ return undefined;
73
+ }
74
+ }
75
+ /**
76
+ * Async version of wrap
77
+ */
78
+ async wrapAsync(operation, errorFactory) {
79
+ try {
80
+ return await operation();
81
+ }
82
+ catch (error) {
83
+ const blacError = errorFactory(error);
84
+ this.handle(blacError);
85
+ // Will only reach here if strategy says not to propagate
86
+ return undefined;
87
+ }
88
+ }
89
+ }
90
+ exports.ErrorManager = ErrorManager;
91
+ //# sourceMappingURL=ErrorManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorManager.js","sourceRoot":"","sources":["../../src/errors/ErrorManager.ts"],"names":[],"mappings":";;;AAAA,2CAKqB;AAErB;;;GAGG;AACH,MAAa,YAAY;IACf,MAAM,CAAC,QAAQ,CAAe;IAC9B,QAAQ,GAAsB,IAAI,GAAG,EAAE,CAAC;IACxC,QAAQ,GAA0B,gCAAoB,CAAC;IAE/D;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC3B,YAAY,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,YAAY,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,QAA+B;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAqB;QAC9B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,OAAqB;QACjC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAgB;QACrB,+BAA+B;QAC/B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAChC,IAAI,CAAC;gBACH,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAAC,OAAO,YAAY,EAAE,CAAC;gBACtB,sDAAsD;gBACtD,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,iBAAiB;QACjB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE5B,sBAAsB;QACtB,IAAI,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;YACzC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI,CAAI,SAAkB,EAAE,YAA2C;QACrE,IAAI,CAAC;YACH,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACvB,yDAAyD;YACzD,OAAO,SAAc,CAAC;QACxB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CACb,SAA2B,EAC3B,YAA2C;QAE3C,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACvB,yDAAyD;YACzD,OAAO,SAAc,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAzFD,oCAyFC"}
@@ -0,0 +1,24 @@
1
+ import { ErrorCategory, ErrorSeverity, BlacErrorContext } from './BlacError';
2
+ /**
3
+ * Standard error handling helper for BlaC
4
+ *
5
+ * Usage:
6
+ * - For fatal errors that should propagate: handleError.fatal(...)
7
+ * - For recoverable errors: handleError.error(...)
8
+ * - For warnings: handleError.warn(...)
9
+ */
10
+ export declare const handleError: {
11
+ fatal: (message: string, category: ErrorCategory, context?: BlacErrorContext, cause?: unknown) => never;
12
+ error: (message: string, category: ErrorCategory, context?: BlacErrorContext, cause?: unknown) => void;
13
+ warn: (message: string, category: ErrorCategory, context?: BlacErrorContext, cause?: unknown) => void;
14
+ info: (message: string, category: ErrorCategory, context?: BlacErrorContext) => void;
15
+ /**
16
+ * Wraps a function to catch and handle errors
17
+ */
18
+ wrap: <T>(fn: () => T, category: ErrorCategory, context?: BlacErrorContext, severity?: ErrorSeverity) => T | undefined;
19
+ /**
20
+ * Wraps an async function to catch and handle errors
21
+ */
22
+ wrapAsync: <T>(fn: () => Promise<T>, category: ErrorCategory, context?: BlacErrorContext, severity?: ErrorSeverity) => Promise<T | undefined>;
23
+ };
24
+ //# sourceMappingURL=handleError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../src/errors/handleError.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,aAAa,EACb,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAGrB;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;qBAEX,MAAM,YACL,aAAa,YACb,gBAAgB,UAClB,OAAO,KACd,KAAK;qBAcG,MAAM,YACL,aAAa,YACb,gBAAgB,UAClB,OAAO,KACd,IAAI;oBAYI,MAAM,YACL,aAAa,YACb,gBAAgB,UAClB,OAAO,KACd,IAAI;oBAYI,MAAM,YACL,aAAa,YACb,gBAAgB,KACzB,IAAI;IAKP;;OAEG;WACI,CAAC,MACF,MAAM,CAAC,YACD,aAAa,YACb,gBAAgB,aAChB,aAAa,KACtB,CAAC,GAAG,SAAS;IAWhB;;OAEG;gBACe,CAAC,MACb,MAAM,OAAO,CAAC,CAAC,CAAC,YACV,aAAa,YACb,gBAAgB,aAChB,aAAa,KACtB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAU1B,CAAC"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleError = void 0;
4
+ const BlacError_1 = require("./BlacError");
5
+ const ErrorManager_1 = require("./ErrorManager");
6
+ /**
7
+ * Standard error handling helper for BlaC
8
+ *
9
+ * Usage:
10
+ * - For fatal errors that should propagate: handleError.fatal(...)
11
+ * - For recoverable errors: handleError.error(...)
12
+ * - For warnings: handleError.warn(...)
13
+ */
14
+ exports.handleError = {
15
+ fatal: (message, category, context, cause) => {
16
+ const error = new BlacError_1.BlacError(message, category, BlacError_1.ErrorSeverity.FATAL, context, cause);
17
+ ErrorManager_1.ErrorManager.getInstance().handle(error);
18
+ // This will always throw due to FATAL severity
19
+ throw error;
20
+ },
21
+ error: (message, category, context, cause) => {
22
+ const error = new BlacError_1.BlacError(message, category, BlacError_1.ErrorSeverity.ERROR, context, cause);
23
+ ErrorManager_1.ErrorManager.getInstance().handle(error);
24
+ },
25
+ warn: (message, category, context, cause) => {
26
+ const error = new BlacError_1.BlacError(message, category, BlacError_1.ErrorSeverity.WARNING, context, cause);
27
+ ErrorManager_1.ErrorManager.getInstance().handle(error);
28
+ },
29
+ info: (message, category, context) => {
30
+ const error = new BlacError_1.BlacError(message, category, BlacError_1.ErrorSeverity.INFO, context);
31
+ ErrorManager_1.ErrorManager.getInstance().handle(error);
32
+ },
33
+ /**
34
+ * Wraps a function to catch and handle errors
35
+ */
36
+ wrap: (fn, category, context, severity = BlacError_1.ErrorSeverity.ERROR) => {
37
+ try {
38
+ return fn();
39
+ }
40
+ catch (cause) {
41
+ const message = cause instanceof Error ? cause.message : String(cause);
42
+ const error = new BlacError_1.BlacError(message, category, severity, context, cause);
43
+ ErrorManager_1.ErrorManager.getInstance().handle(error);
44
+ return undefined;
45
+ }
46
+ },
47
+ /**
48
+ * Wraps an async function to catch and handle errors
49
+ */
50
+ wrapAsync: async (fn, category, context, severity = BlacError_1.ErrorSeverity.ERROR) => {
51
+ try {
52
+ return await fn();
53
+ }
54
+ catch (cause) {
55
+ const message = cause instanceof Error ? cause.message : String(cause);
56
+ const error = new BlacError_1.BlacError(message, category, severity, context, cause);
57
+ ErrorManager_1.ErrorManager.getInstance().handle(error);
58
+ return undefined;
59
+ }
60
+ },
61
+ };
62
+ //# sourceMappingURL=handleError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleError.js","sourceRoot":"","sources":["../../src/errors/handleError.ts"],"names":[],"mappings":";;;AAAA,2CAKqB;AACrB,iDAA8C;AAE9C;;;;;;;GAOG;AACU,QAAA,WAAW,GAAG;IACzB,KAAK,EAAE,CACL,OAAe,EACf,QAAuB,EACvB,OAA0B,EAC1B,KAAe,EACR,EAAE;QACT,MAAM,KAAK,GAAG,IAAI,qBAAS,CACzB,OAAO,EACP,QAAQ,EACR,yBAAa,CAAC,KAAK,EACnB,OAAO,EACP,KAAK,CACN,CAAC;QACF,2BAAY,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzC,+CAA+C;QAC/C,MAAM,KAAK,CAAC;IACd,CAAC;IAED,KAAK,EAAE,CACL,OAAe,EACf,QAAuB,EACvB,OAA0B,EAC1B,KAAe,EACT,EAAE;QACR,MAAM,KAAK,GAAG,IAAI,qBAAS,CACzB,OAAO,EACP,QAAQ,EACR,yBAAa,CAAC,KAAK,EACnB,OAAO,EACP,KAAK,CACN,CAAC;QACF,2BAAY,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,EAAE,CACJ,OAAe,EACf,QAAuB,EACvB,OAA0B,EAC1B,KAAe,EACT,EAAE;QACR,MAAM,KAAK,GAAG,IAAI,qBAAS,CACzB,OAAO,EACP,QAAQ,EACR,yBAAa,CAAC,OAAO,EACrB,OAAO,EACP,KAAK,CACN,CAAC;QACF,2BAAY,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,EAAE,CACJ,OAAe,EACf,QAAuB,EACvB,OAA0B,EACpB,EAAE;QACR,MAAM,KAAK,GAAG,IAAI,qBAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,yBAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC5E,2BAAY,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,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from './BlacError';
2
+ export type { BlacErrorContext, ErrorHandler, ErrorHandlingStrategy, } from './BlacError';
3
+ export { ErrorManager } from './ErrorManager';
4
+ export { handleError } from './handleError';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleError = exports.ErrorManager = exports.DefaultErrorStrategy = exports.ErrorSeverity = exports.ErrorCategory = exports.BlacError = void 0;
4
+ var BlacError_1 = require("./BlacError");
5
+ Object.defineProperty(exports, "BlacError", { enumerable: true, get: function () { return BlacError_1.BlacError; } });
6
+ Object.defineProperty(exports, "ErrorCategory", { enumerable: true, get: function () { return BlacError_1.ErrorCategory; } });
7
+ Object.defineProperty(exports, "ErrorSeverity", { enumerable: true, get: function () { return BlacError_1.ErrorSeverity; } });
8
+ Object.defineProperty(exports, "DefaultErrorStrategy", { enumerable: true, get: function () { return BlacError_1.DefaultErrorStrategy; } });
9
+ var ErrorManager_1 = require("./ErrorManager");
10
+ Object.defineProperty(exports, "ErrorManager", { enumerable: true, get: function () { return ErrorManager_1.ErrorManager; } });
11
+ var handleError_1 = require("./handleError");
12
+ Object.defineProperty(exports, "handleError", { enumerable: true, get: function () { return handleError_1.handleError; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAAA,yCAKqB;AAJnB,sGAAA,SAAS,OAAA;AACT,0GAAA,aAAa,OAAA;AACb,0GAAA,aAAa,OAAA;AACb,iHAAA,oBAAoB,OAAA;AAOtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA"}
@@ -4,6 +4,8 @@
4
4
  * about prop changes in React components.
5
5
  * @template P - The type of props being updated
6
6
  */
7
- export class PropsUpdated<P = any> {
8
- constructor(public readonly props: P) {}
7
+ export declare class PropsUpdated<P = any> {
8
+ readonly props: P;
9
+ constructor(props: P);
9
10
  }
11
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,YAAY,CAAC,CAAC,GAAG,GAAG;aACH,KAAK,EAAE,CAAC;gBAAR,KAAK,EAAE,CAAC;CACrC"}
package/dist/events.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropsUpdated = void 0;
4
+ /**
5
+ * Event fired when props are updated on a Bloc or Cubit instance.
6
+ * This is primarily used internally by the framework to notify
7
+ * about prop changes in React components.
8
+ * @template P - The type of props being updated
9
+ */
10
+ class PropsUpdated {
11
+ props;
12
+ constructor(props) {
13
+ this.props = props;
14
+ }
15
+ }
16
+ exports.PropsUpdated = PropsUpdated;
17
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,YAAY;IACK;IAA5B,YAA4B,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;CACzC;AAFD,oCAEC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Blac"), exports);
18
+ __exportStar(require("./Bloc"), exports);
19
+ __exportStar(require("./BlocBase"), exports);
20
+ __exportStar(require("./Cubit"), exports);
21
+ __exportStar(require("./types"), exports);
22
+ __exportStar(require("./events"), exports);
23
+ __exportStar(require("./subscription"), exports);
24
+ __exportStar(require("./lifecycle"), exports);
25
+ // Utilities
26
+ __exportStar(require("./utils/uuid"), exports);
27
+ __exportStar(require("./utils/shallowEqual"), exports);
28
+ __exportStar(require("./utils/generateInstanceId"), exports);
29
+ __exportStar(require("./utils/RerenderLogger"), exports);
30
+ // Test utilities
31
+ __exportStar(require("./testing"), exports);
32
+ // Adapter
33
+ __exportStar(require("./adapter"), exports);
34
+ // Plugins
35
+ __exportStar(require("./plugins"), exports);
36
+ // Error handling
37
+ __exportStar(require("./errors"), exports);
38
+ //# sourceMappingURL=index.js.map