This is the main guide for WebF development. Detailed content is organized into folder-specific guides.
| Guide | Description |
|---|---|
| C++ Development | C++ bridge development, build commands, FFI patterns, iOS troubleshooting |
| Dart/Flutter Development | Dart code, widget testing, Flutter patterns, render object system |
| Integration Testing | Writing and running integration tests, snapshot testing |
| CLI Development | WebF CLI code generator for React/Vue bindings |
| Scripts | Build scripts and utility tools |
| Architecture | WebF architecture pipeline and design patterns |
| Memory & Performance | Performance optimization, caching, memory management |
bridge/: C++ code providing JavaScript runtime and DOM API implementationswebf/: Dart code implementing DOM/CSS and layout/painting on Flutterintegration_tests/: Integration tests and visual regression testscli/: WebF CLI for generating React/Vue bindingsscripts/: Build and utility scripts
| Task | Command |
|---|---|
| Build C++ (macOS) | npm run build:bridge:macos |
| Build C++ (Android, static STL) | npm run build:bridge:android |
| Build C++ (Android, dynamic STL) | npm run build:bridge:android:dynamic-stl |
| Build C++ (Android, separate libs) | npm run build:bridge:android:separate |
| Build C++ (all platforms) | npm run build:bridge:all |
| Run all tests | npm test |
| Run integration tests | cd integration_tests && npm run integration |
| Run Dart tests | cd webf && flutter test |
| Lint code | npm run lint |
| Format code | npm run format |
| Clean build | npm run build:clean |
- Use
Grepfor specific function/class names - Use
Globfor file patterns - Batch related searches in parallel
- For cross-language features, search both C++ (.cc/.h) and Dart (.dart) files
- Function usage:
FunctionName\( - Class definition:
class ClassName - FFI exports:
WEBF_EXPORT_C
WebF supports two modes for bundling C++ libraries in Android builds:
npm run build:bridge:android # Bundled QuickJS + static STL (default)
npm run build:bridge:android:release # Bundled QuickJS + static STL (release)
npm run build:bridge:android:dynamic-stl # Bundled QuickJS + dynamic STLOutputs:
libwebf.so- Contains WebF + QuickJS + STL code bundled together (default)libc++_shared.so- Android STL runtime (only with --dynamic-stl flag)
Advantages:
- Maximum simplicity - Single
libwebf.sofile only (no STL dependencies) - Smallest deployment - No separate
libc++_shared.sorequired - Better optimization - Cross-library inlining including STL
- Reduced app size - No duplicate symbols, smaller total size
- Easier debugging - Everything in one library
npm run build:bridge:android:separate # Separate QuickJS library
WEBF_SEPARATE_QUICKJS=true npm run build:bridge:androidOutputs:
libwebf.so- WebF core librarylibquickjs.so- JavaScript engine (separate)libc++_shared.so- Android STL runtime
Use Cases:
- When you need to share QuickJS with other libraries
- For debugging library boundaries
- Advanced library management scenarios
| Flag/Environment | Description | Default |
|---|---|---|
--static-quickjs |
Bundle QuickJS into webf library | Android: true, Others: false |
--dynamic-stl |
Use dynamic C++ standard library (Android) | false |
WEBF_SEPARATE_QUICKJS=true |
Build QuickJS as separate library | false |
ANDROID_STL=c++_shared |
Override default STL type | c++_static |
--enable-log |
Enable debug logging | false |
| STL Type | Description | Libraries Required |
|---|---|---|
c++_static (default) |
Static C++ standard library | libwebf.so only |
c++_shared |
Dynamic C++ standard library | libwebf.so + libc++_shared.so |
system |
System C++ library (deprecated) | libwebf.so only |
- Always free allocated memory in Dart FFI
- Use
malloc.free()fortoNativeUtf8()allocations - Track pointer ownership in callbacks
- Document memory ownership clearly
- Use RAII patterns in C++ where possible
PostToJs: Execute on JS threadPostToDart: Return results to Dart isolatePostToJsSync: Synchronous execution (avoid when possible)
- Unit Tests: See folder-specific guides
- Integration Tests: See Integration Development Guide
- Flutter Widget Tests: See Dart Development Guide
# All tests
npm test
# Specific integration test
cd integration_tests && npm run integration -- specs/css/css-display/display.ts
# Flutter tests
cd webf && flutter test
# Bridge unit tests
node scripts/run_bridge_unit_test.jsThe CLI generates type-safe bindings between Flutter/Dart and JavaScript frameworks.
# Basic usage
webf codegen my-typings --flutter-package-src=../webf_package
# With auto-publish
webf codegen --flutter-package-src=../webf_package --publish-to-npm
# Custom registry
webf codegen --flutter-package-src=../webf_package --publish-to-npm --npm-registry=https://custom.registry.com/WebF Enterprise is a closed-source product requiring subscription:
dependencies:
webf: ^0.23.10 # Enterprise version available on pub.devThe MCP server provides dependency graph analysis:
- 8,244+ nodes across multiple languages
- Dependency analysis and impact assessment
- Code quality metrics
- Cross-language FFI analysis
- Architecture validation
# Find a class
mcp__webf__get_node_by_name(name="WebFController")
# Analyze dependencies
mcp__webf__get_dependencies(node_name="RenderStyle", max_depth=2)
# Find code smells
mcp__webf__analyze_code_smells(god_class_threshold=20)- Clarify that WebF builds Flutter apps, not web apps
- Provide complete, runnable examples
- Include WebFControllerManager setup in examples
- Structure information hierarchically
- Test all code examples
- Do what has been asked; nothing more, nothing less
- NEVER create files unless absolutely necessary
- ALWAYS prefer editing existing files
- Only create documentation when explicitly requested