arn-browser 0.0.8 → 0.0.9

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": "arn-browser",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "A lightweight, browser autmation helper.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -205,43 +205,53 @@ export interface LaunchOptions {
205
205
  }
206
206
 
207
207
  /**
208
- * The object returned by launchBrowser.
208
+ * Successful browser launch result.
209
+ * When launchError is null, browser/context/page are guaranteed to be valid.
209
210
  */
210
- export interface BrowserController {
211
- /**
212
- * The Playwright Browser or BrowserContext instance.
213
- * Note: Multilogin and Persistent profiles return a BrowserContext here.
214
- */
215
- browser: Browser | BrowserContext | null;
216
-
217
- /**
218
- * The active BrowserContext.
219
- */
220
- context: BrowserContext | null;
221
-
211
+ export interface BrowserControllerSuccess {
212
+ /** The Playwright Browser or BrowserContext instance. */
213
+ browser: Browser | BrowserContext;
214
+ /** The active BrowserContext. */
215
+ context: BrowserContext;
222
216
  /**
223
217
  * The initial Page object.
224
218
  * When humanize_options is provided, this will be a HumanPage with human-like cursor methods.
225
219
  * All standard Playwright Page methods are available.
226
220
  */
227
- page: Page | HumanPage | null;
228
-
229
- /**
230
- * Checks if the browser context is currently active.
231
- */
221
+ page: Page | HumanPage;
222
+ /** Returns true since the browser is running. */
232
223
  isBrowserRunning: () => boolean;
233
-
234
- /**
235
- * Safely closes the browser and cleans up temporary directories if applicable.
236
- */
224
+ /** Safely closes the browser and cleans up temporary directories if applicable. */
237
225
  closeBrowser: () => Promise<boolean>;
226
+ /** No error occurred during launch. */
227
+ launchError: null;
228
+ }
238
229
 
239
- /**
240
- * Captures any error that occurred during launch.
241
- */
242
- launchError: Error | null;
230
+ /**
231
+ * Failed browser launch result.
232
+ * When launchError is set, browser/context/page are null.
233
+ */
234
+ export interface BrowserControllerError {
235
+ /** Null on launch failure. */
236
+ browser: null;
237
+ /** Null on launch failure. */
238
+ context: null;
239
+ /** Null on launch failure. */
240
+ page: null;
241
+ /** Returns false since the browser failed to launch. */
242
+ isBrowserRunning: () => boolean;
243
+ /** No-op cleanup function. */
244
+ closeBrowser: () => Promise<boolean>;
245
+ /** The error that occurred during launch. */
246
+ launchError: Error;
243
247
  }
244
248
 
249
+ /**
250
+ * The object returned by launchBrowser.
251
+ * Check launchError to discriminate between success and failure states.
252
+ */
253
+ export type BrowserController = BrowserControllerSuccess | BrowserControllerError;
254
+
245
255
  /**
246
256
  * Launches a browser based on the provided options.
247
257
  */
@@ -258,7 +258,7 @@ export async function launchBrowser({
258
258
  return browserInstance;
259
259
  } catch (error) {
260
260
  console.error("❌ [LaunchBrowser] Critical Error:", error.message || error);
261
- return { data: null, error: error, closeBrowser: async () => { } };
261
+ return { browser: null, context: null, page: null, isBrowserRunning: () => false, closeBrowser: async () => false, launchError: error };
262
262
  }
263
263
  }
264
264
 
@@ -729,7 +729,7 @@ async function launchExistingMultiloginProfile(profileId, humanize_options = nul
729
729
  try {
730
730
  await stopMultiloginProfile(profileId);
731
731
  } catch (e) { }
732
- return { data: null, error, closeBrowser: async () => { } };
732
+ return { browser: null, context: null, page: null, isBrowserRunning: () => false, closeBrowser: async () => false, launchError: error };
733
733
  }
734
734
  }
735
735
 
@@ -801,7 +801,7 @@ async function launchQuickMultiloginProfile({ os_type, proxy, canvas_noise, medi
801
801
  } catch (error) {
802
802
  console.error("Quick Profile Error:", error);
803
803
  if (profileId) await stopMultiloginProfile(profileId);
804
- return { data: null, error, closeBrowser: async () => { } };
804
+ return { browser: null, context: null, page: null, isBrowserRunning: () => false, closeBrowser: async () => false, launchError: error };
805
805
  }
806
806
  }
807
807