-
-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
Complete technical reference for Arsenal Lab components and APIs.
- Core Components
- Custom Hooks
- UI Components
- Utility Functions
- Type Definitions
- Advanced Usage
- Migration Guide
- Support
Main performance testing component with real-time benchmarking.
interface PerformanceArsenalProps {
initialTab?: 'postmessage' | 'registry' | 'crypto' | 'memory';
showHardwareWarning?: boolean;
enableAnalytics?: boolean;
}import { PerformanceArsenal } from '@bun/performance-arsenal';
function App() {
return (
<PerformanceArsenal
initialTab="crypto"
showHardwareWarning={true}
enableAnalytics={true}
/>
);
}Interactive Bun.build() API and CLI playground.
interface BuildConfigurationArsenalProps {
initialConfig?: Partial<BuildConfiguration>;
showCliCommand?: boolean;
enableCodeCopy?: boolean;
}interface BuildConfiguration {
// Core Options
entrypoints: string[];
outdir: string;
target: 'browser' | 'bun' | 'node';
format: 'esm' | 'cjs' | 'iife';
// Environment
env: 'inline' | 'disable' | string;
define: Record<string, string>;
conditions: string[];
// JSX
jsx: {
runtime: 'automatic' | 'classic';
factory: string;
fragment: string;
importSource: string;
};
// Optimization
minify: boolean | {
whitespace: boolean;
syntax: boolean;
identifiers: boolean;
};
splitting: boolean;
external: string[];
packages: 'bundle' | 'external';
// Output
sourcemap: 'none' | 'linked' | 'inline' | 'external';
naming: string | {
entry: string;
chunk: string;
asset: string;
};
publicPath: string;
// Advanced
bytecode: boolean;
throw: boolean;
banner: string;
footer: string;
drop: string[];
ignoreDCEAnnotations: boolean;
emitDCEAnnotations: boolean;
// CLI-Specific (not in JS API)
production?: boolean;
watch?: boolean;
noClearScreen?: boolean;
reactFastRefresh?: boolean;
compile?: boolean;
compileExecArgv?: string;
}Core hook for performance benchmarking functionality.
interface PerformanceArsenalHook {
// State
tab: 'postmessage' | 'registry' | 'crypto' | 'memory';
pmSize: number;
regAction: string;
isRunning: boolean;
benchmarkResults: BenchmarkResult[];
// Hardware
hardwareInfo: HardwareInfo;
// Actions
setTab: (tab: TabType) => void;
setPmSize: (size: number) => void;
setRegAction: (action: string) => void;
runBenchmark: () => Promise<void>;
copyCode: (code: string) => void;
}
interface BenchmarkResult {
name: string;
bun: number;
node: number;
speedup: number;
timestamp: Date;
}
interface HardwareInfo {
cores: number;
memory: number;
platform: string;
arch: string;
}Hook for build configuration management.
interface BuildConfigurationHook {
// State
config: BuildConfiguration;
activeTab: string;
generatedCode: string;
cliCommand: string;
// Actions
updateConfig: (updates: Partial<BuildConfiguration>) => void;
updateCoreOption: (key: keyof CoreOptions, value: any) => void;
updateEnvOption: (key: keyof EnvOptions, value: any) => void;
updateJsxOption: (key: keyof JsxOptions, value: any) => void;
updateOptimization: (key: keyof OptimizationOptions, value: any) => void;
updateOutput: (key: keyof OutputOptions, value: any) => void;
updateAdvanced: (key: keyof AdvancedOptions, value: any) => void;
updateCliOption: (key: keyof CliOptions, value: any) => void;
// Utilities
generateBuildCode: () => string;
generateCliCommand: () => string;
resetConfig: () => void;
}Database testing and infrastructure management.
interface DatabaseHook {
// SQLite
sqliteConnection: SQLiteConnection;
sqliteResults: QueryResult[];
isSqliteConnected: boolean;
// Redis
redisConnection: RedisConnection;
redisResults: RedisResult[];
isRedisConnected: boolean;
// Actions
connectSqlite: (path: string) => Promise<void>;
disconnectSqlite: () => void;
executeSqliteQuery: (query: string) => Promise<QueryResult[]>;
connectRedis: (config: RedisConfig) => Promise<void>;
disconnectRedis: () => void;
executeRedisCommand: (command: string, args: any[]) => Promise<RedisResult>;
}
interface QueryResult {
columns: string[];
rows: any[][];
executionTime: number;
affectedRows?: number;
}Process management and shell operations.
interface ProcessHook {
// Process State
processes: ProcessInfo[];
activeProcess: ProcessInfo | null;
isRunning: boolean;
// Socket State
socketConnections: SocketInfo[];
socketStats: SocketStats;
// Actions
spawnProcess: (command: string, args: string[]) => Promise<ProcessInfo>;
killProcess: (pid: number) => void;
sendProcessSignal: (pid: number, signal: string) => void;
createSocket: (type: 'tcp' | 'udp', config: SocketConfig) => Promise<SocketInfo>;
closeSocket: (id: string) => void;
sendSocketData: (id: string, data: Buffer) => void;
}
interface ProcessInfo {
pid: number;
command: string;
args: string[];
status: 'running' | 'stopped' | 'exited';
cpu: number;
memory: number;
startTime: Date;
}Testing framework management and execution.
interface TestingHook {
// Test State
tests: TestSuite[];
runningTests: TestSuite[];
testResults: TestResult[];
coverage: CoverageReport;
// Configuration
testConfig: TestConfig;
// Actions
runAllTests: () => Promise<void>;
runTestSuite: (suiteId: string) => Promise<void>;
runSingleTest: (testId: string) => Promise<void>;
stopTests: () => void;
updateTestConfig: (config: Partial<TestConfig>) => void;
loadTestFile: (path: string) => Promise<void>;
generateTestReport: (format: 'json' | 'html' | 'xml') => Promise<string>;
}
interface TestResult {
id: string;
name: string;
status: 'passed' | 'failed' | 'skipped';
duration: number;
error?: string;
stack?: string;
}Professional footer with performance metrics and navigation.
import { Footer } from '@bun/performance-arsenal';
function App() {
return (
<div>
<main>{/* Main content */}</main>
<Footer />
</div>
);
}Rotating feature announcements and project statistics.
import { Banner } from '@bun/performance-arsenal';
function App() {
return (
<div>
<Banner />
<main>{/* Main content */}</main>
</div>
);
}Advanced banner with social links and metrics.
import { EnhancedBanner } from '@bun/performance-arsenal';
function App() {
return (
<div>
<EnhancedBanner
showStats={true}
showSocialLinks={true}
/>
</div>
);
}Consistent tab navigation across all arsenals.
import { TabNavigation } from '@bun/performance-arsenal/ui';
const tabs = [
{ id: 'performance', label: 'Performance', icon: 'β‘' },
{ id: 'database', label: 'Database', icon: 'ποΈ' }
];
function MyComponent() {
const [activeTab, setActiveTab] = useState('performance');
return (
<TabNavigation
tabs={tabs}
activeTab={activeTab}
onTabChange={setActiveTab}
/>
);
}Syntax-highlighted code display with copy functionality.
import { CodeBlock } from '@bun/performance-arsenal/ui';
function MyComponent() {
const code = `console.log('Hello, Bun!');`;
return (
<CodeBlock
code={code}
language="javascript"
showCopyButton={true}
onCopy={() => console.log('Copied!')}
/>
);
}Real-time performance metric display.
import { PerformanceMetric } from '@bun/performance-arsenal/ui';
function MyComponent() {
return (
<div>
<PerformanceMetric
label="FPS"
value={60}
unit="fps"
status="good"
/>
<PerformanceMetric
label="Memory"
value={128}
unit="MB"
status="warning"
/>
</div>
);
}Performance tracking and analytics utilities.
import {
trackBenchmark,
trackInteraction,
exportAnalytics,
clearAnalytics
} from '@bun/performance-arsenal/utils/analytics';
// Track benchmark results
trackBenchmark('crypto-sha256', {
inputSize: '1MB',
duration: 45,
throughput: '22.2 MB/s'
});
// Export analytics data
const data = await exportAnalytics();
console.log(JSON.stringify(data, null, 2));Cross-platform clipboard utilities.
import { copyToClipboard } from '@bun/performance-arsenal/utils/copyToClipboard';
// Copy text to clipboard
await copyToClipboard('Hello, World!');
// Copy with callback
copyToClipboard('Code snippet', () => {
console.log('Copied successfully!');
});System hardware profiling.
import { detectHardware } from '@bun/performance-arsenal/utils/hardware';
const hardware = await detectHardware();
console.log({
cores: hardware.cores,
memory: hardware.totalMemory,
platform: hardware.platform,
arch: hardware.arch
});Persistent storage utilities.
import { getStorageItem, setStorageItem } from '@bun/performance-arsenal/utils/storage';
// Store user preferences
setStorageItem('theme', 'dark');
setStorageItem('analytics', true);
// Retrieve stored data
const theme = getStorageItem('theme', 'light');
const analytics = getStorageItem('analytics', false);enum Target {
Browser = 'browser',
Bun = 'bun',
Node = 'node'
}
enum Format {
ESM = 'esm',
CJS = 'cjs',
IIFE = 'iife'
}
enum SourcemapType {
None = 'none',
Linked = 'linked',
Inline = 'inline',
External = 'external'
}class ArsenalError extends Error {
constructor(
message: string,
public code: string,
public details?: any
) {
super(message);
this.name = 'ArsenalError';
}
}
class BenchmarkError extends ArsenalError {
constructor(message: string, public benchmark: string) {
super(message, 'BENCHMARK_ERROR', { benchmark });
}
}
class BuildError extends ArsenalError {
constructor(message: string, public config: BuildConfiguration) {
super(message, 'BUILD_ERROR', { config });
}
}Create custom performance benchmarks:
import { createBenchmark } from '@bun/performance-arsenal';
const customBenchmark = createBenchmark({
name: 'custom-algorithm',
setup: () => {
// Setup test data
return { data: generateTestData() };
},
run: (context) => {
// Run the algorithm
return processAlgorithm(context.data);
},
iterations: 1000
});
// Run the benchmark
const result = await customBenchmark.run();
console.log(`Result: ${result.duration}ms`);Extend Arsenal Lab with custom plugins:
import { registerPlugin } from '@bun/performance-arsenal';
registerPlugin({
name: 'custom-plugin',
version: '1.0.0',
hooks: {
onBenchmarkStart: (benchmark) => {
console.log(`Starting ${benchmark.name}`);
},
onBenchmarkEnd: (result) => {
console.log(`Completed in ${result.duration}ms`);
}
}
});Advanced configuration management:
import { configureArsenal } from '@bun/performance-arsenal';
// Global configuration
configureArsenal({
analytics: {
enabled: true,
retention: '30-days',
endpoint: 'https://analytics.example.com'
},
performance: {
warnings: {
lowFps: 30,
highMemory: 500
}
},
ui: {
theme: 'dark',
animations: true
}
});- New CLI options in BuildConfigurationArsenal
- Enhanced analytics with privacy controls
- Improved error handling and TypeScript support
-
useAnalyticshook renamed tousePerformanceMonitor - Footer component now requires React 18+
- Build configuration validation is stricter
| Document | Description |
|---|---|
| π Wiki Home | Overview and getting started |
| π Analytics Guide | Performance monitoring and metrics |
| ποΈ Database Guide | Database integration patterns |
| π SQL Examples | Query patterns and examples |
- π¬ Discussions - Community conversations
- π Issues - Bug reports and feature requests
- π Full Documentation - Complete documentation hub
Built with β€οΈ for the Bun ecosystem β’ Last updated: October 21, 2025