@umituz/react-native-ai-generation-content 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -30,6 +30,13 @@ class GenerationOrchestratorService {
30
30
  private config: OrchestratorConfig = {};
31
31
 
32
32
  configure(config: OrchestratorConfig): void {
33
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
34
+ // eslint-disable-next-line no-console
35
+ console.log("[Orchestrator] configure() called", {
36
+ hasPollingConfig: !!config.polling,
37
+ hasStatusUpdate: !!config.onStatusUpdate,
38
+ });
39
+ }
33
40
  this.config = { ...this.config, ...config };
34
41
  }
35
42
 
@@ -139,6 +146,15 @@ class GenerationOrchestratorService {
139
146
  requestId: string,
140
147
  onProgress?: (progress: GenerationProgress) => void,
141
148
  ): Promise<T> {
149
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
150
+ // eslint-disable-next-line no-console
151
+ console.log("[Orchestrator] pollForResult() started", {
152
+ provider: provider.providerId,
153
+ model,
154
+ requestId,
155
+ });
156
+ }
157
+
142
158
  const config = {
143
159
  ...DEFAULT_POLLING_CONFIG,
144
160
  ...this.config.polling,
@@ -149,6 +165,14 @@ class GenerationOrchestratorService {
149
165
  for (let attempt = 0; attempt < config.maxAttempts; attempt++) {
150
166
  await createPollingDelay(attempt, config);
151
167
 
168
+ if (typeof __DEV__ !== "undefined" && __DEV__ && attempt % 5 === 0) {
169
+ // eslint-disable-next-line no-console
170
+ console.log("[Orchestrator] pollForResult() attempt", {
171
+ attempt,
172
+ maxAttempts: config.maxAttempts,
173
+ });
174
+ }
175
+
152
176
  try {
153
177
  const status = await provider.getJobStatus(model, requestId);
154
178
 
@@ -157,6 +181,13 @@ class GenerationOrchestratorService {
157
181
  this.updateProgressFromStatus(status, attempt, config, onProgress);
158
182
 
159
183
  if (status.status === "COMPLETED") {
184
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
185
+ // eslint-disable-next-line no-console
186
+ console.log("[Orchestrator] pollForResult() job COMPLETED", {
187
+ requestId,
188
+ attempt,
189
+ });
190
+ }
160
191
  return provider.getJobResult<T>(model, requestId);
161
192
  }
162
193
 
@@ -214,20 +245,41 @@ class GenerationOrchestratorService {
214
245
  }
215
246
 
216
247
  private getProvider(): IAIProvider {
248
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
249
+ // eslint-disable-next-line no-console
250
+ console.log("[Orchestrator] getProvider() called");
251
+ }
252
+
217
253
  const provider = providerRegistry.getActiveProvider();
218
254
 
219
255
  if (!provider) {
256
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
257
+ // eslint-disable-next-line no-console
258
+ console.error("[Orchestrator] No active provider found!");
259
+ }
220
260
  throw new Error(
221
261
  "No active AI provider. Register and set a provider first.",
222
262
  );
223
263
  }
224
264
 
225
265
  if (!provider.isInitialized()) {
266
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
267
+ // eslint-disable-next-line no-console
268
+ console.error("[Orchestrator] Provider not initialized:", provider.providerId);
269
+ }
226
270
  throw new Error(
227
271
  `Provider ${provider.providerId} is not initialized.`,
228
272
  );
229
273
  }
230
274
 
275
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
276
+ // eslint-disable-next-line no-console
277
+ console.log("[Orchestrator] getProvider() returning:", {
278
+ providerId: provider.providerId,
279
+ isInitialized: provider.isInitialized(),
280
+ });
281
+ }
282
+
231
283
  return provider;
232
284
  }
233
285
  }
@@ -52,10 +52,33 @@ class ProviderRegistry {
52
52
  }
53
53
 
54
54
  getActiveProvider(): IAIProvider | null {
55
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
56
+ // eslint-disable-next-line no-console
57
+ console.log("[ProviderRegistry] getActiveProvider() called", {
58
+ activeProviderId: this.activeProviderId,
59
+ registeredProviders: Array.from(this.providers.keys()),
60
+ });
61
+ }
62
+
55
63
  if (!this.activeProviderId) {
64
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
65
+ // eslint-disable-next-line no-console
66
+ console.warn("[ProviderRegistry] No active provider set!");
67
+ }
56
68
  return null;
57
69
  }
58
- return this.providers.get(this.activeProviderId) ?? null;
70
+
71
+ const provider = this.providers.get(this.activeProviderId) ?? null;
72
+
73
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
74
+ // eslint-disable-next-line no-console
75
+ console.log("[ProviderRegistry] getActiveProvider() returning", {
76
+ providerId: provider?.providerId,
77
+ isInitialized: provider?.isInitialized(),
78
+ });
79
+ }
80
+
81
+ return provider;
59
82
  }
60
83
 
61
84
  getProvider(providerId: string): IAIProvider | null {