mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
feat: add JavaScript scripting foundation
Introduces a JavaScript setup script that defines the `ad` helper object. This `ad` object exposes APIs for manipulating request data, accessing response details, and managing environment variables within scripts. Adds an `evaluate` function to execute JS code using the `flutter_js` runtime and log results or errors. This establishes the core infrastructure for pre-request and post-response scripting.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_js/flutter_js.dart';
|
||||
|
||||
late JavascriptRuntime jsRuntime;
|
||||
@@ -9,3 +12,12 @@ void initializeJsRuntime() {
|
||||
void disposeJsRuntime() {
|
||||
jsRuntime.dispose();
|
||||
}
|
||||
|
||||
void evaluate(String code) {
|
||||
try {
|
||||
JsEvalResult jsResult = jsRuntime.evaluate(code);
|
||||
log(jsResult.stringResult);
|
||||
} on PlatformException catch (e) {
|
||||
log('ERROR: ${e.details}');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user