@impractical-ai/motion 0.1.7 → 0.1.10

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.
@@ -6,14 +6,14 @@ import {
6
6
  loadConfig,
7
7
  recoverCorruptConfig,
8
8
  saveConfig
9
- } from "./chunk-MQKW7NFI.js";
9
+ } from "./chunk-CZANULCU.js";
10
10
  import {
11
11
  PACKAGE_COMMAND,
12
12
  PACKAGE_NAME,
13
13
  PACKAGE_VERSION,
14
14
  PRODUCTION_APP_URL,
15
15
  PRODUCTION_SUPABASE_URL
16
- } from "./chunk-Z74SLKEU.js";
16
+ } from "./chunk-6FVZ6IWR.js";
17
17
 
18
18
  // src/onboarding.ts
19
19
  import {
@@ -30,6 +30,7 @@ import { homedir } from "node:os";
30
30
  import { dirname, join } from "node:path";
31
31
  import { fileURLToPath } from "node:url";
32
32
  import { spawnSync } from "node:child_process";
33
+ import { createRequire } from "node:module";
33
34
  var CLAUDE_MARKETPLACE = "Openpod/impractical-agent-plugins";
34
35
  var CLAUDE_PLUGIN = "impractical-motion@impractical";
35
36
  var CLAUDE_MARKETPLACE_NAME = "impractical";
@@ -426,7 +427,7 @@ Official setup guide: ${CLAUDE_INSTALL_URL}`
426
427
  throw new Error(`${label} is required before setup can continue.`);
427
428
  }
428
429
  }
429
- function hasChrome() {
430
+ function hasSystemChrome() {
430
431
  const macPaths = [
431
432
  "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
432
433
  "/Applications/Chromium.app/Contents/MacOS/Chromium"
@@ -437,11 +438,62 @@ function hasChrome() {
437
438
  return !result.error && result.status === 0;
438
439
  });
439
440
  }
441
+ function playwrightCli() {
442
+ try {
443
+ const require_ = createRequire(import.meta.url);
444
+ const cli = join(dirname(require_.resolve("playwright-core/package.json")), "cli.js");
445
+ return existsSync(cli) ? cli : void 0;
446
+ } catch {
447
+ return void 0;
448
+ }
449
+ }
450
+ function managedBrowserPath() {
451
+ const cli = playwrightCli();
452
+ if (!cli) return void 0;
453
+ const probe = spawnSync(
454
+ process.execPath,
455
+ [cli, "install", "--dry-run", "chromium-headless-shell"],
456
+ { encoding: "utf8", windowsHide: true }
457
+ );
458
+ if (probe.error || probe.status !== 0) return void 0;
459
+ const match = /^\s*Install location:\s*(.+?)\s*$/m.exec(probe.stdout ?? "");
460
+ return match?.[1];
461
+ }
462
+ function hasManagedBrowser() {
463
+ const path = managedBrowserPath();
464
+ return Boolean(path && existsSync(path));
465
+ }
466
+ function ensureRenderBrowser(log = () => {
467
+ }) {
468
+ if (hasManagedBrowser()) return;
469
+ const cli = playwrightCli();
470
+ if (!cli) {
471
+ if (hasSystemChrome()) return;
472
+ throw new Error(
473
+ "A browser is required to inspect video frames, and the bundled installer could not be found. Install Google Chrome, or run `npx playwright-core install chromium-headless-shell`."
474
+ );
475
+ }
476
+ log("Installing a headless browser for frame capture (one time, a few hundred MB)...");
477
+ const result = spawnSync(process.execPath, [cli, "install", "chromium-headless-shell"], {
478
+ stdio: "inherit",
479
+ windowsHide: true
480
+ });
481
+ if (!result.error && result.status === 0) {
482
+ log("Headless browser ready.");
483
+ return;
484
+ }
485
+ if (hasSystemChrome()) {
486
+ log("Could not install the headless browser; falling back to your installed Chrome.");
487
+ return;
488
+ }
489
+ throw new Error(
490
+ "Could not install a browser for frame capture, and no Chrome or Chromium was found. Install Google Chrome, or run `npx playwright-core install chromium-headless-shell` and re-run setup."
491
+ );
492
+ }
440
493
  function verifyClaudePrerequisites() {
441
494
  const major = Number(process.versions.node.split(".")[0]);
442
495
  if (!Number.isInteger(major) || major < 22) throw new Error("Node.js 22 or newer is required.");
443
496
  requireCommand("claude", "Claude Code");
444
- if (!hasChrome()) throw new Error("Google Chrome or Chromium is required to inspect video frames.");
445
497
  }
446
498
  function runClaude(args, log, tolerateAlreadyInstalled = false) {
447
499
  const result = commandResult("claude", args);
@@ -618,6 +670,7 @@ async function setup(options) {
618
670
  if (options.installAgentMcp) {
619
671
  verifyAgentPrerequisites();
620
672
  }
673
+ ensureRenderBrowser(options.log);
621
674
  const corruptConfigBackup = recoverCorruptConfig();
622
675
  if (corruptConfigBackup) {
623
676
  options.log(`Backed up invalid configuration to ${corruptConfigBackup}; starting clean.`);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  setup
4
- } from "./chunk-M7SHFM25.js";
4
+ } from "./chunk-WB7FRXAG.js";
5
5
  import {
6
6
  invoke,
7
7
  invokeAt,
@@ -11,8 +11,8 @@ import {
11
11
  saveConfig,
12
12
  studioLink,
13
13
  waitForJobs
14
- } from "./chunk-MQKW7NFI.js";
15
- import "./chunk-Z74SLKEU.js";
14
+ } from "./chunk-CZANULCU.js";
15
+ import "./chunk-6FVZ6IWR.js";
16
16
  import "./chunk-77HVPD4G.js";
17
17
 
18
18
  // src/commands.ts
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  PACKAGE_VERSION
4
- } from "./chunk-Z74SLKEU.js";
4
+ } from "./chunk-6FVZ6IWR.js";
5
5
  import "./chunk-77HVPD4G.js";
6
6
 
7
7
  // src/cli-args.ts
@@ -140,11 +140,11 @@ async function runCli(args, deps) {
140
140
  // src/index.ts
141
141
  runCli(process.argv.slice(2), {
142
142
  writeLine: (line) => console.log(line),
143
- loadCommands: () => import("./commands-R3LJU2BW.js"),
144
- loadApi: () => import("./api-DR3NJ7TI.js"),
145
- loadMcp: () => import("./stdio-XUVQKDCB.js")
143
+ loadCommands: () => import("./commands-YJFMKK2K.js"),
144
+ loadApi: () => import("./api-4WE4LYPB.js"),
145
+ loadMcp: () => import("./stdio-S7VGBKNS.js")
146
146
  }).catch(async (error) => {
147
- const { ApiError } = await import("./api-DR3NJ7TI.js");
147
+ const { ApiError } = await import("./api-4WE4LYPB.js");
148
148
  if (error instanceof ApiError) {
149
149
  console.error(`Error (${error.status} from ${error.fn}): ${error.message}`);
150
150
  if (error.status === 429) console.error("Weekly MCP allowance reached. Upgrade or wait for Monday UTC.");