Skip to content

Commit 7f78b6b

Browse files
committed
🦄 refactor: Convert version change scripts to typescript
1 parent f6e468e commit 7f78b6b

File tree

6 files changed

+656
-14
lines changed

6 files changed

+656
-14
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,8 @@ target
8282
# JNI
8383

8484
cpp/build*
85+
86+
# ------------------------------------------------------------------------------
87+
# Claude AI
88+
89+
.claude

CLAUDE.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@ Javet (Java + V8) is a Java library that embeds Node.js and V8 JavaScript engine
1010

1111
### Core Components
1212

13-
- **V8Host**: Main entry point for creating V8/Node.js runtimes. Handles runtime lifecycle management and native library loading via `JavetLibLoader`.
14-
- **V8Runtime/NodeRuntime**: The primary runtime interfaces. `NodeRuntime` extends `V8Runtime` with Node.js-specific functionality like `require()` support.
13+
- **V8Host**: Main entry point for creating V8/Node.js runtimes. Handles runtime lifecycle management and native library loading via `JavetLibLoader`. Manages a daemon for runtime guards and statistics futures.
14+
- **V8Runtime/NodeRuntime**: The primary runtime interfaces. `NodeRuntime` extends `V8Runtime` with Node.js-specific functionality like `require()` support. Represents a V8 isolate with a single context (Javet simplifies V8's multi-context model to 1 runtime = 1 isolate = 1 context).
1515
- **Interop Layer**: Located in `src/main/java/com/caoccao/javet/interop/`, handles Java-JavaScript value conversion and binding.
1616
- **Native Layer**: C++ JNI code in `cpp/jni/` directory bridges Java and the underlying V8/Node.js engines.
17+
- **Engine Pool**: `JavetEnginePool` in `interop/engine/` provides pooling for expensive runtime creation. Use in production for performance.
18+
- **Converters**: Located in `interop/converters/`, handle type conversion between Java and JavaScript (`JavetObjectConverter`, `JavetPrimitiveConverter`, `JavetProxyConverter`, `JavetBridgeConverter`).
1719

1820
### Key Packages
1921

20-
- `com.caoccao.javet.annotations`: Annotations for V8 binding (@V8Function, @V8Property, etc.)
22+
- `com.caoccao.javet.annotations`: Annotations for V8 binding (@V8Function, @V8Property, @V8Getter, @V8Setter, etc.)
2123
- `com.caoccao.javet.values`: V8 value types (V8ValueObject, V8ValueFunction, etc.)
22-
- `com.caoccao.javet.interception`: Interceptors for debugging and logging
24+
- `com.caoccao.javet.interception`: Interceptors for debugging and logging (`JavetStandardConsoleInterceptor`, `JavetJVMInterceptor`)
2325
- `com.caoccao.javet.exceptions`: Javet-specific exception hierarchy
2426
- `com.caoccao.javet.node.modules`: Node.js module implementations
27+
- `com.caoccao.javet.interop.binding`: Binding system for proxying Java objects to JavaScript
28+
- `com.caoccao.javet.interop.executors`: Executors for running scripts (V8StringExecutor, V8FileExecutor, V8PathExecutor)
2529

2630
### Multi-Platform Support
2731

@@ -36,18 +40,29 @@ The project supports multiple architectures via separate native library artifact
3640
### Building
3741
```bash
3842
./gradlew build # Build entire project
39-
./gradlew jar # Build main JAR
40-
./gradlew javadocJar # Build Javadoc JAR
41-
./gradlew sourcesJar # Build sources JAR
43+
./gradlew jar # Build main JAR
44+
./gradlew javadocJar # Build Javadoc JAR
45+
./gradlew sourcesJar # Build sources JAR
46+
./gradlew clean # Clean build directory
4247
```
4348

4449
### Testing
4550
```bash
4651
./gradlew test # Run standard tests (excludes performance tests)
47-
./gradlew performanceTest # Run performance tests only
52+
./gradlew performanceTest # Run performance tests only (tagged with @Tag("performance"))
4853
./gradlew check # Run all verification tasks
4954
```
5055

56+
To run a single test class:
57+
```bash
58+
./gradlew test --tests "com.caoccao.javet.exceptions.TestJavetError"
59+
```
60+
61+
To run a single test method:
62+
```bash
63+
./gradlew test --tests "com.caoccao.javet.exceptions.TestJavetError.testErrorType"
64+
```
65+
5166
### Native Development
5267
```bash
5368
./gradlew buildJNIHeaders # Generate JNI headers for C++ development
@@ -67,21 +82,40 @@ The project supports multiple architectures via separate native library artifact
6782
2. Test code follows standard Maven structure in `src/test/java/`
6883
3. Use existing patterns for V8 value handling and exception management
6984
4. Follow the annotation-based binding system for Java-JavaScript interop
85+
5. All tests extend `BaseTestJavet` or `BaseTestJavetRuntime` which sets up V8 flags and provides common test utilities
7086

71-
### Native Development
87+
### Native Development
7288
1. JNI headers are auto-generated via `buildJNIHeaders` task
7389
2. C++ source is in `cpp/jni/` directory
7490
3. Native libraries are platform-specific and loaded dynamically
91+
4. The native interfaces are `IV8Native` (implemented by `V8Native`) and `INodeNative` (implemented by `NodeNative`)
7592

7693
### Testing Strategy
7794
- Standard unit tests exclude performance tests by default
78-
- Performance tests are tagged and run separately
95+
- Performance tests are tagged with `@Tag("performance")` and run separately via `performanceTest` task
7996
- Tests require platform-specific native libraries to be available
97+
- Base test classes provide setup: `BaseTestJavet`, `BaseTestJavetPool`, `BaseTestJavetRuntime`
8098

8199
## Important Notes
82100

101+
### Resource Management
83102
- The project uses JNI extensively - be careful with native resource management
84-
- V8 contexts and values must be properly closed to prevent memory leaks
85-
- Runtime creation is expensive - use pooling for production scenarios
86-
- Different runtime types (V8 vs Node.js) have different capabilities and APIs
87-
- Platform-specific native dependencies are required for running tests and applications
103+
- V8 values and runtimes implement `IJavetClosable` and must be properly closed to prevent memory leaks
104+
- Use try-with-resources pattern for V8 values and runtimes
105+
- Runtime creation is expensive - use `JavetEnginePool` for production scenarios
106+
107+
### Runtime Types
108+
- **V8 Mode**: Standalone V8 engine without Node.js APIs
109+
- **Node Mode**: Full Node.js with `require()`, built-in modules, and V8 engine
110+
- Different runtime types have different capabilities - choose based on your needs
111+
- Switch between modes using `JSRuntimeType.V8` or `JSRuntimeType.Node` when creating runtimes
112+
113+
### Type Conversion
114+
- Javet provides multiple converter strategies: `JavetObjectConverter` (default), `JavetPrimitiveConverter`, `JavetProxyConverter`, `JavetBridgeConverter`
115+
- Converters handle automatic type mapping between Java and JavaScript
116+
- Custom converters can be implemented via `IJavetConverter`
117+
118+
### Platform Dependencies
119+
- Platform-specific native dependencies are required for running tests and applications
120+
- Native libraries must match the OS and architecture (x86_64, arm64, etc.)
121+
- Libraries are loaded via `JavetLibLoader` at runtime

0 commit comments

Comments
 (0)