Skip to content

Add jetpack javascript engine#3

Merged
predatorx7 merged 4 commits into
mainfrom
add_jetpack_javascriptengine
Aug 15, 2025
Merged

Add jetpack javascript engine#3
predatorx7 merged 4 commits into
mainfrom
add_jetpack_javascriptengine

Conversation

@predatorx7

@predatorx7 predatorx7 commented Aug 11, 2025

Copy link
Copy Markdown
Owner

Description

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Test

Summary by CodeRabbit

  • New Features

    • Android: JavaScript sandbox support with per-engine lifecycle (start/run/dispose) and run-from-file API accessible from Flutter.
    • Dart: Added run-from-file API and platform wiring to call engine operations.
  • Refactor

    • Replaced native QuickJS native build with AndroidX JavaScript Engine dependency and new Android platform integration.
  • Chores

    • Updated test dependency (mockito) and relaxed a Dart analyzer lint rule.
  • Example

    • Modularized example app: structured logging, console UI, URL download, and new runtime/view-model UI components.

@coderabbitai

coderabbitai Bot commented Aug 11, 2025

Copy link
Copy Markdown

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Reviewing files that changed from the base of the PR and between 75d84b3 and dbe40fc.

📒 Files selected for processing (5)
  • packages/javascript/javascript/README.md (1 hunks)
  • packages/javascript/javascript/example/lib/src/model.dart (1 hunks)
  • packages/javascript/javascript/example/pubspec.yaml (1 hunks)
  • packages/javascript/javascript/lib/javascript.dart (1 hunks)
  • packages/javascript/javascript_android/README.md (1 hunks)
 ______________________________________________________
< CUDA: Carrot Utilization for Debugging Acceleration. >
 ------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

Walkthrough

Replaces the QuickJS native integration with AndroidX JavaScriptSandbox: removes QuickJS C/C++ sources, build scripts, tests, and FFI; adds Kotlin platform API and Flutter message-channel wiring; updates Android Gradle to use androidx.javascriptengine; and introduces example app refactors and logging plus minor lint change.

Changes

Cohort / File(s) Summary
Lint config
packages/javascript/javascript_android/analysis_options.yaml
Adds analyzer.errors.constant_identifier_names: ignore.
Android build & deps
packages/javascript/javascript_android/android/build.gradle, packages/javascript/javascript_android/android/src/main/cxx/CMakeLists.txt
Remove externalNativeBuild/CMake config and deleted local CMake file; add implementation "androidx.javascriptengine:javascriptengine:1.0.0"; bump org.mockito:mockito-core to 5.18.0.
Kotlin platform API & glue
.../android/src/main/kotlin/org/reclaimprotocol/javascript_android/Messages.kt, .../JavaScriptAndroid.kt
Add JavaScriptAndroidPlatformApi message-channel wiring, FlutterError, custom codec, and JavaScriptAndroid implementation that manages JavaScriptSandbox, isolates, evaluation, lifecycle, and callbacks.
Flutter plugin lifecycle
.../android/src/main/kotlin/org/reclaimprotocol/javascript_android/JavaScriptPlugin.kt
Make plugin ActivityAware; create/store JavaScriptAndroid on attach; wire/unwire platform API channels; add activity lifecycle forwarding and logging.
Remove QuickJS native stack & tooling
packages/javascript/javascript_android/cxx/*, packages/javascript/javascript_android/cxx/quickjs/** (headers, sources, examples, tools, fuzzers, Makefile, CMake, CI, licenses, tests)
Delete QuickJS sources, headers, FFI bridge (ffi.cpp, ffi.h), build scripts (Makefile, quickjs.cmake, prebuild.sh), tests, examples, documentation, CI workflow, fuzzers, and ancillary files.
Example app — runtime & services removed
packages/javascript/javascript/example/lib/runtime.dart, .../runtime_service.dart, .../json.dart
Remove previous Dart runtime bridge and service implementations and base64/JSON helpers (these were replaced/restructured elsewhere).
Example app — UI & runtime added/modified
packages/javascript/javascript/example/lib/main.dart, .../src/* (new file.dart, model.dart, runtime_service.dart, UI widgets: url_input.dart, command_input.dart, console_output.dart)
Refactor example to new modular runtime service, view model, file download helper, console model/UI widgets, and enable runtime logging; update example pubspec dependencies (add crypto, http, logging).
Public API additions (Dart)
packages/javascript/javascript/lib/impl.dart, packages/javascript/javascript/lib/javascript.dart
Add runJavaScriptFromFileReturningResult(String) method to run JavaScript from a file and return result.
iOS/macOS project updates
packages/javascript/javascript/example/ios/*, packages/javascript/javascript/example/macos/*, workspace files
Integrate CocoaPods references and build phases (Pods xcconfigs, frameworks, embed/check script phases) into Xcode project/workspace files.
Misc files removed
packages/javascript/javascript_android/cxx/quickjs/* (many doc/tests/examples/binaries)
Remove ancillary QuickJS files: docs, README, changelog, version, example modules, microbench, REPL, test harnesses, and release scripts.

Sequence Diagram(s)

sequenceDiagram
  participant Dart as Flutter (Dart)
  participant Chan as BinaryMessenger (BasicMessageChannel)
  participant API as JavaScriptAndroidPlatformApi
  participant Impl as JavaScriptAndroid (Kotlin)
  participant SB as JavaScriptSandbox
  participant ISO as JavaScriptIsolate

  Dart->>Chan: startJavaScriptEngine(id)
  Chan->>API: startJavaScriptEngine(id)
  API->>Impl: startJavaScriptEngine(id, callback)
  Impl->>SB: createConnectedInstanceAsync()
  SB-->>Impl: Future completes (sandbox)
  Impl->>SB: createIsolate(params)
  Impl-->>API: callback(success)

  Dart->>Chan: runJavaScriptReturningResult(id, code)
  Chan->>API: runJavaScriptReturningResult(id, code)
  API->>Impl: runJavaScriptReturningResult(id, code, callback)
  Impl->>ISO: evaluateAsync(code)
  ISO-->>Impl: result / exception
  Impl-->>API: callback(result/error)
  API-->>Chan: reply (wrapped result/error)
  Chan-->>Dart: deliver response

  Dart->>Chan: dispose(id)
  Chan->>API: dispose(id)
  API->>Impl: dispose(id, callback)
  Impl->>ISO: close()
  Impl-->>API: callback(success)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90 minutes

Poem

A rabbit taps keys with delighted cheer,
Out hops the C, in bounds Kotlin here.
Sandboxes bloom, isolates spin,
Messages flutter, results drop in.
Logs now sparkle, tidy and bright — carrots for tests, and engines light. 🥕

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Join our Discord community for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@predatorx7 predatorx7 merged commit 31f6270 into main Aug 15, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant