mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
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.
24 lines
467 B
Dart
24 lines
467 B
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_js/flutter_js.dart';
|
|
|
|
late JavascriptRuntime jsRuntime;
|
|
|
|
void initializeJsRuntime() {
|
|
jsRuntime = getJavascriptRuntime();
|
|
}
|
|
|
|
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}');
|
|
}
|
|
}
|