@xbrowser/cli 1.22.0 → 1.23.1

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.
@@ -1,5 +1,9 @@
1
+ import {
2
+ getCaptchaConfig
3
+ } from "./chunk-ZTHE5RBZ.js";
4
+
1
5
  // src/human-interaction.ts
2
- import { execSync } from "child_process";
6
+ import { execFile } from "child_process";
3
7
 
4
8
  // src/screencast.ts
5
9
  var ScreencastCapturer = class {
@@ -274,99 +278,6 @@ var WebhookNotifier = class {
274
278
  }
275
279
  };
276
280
 
277
- // src/config.ts
278
- import { homedir, tmpdir } from "os";
279
- import { join } from "path";
280
- import { loadConfig as coreLoadConfig, saveConfig as coreSaveConfig } from "@dyyz1993/xcli-core";
281
- function getConfigSource() {
282
- return { configDir: join(homedir() || tmpdir(), ".xbrowser") };
283
- }
284
- function loadConfig() {
285
- return coreLoadConfig(getConfigSource());
286
- }
287
- function saveConfig(config) {
288
- coreSaveConfig(getConfigSource(), config);
289
- }
290
- function getConfigValue(key) {
291
- const parts = key.split(".");
292
- let obj = loadConfig();
293
- for (const part of parts) {
294
- if (obj && typeof obj === "object") {
295
- obj = obj[part];
296
- } else {
297
- return void 0;
298
- }
299
- }
300
- return obj;
301
- }
302
- function setConfigValue(key, value) {
303
- const config = loadConfig();
304
- const parts = key.split(".");
305
- let obj = config;
306
- for (let i = 0; i < parts.length - 1; i++) {
307
- if (!obj[parts[i]] || typeof obj[parts[i]] !== "object") {
308
- obj[parts[i]] = {};
309
- }
310
- obj = obj[parts[i]];
311
- }
312
- obj[parts[parts.length - 1]] = value;
313
- saveConfig(config);
314
- }
315
- var DEFAULT_MARKETPLACE_URL = "https://marketplace.xbrowser.dev";
316
- var NPM_REGISTRY_URL = "https://registry.npmjs.org";
317
- var NPM_SCOPE = "@xbrowser/";
318
- function getMarketplaceUrl() {
319
- return process.env.XBROWSER_MARKETPLACE_URL || getConfigValue("marketplaceUrl") || DEFAULT_MARKETPLACE_URL;
320
- }
321
- function resolveNpmPackageName(name) {
322
- if (name.startsWith("@")) return name;
323
- return `${NPM_SCOPE}${name}`;
324
- }
325
- var NPM_NAME_ALIASES = {
326
- "1688": "alibaba-1688"
327
- };
328
- function generateNpmCandidates(name) {
329
- if (name.startsWith("@")) return [name];
330
- const resolved = NPM_NAME_ALIASES[name] ?? name;
331
- return [
332
- `${NPM_SCOPE}xbrowser-plugin-${resolved}`,
333
- `${NPM_SCOPE}${resolved}`,
334
- `xbrowser-plugin-${resolved}`
335
- ];
336
- }
337
- async function resolveNpmPackageWithFallback(name) {
338
- const candidates = generateNpmCandidates(name);
339
- for (const candidate of candidates) {
340
- try {
341
- const encoded = encodeURIComponent(candidate);
342
- const res = await fetch(`${NPM_REGISTRY_URL}/${encoded}`);
343
- if (res.ok) return candidate;
344
- } catch {
345
- continue;
346
- }
347
- }
348
- return resolveNpmPackageName(name);
349
- }
350
- function getCaptchaConfig() {
351
- const config = loadConfig();
352
- return {
353
- notifyUrl: process.env.XBROWSER_NOTIFY_URL || config.captcha?.notifyUrl,
354
- autoOpen: process.env.XBROWSER_AUTO_OPEN === "true" || config.captcha?.autoOpen === true,
355
- timeout: parseInt(process.env.XBROWSER_CAPTCHA_TIMEOUT || "") || config.captcha?.timeout || 120,
356
- previewPort: parseInt(process.env.XBROWSER_PREVIEW_PORT || "") || config.preview?.port || 9223
357
- };
358
- }
359
- function resolveScreenshotsDir() {
360
- const configured = getConfigValue("screenshots.dir");
361
- if (typeof configured === "string" && configured.trim()) return configured.trim();
362
- return join(tmpdir(), "xbrowser", "screenshots");
363
- }
364
-
365
- // src/utils/shell-escape.ts
366
- function shellEscape(value) {
367
- return `'${value.replace(/'/g, "'\\''")}'`;
368
- }
369
-
370
281
  // src/human-interaction.ts
371
282
  var HumanInteractionManager = class {
372
283
  wsServer;
@@ -395,8 +306,10 @@ var HumanInteractionManager = class {
395
306
  tryAutoOpen(previewUrl) {
396
307
  if (!this.autoOpen) return;
397
308
  try {
398
- const cmd = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : "start";
399
- execSync(`${cmd} ${shellEscape(previewUrl)}`, { stdio: "ignore" });
309
+ const opener = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : "cmd";
310
+ const args = process.platform === "win32" ? ["/c", "start", "", previewUrl] : [previewUrl];
311
+ execFile(opener, args, { timeout: 1e4 }, () => {
312
+ });
400
313
  } catch {
401
314
  }
402
315
  }
@@ -513,15 +426,6 @@ var HumanInteractionManager = class {
513
426
  };
514
427
 
515
428
  export {
516
- loadConfig,
517
- getConfigValue,
518
- setConfigValue,
519
- NPM_REGISTRY_URL,
520
- NPM_SCOPE,
521
- getMarketplaceUrl,
522
- resolveNpmPackageWithFallback,
523
- getCaptchaConfig,
524
- resolveScreenshotsDir,
525
429
  ScreencastCapturer,
526
430
  CaptchaDetector,
527
431
  WebhookNotifier,