2021-01-02 13:10:00 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "quickjs.h"
|
|
|
|
|
|
|
|
typedef struct uv_loop_s uv_loop_t;
|
|
|
|
typedef struct uv_timer_s uv_timer_t;
|
|
|
|
|
|
|
|
typedef int taskid_t;
|
|
|
|
typedef int promiseid_t;
|
|
|
|
typedef int exportid_t;
|
|
|
|
typedef struct _tf_taskstub_t tf_taskstub_t;
|
|
|
|
typedef struct _tf_task_t tf_task_t;
|
2021-12-27 15:49:07 -05:00
|
|
|
typedef struct _tf_trace_t tf_trace_t;
|
2022-01-17 17:00:42 -05:00
|
|
|
typedef struct _tf_ssb_t tf_ssb_t;
|
2021-01-02 13:10:00 -05:00
|
|
|
|
|
|
|
static const taskid_t k_task_parent_id = 0;
|
|
|
|
|
2024-02-15 18:35:01 -05:00
|
|
|
typedef enum _tf_task_message_t
|
|
|
|
{
|
2021-01-02 13:10:00 -05:00
|
|
|
kResolvePromise,
|
|
|
|
kRejectPromise,
|
|
|
|
kInvokeExport,
|
|
|
|
kReleaseExport,
|
|
|
|
kReleaseImport,
|
|
|
|
kActivate,
|
|
|
|
kExecute,
|
|
|
|
kKill,
|
|
|
|
kSetImports,
|
|
|
|
kGetExports,
|
|
|
|
kLoadFile,
|
|
|
|
kTaskError,
|
2022-01-02 13:17:58 -05:00
|
|
|
kTaskTrace,
|
2022-02-13 17:39:22 -05:00
|
|
|
kPrint,
|
2021-01-02 13:10:00 -05:00
|
|
|
} tf_task_message_t;
|
|
|
|
|
|
|
|
tf_task_t* tf_task_create();
|
2023-10-15 13:33:36 -04:00
|
|
|
void tf_task_configure_from_fd(tf_task_t* task, int fd);
|
2021-01-02 13:10:00 -05:00
|
|
|
void tf_task_set_ssb_port(tf_task_t* task, int port);
|
|
|
|
void tf_task_set_http_port(tf_task_t* task, int port);
|
|
|
|
void tf_task_set_https_port(tf_task_t* task, int port);
|
|
|
|
void tf_task_set_db_path(tf_task_t* task, const char* path);
|
2023-03-08 18:59:11 -05:00
|
|
|
void tf_task_set_zip_path(tf_task_t* task, const char* path);
|
2023-03-08 20:03:35 -05:00
|
|
|
const char* tf_task_get_zip_path(tf_task_t* task);
|
2021-12-01 18:29:53 -05:00
|
|
|
void tf_task_set_args(tf_task_t* task, const char* args);
|
2023-10-15 13:33:36 -04:00
|
|
|
bool tf_task_get_one_proc(tf_task_t* task);
|
|
|
|
void tf_task_set_one_proc(tf_task_t* task, bool one_proc);
|
2021-01-02 13:10:00 -05:00
|
|
|
void tf_task_activate(tf_task_t* task);
|
|
|
|
void tf_task_run(tf_task_t* task);
|
|
|
|
int tf_task_execute(tf_task_t* task, const char* file);
|
|
|
|
void tf_task_set_trusted(tf_task_t* task, bool trusted);
|
|
|
|
JSContext* tf_task_get_context(tf_task_t* task);
|
|
|
|
void tf_task_destroy(tf_task_t* task);
|
|
|
|
exportid_t tf_task_export_function(tf_task_t* task, tf_taskstub_t* to, JSValue function);
|
|
|
|
JSValue tf_task_add_import(tf_task_t* task, taskid_t stub_id, exportid_t export_id);
|
|
|
|
uv_loop_t* tf_task_get_loop(tf_task_t* task);
|
|
|
|
tf_task_t* tf_task_get(JSContext* context);
|
2021-12-27 15:49:07 -05:00
|
|
|
tf_trace_t* tf_task_get_trace(tf_task_t* task);
|
2022-01-17 17:00:42 -05:00
|
|
|
tf_ssb_t* tf_task_get_ssb(tf_task_t* task);
|
2021-11-03 18:15:46 -04:00
|
|
|
const char* tf_task_get_name(tf_task_t* task);
|
2022-02-13 17:39:22 -05:00
|
|
|
void tf_task_print(tf_task_t* task, int argc, JSValueConst* argv);
|
2021-01-02 13:10:00 -05:00
|
|
|
|
2022-01-13 22:05:37 -05:00
|
|
|
JSValue tf_task_allocate_promise(tf_task_t* task, promiseid_t* out_promise);
|
2021-01-02 13:10:00 -05:00
|
|
|
void tf_task_reject_promise(tf_task_t* task, promiseid_t promise, JSValue error);
|
|
|
|
void tf_task_resolve_promise(tf_task_t* task, promiseid_t promise, JSValue result);
|
|
|
|
void tf_task_send_promise_message(tf_task_t* from, tf_taskstub_t* to, tf_task_message_t type, promiseid_t promise, JSValue payload);
|
|
|
|
|
|
|
|
void tf_task_on_receive_packet(int packetType, const char* begin, size_t length, void* userData);
|
|
|
|
taskid_t tf_task_allocate_task_id(tf_task_t* task, tf_taskstub_t* stub);
|
|
|
|
void tf_task_remove_child(tf_task_t* task, tf_taskstub_t* child);
|
|
|
|
|
|
|
|
void tf_task_report_error(tf_task_t* task, JSValue error);
|
|
|
|
|
2024-02-15 18:35:01 -05:00
|
|
|
JSValue tf_try_get_typed_array_buffer(JSContext* ctx, JSValueConst obj, size_t* pbyte_offset, size_t* pbyte_length, size_t* pbytes_per_element);
|
|
|
|
uint8_t* tf_try_get_array_buffer(JSContext* ctx, size_t* psize, JSValueConst obj);
|
2021-11-03 18:28:25 -04:00
|
|
|
|
2022-07-26 20:27:10 -04:00
|
|
|
bool tf_task_send_error_to_parent(tf_task_t* task, JSValue error);
|
2024-01-02 18:26:42 -05:00
|
|
|
|
|
|
|
char* tf_task_get_disconnections(tf_task_t* task);
|
|
|
|
char* tf_task_get_debug(tf_task_t* task);
|
|
|
|
char* tf_task_get_hitches(tf_task_t* task);
|