### Execute Brave Browser Compilation Workflow Source: https://context7.com/jaidcompiles/brave/llms.txt Runs the complete Brave Browser compilation process, encompassing repository initialization, patching, configuration, and building. This function automates cloning the repository, installing dependencies, synchronizing source code, applying customizations, and generating the final executable. The output is typically located in the `src/out/Release/` directory. ```typescript const compiler = new BraveCompiler({ folder: 'C:/temp/brave-build', nodeInstallationFolder: 'C:/portable/node/24.11.1', arch: 'x64', os: 'win', flavor: 'jave', buildTarget: 'Release', lowMemory: false, }) await compiler.run() // Execution flow: // 1. Clones brave-browser repository using direct download method // 2. Patches init scripts to skip redundant npm installs // 3. Runs npm install in brave-browser folder // 4. Runs npm run init with target_os and target_arch // 5. Runs npm install in brave-core folder // 6. Runs npm run sync to download Chromium source // 7. Applies customizations if flavor is 'jave' // 8. Patches GN script to support custom --gn arguments // 9. Generates build files with GN // 10. Verifies output executable exists // Expected output: jave.exe or brave.exe in src/out/Release/ ``` -------------------------------- ### Initialize Brave Browser Compiler Instance Source: https://context7.com/jaidcompiles/brave/llms.txt Creates a new BraveCompiler instance, setting up configuration options for the target platform, architecture, build type, and customization level. It automatically configures environment variables, GN build options, and prepares the build environment, including disabling unwanted features if a custom flavor is specified. Dependencies include the 'forward-slash-path' module for path manipulation. ```typescript import {BraveCompiler} from './lib/BraveCompiler.ts' import * as path from 'forward-slash-path' const compiler = new BraveCompiler({ folder: path.join('C:', 'temp', 'brave-build'), nodeInstallationFolder: 'C:/portable/node/24.11.1', arch: 'x64', os: 'win', flavor: 'jave', // 'brave' for vanilla, 'jave' for customized buildTarget: 'Release', lowMemory: true, // Set to true to use jobs:1 for low-memory systems personalArch: 'znver2', // Optional: CPU-specific optimization }) // The compiler automatically: // - Sets up environment variables for Node.js and depot_tools // - Configures GN build options with dummy API keys // - Prepares temporary folder structure // - Disables unwanted features if flavor is 'jave' ``` -------------------------------- ### BraveCompiler Constructor Source: https://context7.com/jaidcompiles/brave/llms.txt Initializes a new Brave Browser compiler instance with specified configuration options for building custom browser versions. ```APIDOC ## BraveCompiler Constructor ### Description Creates a new Brave Browser compiler instance with configuration options for target platform, architecture, build type, and customization level. ### Method `new BraveCompiler(options)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **folder** (string) - Required - The directory where the build process will be managed. - **nodeInstallationFolder** (string) - Required - Path to the Node.js installation. - **arch** (string) - Required - Target architecture (e.g., 'x64'). - **os** (string) - Required - Target operating system (e.g., 'win'). - **flavor** (string) - Required - Build flavor ('brave' for vanilla, 'jave' for customized). - **buildTarget** (string) - Required - Build configuration (e.g., 'Release'). - **lowMemory** (boolean) - Optional - Set to true for low-memory systems (uses jobs:1). - **personalArch** (string) - Optional - CPU-specific optimization (e.g., 'znver2'). ### Request Example ```typescript import {BraveCompiler} from './lib/BraveCompiler.ts' import * as path from 'forward-slash-path' const compiler = new BraveCompiler({ folder: path.join('C:', 'temp', 'brave-build'), nodeInstallationFolder: 'C:/portable/node/24.11.1', arch: 'x64', os: 'win', flavor: 'jave', // 'brave' for vanilla, 'jave' for customized buildTarget: 'Release', lowMemory: true, // Set to true to use jobs:1 for low-memory systems personalArch: 'znver2', // Optional: CPU-specific optimization }) ``` ### Response #### Success Response (200) - **compilerInstance** (object) - An initialized BraveCompiler instance. #### Response Example ```json { "message": "BraveCompiler instance created successfully." } ``` ``` -------------------------------- ### Compiler.cloneGithubRepo() Source: https://context7.com/jaidcompiles/brave/llms.txt Clones a GitHub repository using various methods (SSH, HTTPS, direct ZIP download) with optional caching support. ```APIDOC ## Compiler.cloneGithubRepo() ### Description Clones a GitHub repository using SSH, HTTPS, or direct ZIP download with optional caching support. ### Method `await compiler.cloneGithubRepo(repoPath, cloneMethod)` ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **repoPath** (string) - Required - The path of the GitHub repository (e.g., 'brave/brave-browser'). - **cloneMethod** (string) - Required - The method to use for cloning ('ssh', 'https', or 'direct'). ### Request Example ```typescript import {Compiler} from './lib/Compiler.ts' const compiler = new Compiler({ folder: '/tmp/my-build', cloneMethod: 'direct', // 'ssh', 'https', or 'direct' cacheClones: true, cacheFolder: '/tmp/git-cache', }) await compiler.init() // Clone a specific repository await compiler.cloneGithubRepo('brave/brave-browser', 'direct') // Clone using SSH await compiler.cloneGithubRepo('nodejs/node', 'ssh') // Clone using HTTPS await compiler.cloneGithubRepo('microsoft/TypeScript', 'https') ``` ### Response #### Success Response (200) - **status** (string) - Indicates the repository cloning was successful. - **localPath** (string) - The local path where the repository was cloned. #### Response Example ```json { "status": "success", "localPath": "/tmp/my-build/git/brave/brave-browser" } ``` ``` -------------------------------- ### BraveCompiler.run() Source: https://context7.com/jaidcompiles/brave/llms.txt Executes the full Brave Browser compilation workflow, from cloning the repository to building the final executable. ```APIDOC ## BraveCompiler.run() ### Description Executes the complete Brave Browser compilation workflow including repository initialization, patching, configuration, and building. ### Method `await compiler.run()` ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript const compiler = new BraveCompiler({ folder: 'C:/temp/brave-build', nodeInstallationFolder: 'C:/portable/node/24.11.1', arch: 'x64', os: 'win', flavor: 'jave', buildTarget: 'Release', lowMemory: false, }) await compiler.run() ``` ### Response #### Success Response (200) - **status** (string) - Indicates the build process completed successfully. - **outputDirectory** (string) - The path to the directory containing the compiled executable. #### Response Example ```json { "status": "success", "outputDirectory": "src/out/Release/" } ``` ``` -------------------------------- ### Clone GitHub Repository with Caching Options Source: https://context7.com/jaidcompiles/brave/llms.txt Clones a GitHub repository using specified methods like SSH, HTTPS, or direct ZIP download, with an option to enable caching for faster subsequent clones. This function initializes the compiler's environment and then performs the repository cloning operation. The cloned repository is placed in a specified folder, and an untouched copy can be stored in a cache folder if enabled. ```typescript import {Compiler} from './lib/Compiler.ts' const compiler = new Compiler({ folder: '/tmp/my-build', cloneMethod: 'direct', // 'ssh', 'https', or 'direct' cacheClones: true, cacheFolder: '/tmp/git-cache', }) await compiler.init() // Clone a specific repository await compiler.cloneGithubRepo('brave/brave-browser', 'direct') // Result: Repository contents in /tmp/my-build/git/brave/brave-browser // Cache: Untouched copy in /tmp/git-cache/git/brave/brave-browser // Clone using SSH await compiler.cloneGithubRepo('nodejs/node', 'ssh') // Executes: git clone ssh://git@github.com/nodejs/node.git // Clone using HTTPS await compiler.cloneGithubRepo('microsoft/TypeScript', 'https') // Executes: git clone https://github.com/microsoft/TypeScript.git ``` -------------------------------- ### Generate Git Config from Options (TypeScript) Source: https://context7.com/jaidcompiles/brave/llms.txt Generates a Git configuration file content from a structured JavaScript object. It takes Git options as input and outputs a string formatted as a Git config file. This is useful for programmatic configuration of Git settings within a build process. ```typescript import {Compiler} from './lib/Compiler.ts' const compiler = new Compiler({ folder: '/tmp/build', gitOptions: { core: { longpaths: true, autocrlf: false, eol: 'lf', checkStat: 'minimal', }, fetch: { negotiationAlgorithm: 'skipping', }, diff: { algorithm: 'histogram', }, }, }) // Render as Git config file format const configContent = compiler.renderGitConfig() console.log(configContent) // Output: // [core] // longpaths = true // autocrlf = false // eol = lf // checkStat = minimal // [fetch] // negotiationAlgorithm = skipping // [diff] // algorithm = histogram // Write to file await compiler.outputGitConfig('.gitconfig') // Render as command-line arguments const args = compiler.renderGitConfigToArgs() console.log(args) // Output: ['-c', 'core.longpaths=true', '-c', 'core.autocrlf=false', '-c', 'core.eol=lf', ...] // Use in git commands await compiler.runCommand(['git', ...args, 'clone', 'https://example.com/repo.git', 'dest']) // Executes: git -c core.longpaths=true -c core.autocrlf=false ... clone https://example.com/repo.git dest ``` -------------------------------- ### Execute Shell Commands with Compiler.runCommand Source: https://context7.com/jaidcompiles/brave/llms.txt The `runCommand` method in the `Compiler` class enables the execution of shell commands. It supports environment variable inheritance from the compiler's configuration and allows for specifying the current working directory and additional environment variables for the command. Automatic error handling is included, throwing errors with exit codes upon failure. ```typescript import {Compiler} from './lib/Compiler.ts' const compiler = new Compiler({ folder: '/tmp/build', environmentVariables: { NODE_ENV: 'production', DEBUG: 'false', }, }) // Run a simple command in the base folder await compiler.runCommand(['git', 'status']) // Executes in: /tmp/build // Environment: includes NODE_ENV=production, DEBUG=false // Run command in a subfolder await compiler.runCommand(['npm', 'install'], { cwdExtra: ['git', 'brave', 'brave-browser'], }) // Executes in: /tmp/build/git/brave/brave-browser // Run with additional environment variables await compiler.runCommand(['node', 'build.js'], { cwdExtra: 'scripts', env: { VERBOSE: 'true', }, }) // Executes in: /tmp/build/scripts // Environment: includes NODE_ENV, DEBUG, VERBOSE // Command failures throw errors with exit codes try { await compiler.runCommand(['npm', 'test']) } catch (error) { console.error('Command failed:', error.message) // Error message includes exit code and full command } ``` -------------------------------- ### Apply Regex Patches to Source Files with Compiler.applyPatch Source: https://context7.com/jaidcompiles/brave/llms.txt The `applyPatch` method in the `Compiler` class allows for regex-based find-and-replace operations on specified source files. It automatically verifies that patches have been applied, ensuring code integrity. This method is useful for tasks like disabling features, changing default settings, or renaming executables across a codebase. ```typescript import {Compiler} from './lib/Compiler.ts' const compiler = new Compiler({ folder: '/tmp/brave-build', }) // Disable a feature by changing a flag await compiler.applyPatch({ files: compiler.fromHere('git/brave/brave-browser/src/brave/components/brave_sync/features.cc'), from: /BASE_FEATURE\(\s*kBraveSync\s*,\s*base::FEATURE_ENABLED_BY_DEFAULT\s*\)/, to: 'BASE_FEATURE(kBraveSync, base::FEATURE_DISABLED_BY_DEFAULT)', }) // Output: { patchedFiles: ['/tmp/brave-build/git/brave/brave-browser/src/brave/components/brave_sync/features.cc'] } // Change a default setting await compiler.applyPatch({ files: compiler.fromHere('git/brave/brave-browser/src/brave/browser/brave_profile_prefs.cc'), from: /->RegisterBooleanPref\(kLocationBarIsWide,\s*false\)/, to: '->RegisterBooleanPref(kLocationBarIsWide, true)', }) // Rename executable across multiple files await compiler.applyPatch({ files: compiler.fromHere('git/brave/brave-browser/src/chrome/BUILD.gn'), from: /_chrome_output_name = "chrome"/g, to: '_chrome_output_name = "jave"', }) ``` -------------------------------- ### Manage .env Files with Compiler.outputEnv() and patchEnvFile() in TypeScript Source: https://context7.com/jaidcompiles/brave/llms.txt The Compiler class provides methods to write and merge environment variables into .env files. `outputEnv` creates a new file, while `patchEnvFile` and `patchEnvFileWith` merge variables into existing files, preserving original values where possible. This is useful for build processes and configuration management. ```typescript import {Compiler} from './lib/Compiler.ts' import {EnvironmentVariables} from './lib/EnvironmentVariables.ts' const compiler = new Compiler({ folder: '/tmp/build', }) // Set environment variables compiler.environmentVariables.set('NODE_ENV', 'production') compiler.environmentVariables.set('PORT', 8080) compiler.environmentVariables.set('DEBUG', false) // Write to new .env file await compiler.outputEnv('.env') // Creates /tmp/build/.env with content: // NODE_ENV=production // PORT=8080 // DEBUG=false // Merge with existing .env file await compiler.patchEnvFile('.env') // Reads existing file, merges variables, preserves original values for unchanged keys // Merge custom environment variables into file const customEnv = new EnvironmentVariables() customEnv.set('DATABASE_URL', 'postgresql://localhost/mydb') customEnv.set('REDIS_URL', 'redis://localhost:6379') await compiler.patchEnvFileWith('.env.local', customEnv) // Updates /tmp/build/.env.local with database configuration ``` -------------------------------- ### Manage Environment Variables with EnvironmentVariables Class Source: https://context7.com/jaidcompiles/brave/llms.txt The `EnvironmentVariables` class provides a robust way to manage environment variables. It supports type-safe parsing, manipulation of the PATH variable (prepending and adding items), and serialization/deserialization to/from `.env` file formats. It also facilitates merging different environment configurations and preparing environment variables for subprocess execution. ```typescript import {EnvironmentVariables} from './lib/EnvironmentVariables.ts' // Create from object const env = EnvironmentVariables.fromObject({ NODE_ENV: 'production', PORT: 3000, DEBUG: true, API_KEY: 'secret123', }) // Parse values automatically console.log(env.get('PORT')) // 3000 (number) console.log(env.get('DEBUG')) // true (boolean) // Manipulate PATH variable env.prependPathItem('/usr/local/bin') env.prependPathItem(['C:/tools/bin', 'C:/python39']) env.addPathItem('/opt/bin') console.log(env.getPath()) // ['C:/tools/bin', 'C:/python39', '/usr/local/bin', ..., '/opt/bin'] // Load from .env file const fileEnv = await EnvironmentVariables.fromEnvFile('/path/to/.env') // Parse .env contents const contents = ` NODE_ENV=production PORT=8080 DEBUG=true API_KEY="quoted-value" ` const parsedEnv = EnvironmentVariables.fromEnvContents(contents) // Merge multiple environment sets const defaultEnv = EnvironmentVariables.fromObject({ TIMEOUT: 5000 }) const overrideEnv = EnvironmentVariables.fromObject({ TIMEOUT: 10000 }) const merged = EnvironmentVariables.merge(defaultEnv, overrideEnv) console.log(merged.get('TIMEOUT')) // 10000 // Export to .env format const output = env.toEnvContents() // Result: // NODE_ENV=production // PORT=3000 // DEBUG=true // API_KEY=secret123 // Merge with process.env for subprocess const finalEnv = env.toFinalStringObject() // Contains all process.env variables plus custom ones ``` -------------------------------- ### Create Type-Safe Options with makeOptions in TypeScript Source: https://context7.com/jaidcompiles/brave/llms.txt The makeOptions function generates type-safe option objects. It validates required fields and merges default values, ensuring configurations are complete and consistent. This function is useful for managing complex application settings. ```typescript import {makeOptions} from './lib/package/make-options/src/index.ts' import type {InputOptions} from './lib/package/make-options/src/index.ts' type MyOptions = InputOptions<{ required: { host: string port: number } optional: { timeout: number retry: boolean } defaults: { timeout: 5000 retry: true } }> // Create options with validation const options = makeOptions( { host: 'localhost', port: 3000, timeout: 10000, // Override default }, { requiredKeys: ['host', 'port'], defaultOptions: { timeout: 5000, retry: true, }, } ) // Result: { host: 'localhost', port: 3000, timeout: 10000, retry: true } // Missing required fields throw errors try { const invalid = makeOptions( { host: 'localhost' }, // Missing 'port' { requiredKeys: ['host', 'port'] } ) } catch (error) { console.error(error.message) // "Required options are missing. Given keys: ['host']. Required keys: ['host', 'port']" } // With normalizations type NormalizedOptions = InputOptions<{ required: { path: string } normalizations: { path: string } }> const normalized = makeOptions( { path: 'some\windows\path' }, { requiredKeys: ['path'], normalize: { path: (value) => (value as string).replace(/\\/g, '/'), }, } ) // Result: { path: 'some/windows/path' } ``` -------------------------------- ### Format Terminal Output with ANSI Sequences in TypeScript Source: https://context7.com/jaidcompiles/brave/llms.txt This module provides utility functions for applying ANSI escape codes to terminal output, enabling colored and styled text for file paths, numbers, and commands. It enhances the readability and presentation of command-line interfaces. ```typescript import * as ansi from './lib/package/ansi-sequences/src/index.ts' // Format file paths with colors console.log(ansi.file('/home/user/project/src/main.ts')) // Output: /home/user/project/ (purple) + src/main.ts (orange) console.log(ansi.folder('/usr/local/bin')) // Output: /usr/local/bin (purple) // Format numbers with colors console.log(`Size: ${ansi.integer(1500000)}`) // 1,500,000 (cyan) console.log(`Progress: ${ansi.percent(0.75, 1)}`) // 75.0% (cyan) console.log(`Duration: ${ansi.ms(45500)}`) // 45s (cyan) console.log(`File size: ${ansi.bytesShort(1536000)}`) // 1.54 MB (cyan) // Format commands with proper escaping console.log(ansi.command(['git', 'commit', '-m', 'Fix bug'])) // Output: git commit -m 'Fix bug' (styled) console.log(ansi.command(['node', 'script.js', '--input', 'file with spaces.txt'])) // Output: node script.js --input 'file with spaces.txt' // Create terminal links (VSCode/iTerm2/etc) console.log(ansi.fileLink('/path/to/file.ts', 'Open file')) // Output: Clickable link that opens file in editor // Format file with size const sizeInfo = await ansi.fileWithSize('/path/to/large-file.bin') console.log(sizeInfo) // Output: 15.3 MB /path/to/large-file.bin // Custom formatting with template strings console.log(ansi.make`Processed ${42} files in ${1234}ms`) // Output: Processed 42 (cyan) files in 1234 (cyan)ms ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.