@tempo-ai/visual-review 0.0.142 → 0.0.143-staging.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.
package/dist/bin.js CHANGED
@@ -7,7 +7,7 @@ async function main(argv = process.argv.slice(2)) {
7
7
  const [command, ...commandArgs] = argv;
8
8
  switch (command) {
9
9
  case "capture":
10
- return await (await import("./cli-JLERE5LZ.js")).main(commandArgs);
10
+ return await (await import("./cli-HXYD66W5.js")).main(commandArgs);
11
11
  case "claim":
12
12
  return await (await import("./claim-TARSUW6K.js")).main(commandArgs);
13
13
  case "report":
@@ -29354,7 +29354,7 @@ import path43 from "path";
29354
29354
  var PROJECTION_PENDING_ATTRIBUTE = "data-tempo-projection-pending";
29355
29355
 
29356
29356
  // ../tempo-sdk/canvas/client-protocol.ts
29357
- var CANVAS_CLIENT_PROTOCOL = 2;
29357
+ var CANVAS_CLIENT_PROTOCOL = 3;
29358
29358
  var CANVAS_CLIENT_PROTOCOL_PARAM = "canvasProtocol";
29359
29359
 
29360
29360
  // ../../modules/component-render-pool/direct-render.ts
@@ -40633,7 +40633,7 @@ var MissingRootDepsError = class extends TempoDevServerError {
40633
40633
  // ../tempo-sdk/package.json
40634
40634
  var package_default = {
40635
40635
  name: "tempo-sdk",
40636
- version: "0.0.94",
40636
+ version: "0.0.99",
40637
40637
  publishConfig: {
40638
40638
  tag: "sdk-v2-latest"
40639
40639
  },
@@ -52932,6 +52932,7 @@ var TempoDevServer = class _TempoDevServer {
52932
52932
  // can surface its stdout/stderr tail (diagnostics) without threading the
52933
52933
  // local `process` var out of `startDevServer`.
52934
52934
  this.activeHostProcess = null;
52935
+ this.hostStartGeneration = 0;
52935
52936
  // The `flutter run` daemon beside the host when canvases declare previews (specs/flutter-storyboard-rendering.md §4). Created by the first
52936
52937
  // startDevServer, kept across the host's crash retries, stopped with the
52937
52938
  // host handle and on dispose.
@@ -53070,6 +53071,45 @@ var TempoDevServer = class _TempoDevServer {
53070
53071
  }
53071
53072
  };
53072
53073
  }
53074
+ /** Read-only proof for starting a local Vite host alongside a canvas scan. */
53075
+ async canStartDevServerDuringPreparation() {
53076
+ const hasCustomHostLifecycle = this.config.tempoHostUrl !== null || Boolean(this.config.scripts.stop?.trim()) || Boolean(this.config.scripts.updateSdk?.trim());
53077
+ if (hasCustomHostLifecycle || !this.state.dependenciesInstalled)
53078
+ return false;
53079
+ const processStatus = this.currentProcessStatus();
53080
+ if (processStatus === "running" || processStatus === "starting")
53081
+ return false;
53082
+ if (!looksLikeGeneratedInstallScript(
53083
+ this.config.scripts.install,
53084
+ path23.relative(this.projectRoot, this.appRoot).split(path23.sep).join("/")
53085
+ ))
53086
+ return false;
53087
+ if (await this.resolveStartFramework() !== "vite") return false;
53088
+ const pkg = await readJsonFile(
53089
+ path23.join(this.tempoRoot, "package.json")
53090
+ );
53091
+ let command = this.config.scripts.start.trim();
53092
+ const scriptInvocation = /^(?:npm|pnpm|bun|yarn)[ \t]+run[ \t]+([\w:-]+)$/.exec(command);
53093
+ const scriptShorthand = /^(?:pnpm|yarn)[ \t]+(dev|start)$/.exec(command);
53094
+ const scriptName = scriptInvocation?.[1] ?? scriptShorthand?.[1];
53095
+ if (scriptName) {
53096
+ const hasLifecycleHooks = pkg?.scripts?.[`pre${scriptName}`] || pkg?.scripts?.[`post${scriptName}`];
53097
+ if (hasLifecycleHooks) return false;
53098
+ const script = pkg?.scripts?.[scriptName];
53099
+ command = typeof script === "string" ? script.trim() : "";
53100
+ }
53101
+ const isLocalViteCommand = /^vite(?:[ \t]+[\w./:=@-]+)*$/.test(command) && !/^vite[ \t]+(?:build|preview|optimize)\b/.test(command);
53102
+ if (!isLocalViteCommand) return false;
53103
+ if (!await pathExists2(
53104
+ path23.join(this.tempoRoot, "node_modules", "vite", "package.json")
53105
+ ))
53106
+ return false;
53107
+ const [tempoReady, appReady] = await Promise.all([
53108
+ this.tempoInstallReady(),
53109
+ this.appSideInstallReady()
53110
+ ]);
53111
+ return this.state.dependenciesInstalled && tempoReady && appReady;
53112
+ }
53073
53113
  // The single source of host liveness. A held, signalable child is authority
53074
53114
  // for foreground starts; after a clean daemonizing launcher exits, the
53075
53115
  // retained host handle switches authority to the HTTP probe. Terminal
@@ -53207,6 +53247,7 @@ var TempoDevServer = class _TempoDevServer {
53207
53247
  );
53208
53248
  }
53209
53249
  throwIfLaunchAborted(options?.signal);
53250
+ const startGeneration = ++this.hostStartGeneration;
53210
53251
  const startDialectIssue = findPowerShellSyntax(this.config.scripts.start);
53211
53252
  if (startDialectIssue) {
53212
53253
  t.done({ ok: false, reason: "start_shell_dialect_mismatch" });
@@ -53259,21 +53300,24 @@ var TempoDevServer = class _TempoDevServer {
53259
53300
  });
53260
53301
  void this.releaseNextDistDirClaim();
53261
53302
  }
53262
- if (this.activeHostProcess === activeProcess) {
53303
+ const ownsSupervisor = this.activeHostProcess === activeProcess;
53304
+ if (ownsSupervisor) {
53263
53305
  this.activeHostProcess = null;
53264
53306
  }
53265
53307
  if (process2 !== activeProcess) {
53266
53308
  return;
53267
53309
  }
53268
- this.devserverExternalRuntimePending = false;
53269
- this.state.devserverUrl = null;
53270
- this.state.urlUnreachableSince = null;
53271
- this.idleProcessStatus = "exited";
53272
- this.stopUrlHealthProbe();
53273
53310
  this.removeProcessMarkerForPid(activeProcess.getPid()).catch(() => {
53274
53311
  });
53275
- this.persistStatus().catch(() => {
53276
- });
53312
+ if (ownsSupervisor) {
53313
+ this.devserverExternalRuntimePending = false;
53314
+ this.state.devserverUrl = null;
53315
+ this.state.urlUnreachableSince = null;
53316
+ this.idleProcessStatus = "exited";
53317
+ this.stopUrlHealthProbe();
53318
+ this.persistStatus().catch(() => {
53319
+ });
53320
+ }
53277
53321
  for (const listener of exitListeners) {
53278
53322
  listener(code, signal, crashed, reason, intentional);
53279
53323
  }
@@ -53302,6 +53346,12 @@ var TempoDevServer = class _TempoDevServer {
53302
53346
  attemptedPorts.add(startPlan.injectedPort);
53303
53347
  throwIfLaunchAborted(options?.signal);
53304
53348
  const expectedIdentity = await this.readExpectedHostIdentity();
53349
+ const nuxtEnv = await this.isNuxtTempoHost() ? nuxtSocketTmpdirEnv() : {};
53350
+ const nuxtNodePathEnv = await this.nuxtSidecarNodePathEnv();
53351
+ const watchdogScriptPath = await this.ensureDevserverWatchdogScript();
53352
+ throwIfLaunchAborted(options?.signal);
53353
+ if (this.hostStartGeneration !== startGeneration)
53354
+ throw launchAbortError();
53305
53355
  const stopCommand = this.config.scripts.stop ? substituteAppPort(this.config.scripts.stop, startPlan.injectedPort) : null;
53306
53356
  this.devserverStopCommand = stopCommand;
53307
53357
  this.devserverLaunchPort = startPlan.injectedPort;
@@ -53331,9 +53381,9 @@ var TempoDevServer = class _TempoDevServer {
53331
53381
  extraEnv: {
53332
53382
  // Nuxt 4.4.7's vite-node socket under macOS's TMPDIR passes the
53333
53383
  // Unix socket path limit (see nuxt-socket-tmpdir.ts).
53334
- ...await this.isNuxtTempoHost() ? nuxtSocketTmpdirEnv() : {},
53384
+ ...nuxtEnv,
53335
53385
  // The app's pnpm hoist dir, for its undeclared config imports.
53336
- ...await this.nuxtSidecarNodePathEnv(),
53386
+ ...nuxtNodePathEnv,
53337
53387
  ...startPlan.env,
53338
53388
  // Scoped to this canvas host. The SDK uses this to retire the old
53339
53389
  // all-canvas optimizer glob in memory, preserving the user's file.
@@ -53347,7 +53397,7 @@ var TempoDevServer = class _TempoDevServer {
53347
53397
  // then forwarded, or the typed 503 once Flutter has failed.
53348
53398
  ...this.flutterDevServer ? { TEMPO_FLUTTER_URL: this.flutterDevServer.url } : {}
53349
53399
  },
53350
- watchdogScriptPath: await this.ensureDevserverWatchdogScript(),
53400
+ watchdogScriptPath,
53351
53401
  projectNode: toProjectNodeEnvOption(this.projectNodeOverride)
53352
53402
  });
53353
53403
  process2 = activeProcess;
@@ -53508,7 +53558,15 @@ var TempoDevServer = class _TempoDevServer {
53508
53558
  restartingForFlutter = false;
53509
53559
  }
53510
53560
  };
53561
+ let readinessCancelled = false;
53562
+ const assertReadinessOwnership = () => {
53563
+ throwIfLaunchAborted(options?.signal);
53564
+ if (readinessCancelled || self.hostStartGeneration !== startGeneration) {
53565
+ throw launchAbortError();
53566
+ }
53567
+ };
53511
53568
  const stopActiveProcess = async () => {
53569
+ readinessCancelled = true;
53512
53570
  self.stopUrlHealthProbe();
53513
53571
  await Promise.all([process2.terminate(), self.stopFlutterDevServer()]);
53514
53572
  await self.releaseNextDistDirClaim();
@@ -53571,6 +53629,7 @@ var TempoDevServer = class _TempoDevServer {
53571
53629
  await stopActiveProcess();
53572
53630
  },
53573
53631
  forceKill() {
53632
+ readinessCancelled = true;
53574
53633
  self.flutterHostActive = false;
53575
53634
  self.restartHostForFlutter = null;
53576
53635
  self.flutterChangedPaths.clear();
@@ -53584,7 +53643,13 @@ var TempoDevServer = class _TempoDevServer {
53584
53643
  self.idleProcessStatus = "stopped";
53585
53644
  },
53586
53645
  async waitUntilReady(timeoutMs) {
53587
- let result = await process2.waitUntilReady(timeoutMs);
53646
+ const owned = async (pending) => {
53647
+ const value = await pending;
53648
+ assertReadinessOwnership();
53649
+ return value;
53650
+ };
53651
+ assertReadinessOwnership();
53652
+ let result = await owned(process2.waitUntilReady(timeoutMs));
53588
53653
  self.recordStartAttempt({
53589
53654
  at: Date.now(),
53590
53655
  kind: "initial",
@@ -53618,9 +53683,10 @@ var TempoDevServer = class _TempoDevServer {
53618
53683
  } else if (nodeToolchainRetry) {
53619
53684
  nodeToolchainRetriesUsed += 1;
53620
53685
  setBundledNodeActivated(true);
53621
- self.projectNodeOverride = await resolveProjectNodeOverrideForDir(
53622
- self.tempoRoot
53686
+ const nodeOverride = await owned(
53687
+ resolveProjectNodeOverrideForDir(self.tempoRoot)
53623
53688
  );
53689
+ self.projectNodeOverride = nodeOverride;
53624
53690
  devLog("supervisor:node_toolchain_retry", {
53625
53691
  command: self.config.scripts.start,
53626
53692
  bundledNodeBinDir: getBundledNodeBinDir()
@@ -53629,19 +53695,29 @@ var TempoDevServer = class _TempoDevServer {
53629
53695
  crashRetriesUsed += 1;
53630
53696
  }
53631
53697
  self.stopUrlHealthProbe();
53632
- await process2.terminate();
53633
- await self.removeProcessMarkerForPid(process2.getPid()).catch(() => {
53634
- });
53698
+ await owned(process2.terminate());
53699
+ await owned(
53700
+ self.removeProcessMarkerForPid(process2.getPid()).catch(() => {
53701
+ })
53702
+ );
53635
53703
  if (lockConflictSidestep) {
53636
- self.nextDistDir = await self.selectSuffixedNextDistDir();
53704
+ const distDir = await owned(self.selectSuffixedNextDistDir());
53705
+ self.nextDistDir = distDir;
53637
53706
  devLog("supervisor:next_dist_dir_suffixed", {
53638
53707
  distDir: self.nextDistDir,
53639
53708
  reason: "observed-live-lock",
53640
53709
  tempoRoot: self.tempoRoot
53641
53710
  });
53642
53711
  }
53643
- process2 = await spawnProcess(attempt);
53644
- result = await process2.waitUntilReady(timeoutMs);
53712
+ const spawned = await spawnProcess(attempt);
53713
+ try {
53714
+ assertReadinessOwnership();
53715
+ } catch (error) {
53716
+ await spawned.terminate();
53717
+ throw error;
53718
+ }
53719
+ process2 = spawned;
53720
+ result = await owned(process2.waitUntilReady(timeoutMs));
53645
53721
  self.recordStartAttempt({
53646
53722
  at: Date.now(),
53647
53723
  kind: portCollision ? "port-retry" : lockConflictSidestep ? "lock-sidestep-retry" : nodeToolchainRetry ? "node-toolchain-retry" : "crash-retry",
@@ -53660,29 +53736,36 @@ var TempoDevServer = class _TempoDevServer {
53660
53736
  const shellPid = process2.getPid();
53661
53737
  if (shellPid) {
53662
53738
  const workerPids = new Set(
53663
- await resolveDescendantPids(shellPid).catch(() => [])
53739
+ await owned(resolveDescendantPids(shellPid).catch(() => []))
53664
53740
  );
53665
53741
  const readyPort = portFromReadyUrl(result.url);
53666
53742
  if (readyPort != null) {
53667
- const listenerPid = await findPortListenerPid(readyPort).catch(
53668
- () => null
53743
+ const listenerPid = await owned(
53744
+ findPortListenerPid(readyPort).catch(() => null)
53669
53745
  );
53670
53746
  if (listenerPid != null && workerPids.has(listenerPid)) {
53671
53747
  self.devserverLaunchPid = listenerPid;
53672
- self.devserverLaunchProcessStartedAt = await readProcessStartedAt(listenerPid);
53748
+ const processStartedAt = await owned(
53749
+ readProcessStartedAt(listenerPid)
53750
+ );
53751
+ self.devserverLaunchProcessStartedAt = processStartedAt;
53673
53752
  }
53674
53753
  }
53675
- await self.writeProcessMarker(shellPid, [...workerPids]).catch(() => {
53676
- });
53754
+ await owned(
53755
+ self.writeProcessMarker(shellPid, [...workerPids]).catch(() => {
53756
+ })
53757
+ );
53677
53758
  }
53678
- await self.persistStatus();
53759
+ await owned(self.persistStatus());
53679
53760
  self.startUrlHealthProbe(result.url);
53680
53761
  t.done({ ok: true, url: result.url, pid: result.pid });
53681
53762
  } else {
53682
53763
  self.stopUrlHealthProbe();
53683
- await process2.terminate();
53684
- await self.removeProcessMarkerForPid(process2.getPid()).catch(() => {
53685
- });
53764
+ await owned(process2.terminate());
53765
+ await owned(
53766
+ self.removeProcessMarkerForPid(process2.getPid()).catch(() => {
53767
+ })
53768
+ );
53686
53769
  self.idleProcessStatus = "error";
53687
53770
  const finalConflict = parseDevServerLockConflict(
53688
53771
  process2.getRecentOutputTail()
@@ -53720,8 +53803,8 @@ var TempoDevServer = class _TempoDevServer {
53720
53803
  };
53721
53804
  }
53722
53805
  self.state.lastError = result.message ?? "Canvas dev server failed to become ready";
53723
- await self.persistStatus().catch(() => {
53724
- });
53806
+ await owned(self.persistStatus().catch(() => {
53807
+ }));
53725
53808
  t.done({
53726
53809
  ok: false,
53727
53810
  reason: "not_ready",
@@ -55767,6 +55850,7 @@ async function nodeModulesHasMeaningfulEntries(packageRoot) {
55767
55850
  }
55768
55851
  function looksLikeGeneratedInstallScript(command, appDir) {
55769
55852
  const normalized = command.trim();
55853
+ if (normalized === "npm install && npm install --prefix ..") return true;
55770
55854
  const installCommand = "(?:npm\\s+(?:install|ci)|pnpm\\s+install(?:\\s+--(?:no-)?frozen-lockfile)?|yarn\\s+install(?:\\s+--immutable)?|bun\\s+install)";
55771
55855
  const appFolder = "[\\w@-][\\w@.-]*(?:/[\\w@-][\\w@.-]*)*";
55772
55856
  const backToTempo = "(?:\\.\\./)+tempo";
@@ -64417,4 +64501,4 @@ export {
64417
64501
  buildBaselineCaptureArgs,
64418
64502
  main
64419
64503
  };
64420
- //# sourceMappingURL=chunk-EWF3ZRZK.js.map
64504
+ //# sourceMappingURL=chunk-37ND33UQ.js.map