Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

refactor: crypto.randomUUID over the uuid dep, and one MSVC bootstrap

Etienne Lescot4fa65d9f031a
diff --git a/electron/ai-edition/chat-service.ts b/electron/ai-edition/chat-service.ts
index 14372c4b5..0886768ce 100644
--- a/electron/ai-edition/chat-service.ts
+++ b/electron/ai-edition/chat-service.ts
@@ -5,7 +5,6 @@
// `toolEnd` lifecycle + `error` events into the renderer through the
// ChatEventSink.
-import { v4 as uuidv4 } from "uuid";
import {
type AxcutTimelineOperation,
applyTimelineOperation,
@@ -160,7 +159,7 @@ export function listSessions(projectId: string): ChatSessionSummary[] {
export function createSession(projectId: string, title?: string): ChatSessionSummary {
const m = getProjectSessions(projectId);
- const id = `sess_${uuidv4()}`;
+ const id = `sess_${crypto.randomUUID()}`;
const now = new Date().toISOString();
const session: ChatSession = {
id,
@@ -278,7 +277,7 @@ export async function runChat(
}
const userMessage: AiEditionChatMessage = {
- id: uuidv4(),
+ id: crypto.randomUUID(),
role: "user",
content: message,
createdAt: new Date().toISOString(),
@@ -369,7 +368,7 @@ export async function runChat(
}
const assistantMessage: AiEditionChatMessage = {
- id: uuidv4(),
+ id: crypto.randomUUID(),
role: "assistant",
content: result.text,
createdAt: new Date().toISOString(),
@@ -494,7 +493,7 @@ export async function runTimelineOperation(
if (conversationMessage.trim() && session) {
const assistantMessage: AiEditionChatMessage = {
- id: `msg_${uuidv4()}`,
+ id: `msg_${crypto.randomUUID()}`,
role: "assistant",
content: conversationMessage.trim(),
createdAt: new Date().toISOString(),
diff --git a/package.json b/package.json
index ff602516f..78af3b72b 100644
--- a/package.json
+++ b/package.json
@@ -101,7 +101,6 @@
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"tailwindcss-animate": "^1.0.7",
- "uuid": "^13.0.0",
"web-demuxer": "^4.0.0",
"zod": "^4.1.12",
"zustand": "^5.0.8"
diff --git a/scripts/build-windows-compositor-addon.mjs b/scripts/build-windows-compositor-addon.mjs
index 8bea0e874..dce675986 100644
--- a/scripts/build-windows-compositor-addon.mjs
+++ b/scripts/build-windows-compositor-addon.mjs
@@ -15,125 +15,17 @@
// shipped, and require() fails at runtime even with the right dir on PATH.
// See poc-d3d/.cargo/config.toml for the pin.
-import { spawn, spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
+import { findVcVarsAll, run as spawnStep } from "./msvcEnv.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.join(__dirname, "..");
const POC_D3D_DIR = path.join(ROOT, "poc-d3d");
const BUILD_OUT_DIR = path.join(ROOT, "electron", "native", "compositor-view", "build");
-function findVcVarsAll() {
- const explicit = process.env.VCVARSALL;
- if (explicit && fs.existsSync(explicit)) {
- return explicit;
- }
-
- const vswhere = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe";
- if (fs.existsSync(vswhere)) {
- const result = spawnSync(
- vswhere,
- [
- "-latest",
- "-products",
- "*",
- "-requires",
- "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
- "-property",
- "installationPath",
- ],
- { encoding: "utf8", windowsHide: true },
- );
- const installPath = result.stdout?.trim();
- if (result.status === 0 && installPath) {
- const candidate = path.join(installPath, "VC", "Auxiliary", "Build", "vcvarsall.bat");
- if (fs.existsSync(candidate)) {
- return candidate;
- }
- }
- }
-
- if (process.env.VSINSTALLDIR) {
- const candidate = path.join(
- process.env.VSINSTALLDIR,
- "VC",
- "Auxiliary",
- "Build",
- "vcvarsall.bat",
- );
- if (fs.existsSync(candidate)) {
- return candidate;
- }
- }
-
- // vswhere doesn't always enumerate pre-release channels (e.g. "Insiders"
- // builds) — walk the install roots generically so new VS releases and
- // preview channels are found automatically (same policy as the wgc-capture
- // helper build script).
- const editions = ["Community", "Professional", "Enterprise", "BuildTools"];
- const installRoots = [
- "C:\\Program Files\\Microsoft Visual Studio",
- "C:\\Program Files (x86)\\Microsoft Visual Studio",
- ];
-
- const listDirs = (dir) => {
- try {
- return fs
- .readdirSync(dir, { withFileTypes: true })
- .filter((entry) => entry.isDirectory())
- .map((entry) => path.join(dir, entry.name));
- } catch {
- return [];
- }
- };
-
- for (const installRoot of installRoots) {
- for (const versionDir of listDirs(installRoot)) {
- for (const channelDir of [versionDir, ...listDirs(versionDir)]) {
- const direct = path.join(channelDir, "VC", "Auxiliary", "Build", "vcvarsall.bat");
- if (fs.existsSync(direct)) {
- return direct;
- }
- for (const edition of editions) {
- const nested = path.join(
- channelDir,
- edition,
- "VC",
- "Auxiliary",
- "Build",
- "vcvarsall.bat",
- );
- if (fs.existsSync(nested)) {
- return nested;
- }
- }
- }
- }
- }
-
- return null;
-}
-
-function run(command, args, options = {}) {
- return new Promise((resolve, reject) => {
- const child = spawn(command, args, {
- cwd: POC_D3D_DIR,
- stdio: "inherit",
- windowsHide: true,
- ...options,
- });
- child.once("error", reject);
- child.once("exit", (code) => {
- if (code === 0) {
- resolve();
- } else {
- reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`));
- }
- });
- });
-}
+const run = (command, args, options = {}) => spawnStep(command, args, { cwd: ROOT, ...options });
async function runInVsEnv(command) {
const vcvarsAll = findVcVarsAll();
diff --git a/scripts/build-windows-wgc-helper.mjs b/scripts/build-windows-wgc-helper.mjs
index 60384efa3..063d81b30 100644
--- a/scripts/build-windows-wgc-helper.mjs
+++ b/scripts/build-windows-wgc-helper.mjs
@@ -1,8 +1,8 @@
-import { spawn, spawnSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
+import { findVcVarsAll, run as spawnStep } from "./msvcEnv.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.join(__dirname, "..");
@@ -12,101 +12,6 @@ const COMPAT_LIB_DIR = path.join(BUILD_DIR, "compat-libs");
const BIN_DIR = path.join(ROOT, "electron", "native", "bin", "win32-x64");
const CMAKE = process.env.CMAKE_EXE ?? "cmake";
-function findVcVarsAll() {
- const explicit = process.env.VCVARSALL;
- if (explicit && fs.existsSync(explicit)) {
- return explicit;
- }
-
- const vswhere = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe";
- if (fs.existsSync(vswhere)) {
- const result = spawnSync(
- vswhere,
- [
- "-latest",
- "-products",
- "*",
- "-requires",
- "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
- "-property",
- "installationPath",
- ],
- { encoding: "utf8", windowsHide: true },
- );
- const installPath = result.stdout?.trim();
- if (result.status === 0 && installPath) {
- const candidate = path.join(installPath, "VC", "Auxiliary", "Build", "vcvarsall.bat");
- if (fs.existsSync(candidate)) {
- return candidate;
- }
- }
- }
-
- if (process.env.VSINSTALLDIR) {
- const candidate = path.join(
- process.env.VSINSTALLDIR,
- "VC",
- "Auxiliary",
- "Build",
- "vcvarsall.bat",
- );
- if (fs.existsSync(candidate)) {
- return candidate;
- }
- }
-
- // vswhere doesn't always enumerate pre-release channels (e.g. "Insiders"
- // builds), and the on-disk layout for those isn't a stable "<year>\<edition>"
- // path -- Visual Studio 2026 Insiders installs under a numeric product
- // version folder like "18\Insiders\<edition>" instead of "2026\<edition>".
- // Walk the install roots generically instead of hard-coding version/channel
- // names so new VS releases and preview channels are found automatically.
- const editions = ["Community", "Professional", "Enterprise", "BuildTools"];
- const installRoots = [
- "C:\\Program Files\\Microsoft Visual Studio",
- "C:\\Program Files (x86)\\Microsoft Visual Studio",
- ];
-
- const listDirs = (dir) => {
- try {
- return fs
- .readdirSync(dir, { withFileTypes: true })
- .filter((entry) => entry.isDirectory())
- .map((entry) => path.join(dir, entry.name));
- } catch {
- return [];
- }
- };
-
- for (const installRoot of installRoots) {
- for (const versionDir of listDirs(installRoot)) {
- // versionDir is either an edition directly ("2022\Community") or a
- // channel that nests editions ("18\Insiders\Community").
- for (const channelDir of [versionDir, ...listDirs(versionDir)]) {
- const direct = path.join(channelDir, "VC", "Auxiliary", "Build", "vcvarsall.bat");
- if (fs.existsSync(direct)) {
- return direct;
- }
- for (const edition of editions) {
- const nested = path.join(
- channelDir,
- edition,
- "VC",
- "Auxiliary",
- "Build",
- "vcvarsall.bat",
- );
- if (fs.existsSync(nested)) {
- return nested;
- }
- }
- }
- }
- }
-
- return null;
-}
-
function findWindowsSdkUmLibDir() {
const sdkLibRoot = "C:\\Program Files (x86)\\Windows Kits\\10\\Lib";
if (!fs.existsSync(sdkLibRoot)) {
@@ -122,24 +27,7 @@ function findWindowsSdkUmLibDir() {
.at(-1);
}
-function run(command, args, options = {}) {
- return new Promise((resolve, reject) => {
- const child = spawn(command, args, {
- cwd: ROOT,
- stdio: "inherit",
- windowsHide: true,
- ...options,
- });
- child.once("error", reject);
- child.once("exit", (code) => {
- if (code === 0) {
- resolve();
- } else {
- reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`));
- }
- });
- });
-}
+const run = (command, args, options = {}) => spawnStep(command, args, { cwd: ROOT, ...options });
async function runInVsEnv(command) {
const vcvarsAll = findVcVarsAll();
diff --git a/scripts/msvcEnv.mjs b/scripts/msvcEnv.mjs
new file mode 100644
index 000000000..ca2f68aa5
--- /dev/null
+++ b/scripts/msvcEnv.mjs
@@ -0,0 +1,122 @@
+// Shared MSVC bootstrap for the two Windows native build scripts
+// (build-windows-wgc-helper.mjs and build-windows-compositor-addon.mjs).
+// Both need the same vcvarsall.bat discovery; their runInVsEnv bodies differ
+// (SDK lib compat shims vs cargo) and stay in their own scripts.
+
+import { spawn, spawnSync } from "node:child_process";
+import fs from "node:fs";
+import path from "node:path";
+
+export function findVcVarsAll() {
+ const explicit = process.env.VCVARSALL;
+ if (explicit && fs.existsSync(explicit)) {
+ return explicit;
+ }
+
+ const vswhere = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe";
+ if (fs.existsSync(vswhere)) {
+ const result = spawnSync(
+ vswhere,
+ [
+ "-latest",
+ "-products",
+ "*",
+ "-requires",
+ "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
+ "-property",
+ "installationPath",
+ ],
+ { encoding: "utf8", windowsHide: true },
+ );
+ const installPath = result.stdout?.trim();
+ if (result.status === 0 && installPath) {
+ const candidate = path.join(installPath, "VC", "Auxiliary", "Build", "vcvarsall.bat");
+ if (fs.existsSync(candidate)) {
+ return candidate;
+ }
+ }
+ }
+
+ if (process.env.VSINSTALLDIR) {
+ const candidate = path.join(
+ process.env.VSINSTALLDIR,
+ "VC",
+ "Auxiliary",
+ "Build",
+ "vcvarsall.bat",
+ );
+ if (fs.existsSync(candidate)) {
+ return candidate;
+ }
+ }
+
+ // vswhere doesn't always enumerate pre-release channels (e.g. "Insiders"
+ // builds), and the on-disk layout for those isn't a stable "<year>\<edition>"
+ // path -- Visual Studio 2026 Insiders installs under a numeric product
+ // version folder like "18\Insiders\<edition>" instead of "2026\<edition>".
+ // Walk the install roots generically instead of hard-coding version/channel
+ // names so new VS releases and preview channels are found automatically.
+ const editions = ["Community", "Professional", "Enterprise", "BuildTools"];
+ const installRoots = [
+ "C:\\Program Files\\Microsoft Visual Studio",
+ "C:\\Program Files (x86)\\Microsoft Visual Studio",
+ ];
+
+ const listDirs = (dir) => {
+ try {
+ return fs
+ .readdirSync(dir, { withFileTypes: true })
+ .filter((entry) => entry.isDirectory())
+ .map((entry) => path.join(dir, entry.name));
+ } catch {
+ return [];
+ }
+ };
+
+ for (const installRoot of installRoots) {
+ for (const versionDir of listDirs(installRoot)) {
+ // versionDir is either an edition directly ("2022\Community") or a
+ // channel that nests editions ("18\Insiders\Community").
+ for (const channelDir of [versionDir, ...listDirs(versionDir)]) {
+ const direct = path.join(channelDir, "VC", "Auxiliary", "Build", "vcvarsall.bat");
+ if (fs.existsSync(direct)) {
+ return direct;
+ }
+ for (const edition of editions) {
+ const nested = path.join(
+ channelDir,
+ edition,
+ "VC",
+ "Auxiliary",
+ "Build",
+ "vcvarsall.bat",
+ );
+ if (fs.existsSync(nested)) {
+ return nested;
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+}
+
+/** spawn() as a promise. Callers pass their own cwd. */
+export function run(command, args, options = {}) {
+ return new Promise((resolve, reject) => {
+ const child = spawn(command, args, {
+ stdio: "inherit",
+ windowsHide: true,
+ ...options,
+ });
+ child.once("error", reject);
+ child.once("exit", (code) => {
+ if (code === 0) {
+ resolve();
+ } else {
+ reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`));
+ }
+ });
+ });
+}
diff --git a/src/lib/ai-edition/document/ids.ts b/src/lib/ai-edition/document/ids.ts
index cd8fcb170..e0a560640 100644
--- a/src/lib/ai-edition/document/ids.ts
+++ b/src/lib/ai-edition/document/ids.ts
@@ -1,8 +1,6 @@
-import { v4 as uuidv4 } from "uuid";
-
// ponytail: stable id format `${prefix}_${uuid}` — readable in stored documents
// and grep-friendly. Replacement for axcut's packages/axcut-schema ids helper
// until the full schema package lands in-tree.
export function createId(prefix: string): string {
- return `${prefix}_${uuidv4()}`;
+ return `${prefix}_${crypto.randomUUID()}`;
}