7 Commits

Author SHA1 Message Date
68590cae33 http: Avoid a potential null dereference.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 30m0s
2025-02-27 11:25:38 -05:00
abf2bbaec2 js: Very minor trimming. 2025-02-27 10:01:59 -05:00
0da7e2722f js: Add a place to start moving imports to C. 2025-02-27 09:58:15 -05:00
60d4b06057 http: Prevent reentering tf_http_destroy. 2025-02-27 08:52:42 -05:00
4c3df34950 build: Let's start work on 0.0.29.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 30m9s
2025-02-26 20:04:17 -05:00
7737e60b52 build: ios => CFBundleVersion=10.
Some checks are pending
Build Tilde Friends / Build-All (push) Waiting to run
2025-02-26 19:44:00 -05:00
71e816bc13 build: nix => 0.0.28. 2025-02-26 19:43:20 -05:00
10 changed files with 73 additions and 27 deletions

View File

@ -16,9 +16,9 @@ MAKEFLAGS += --no-builtin-rules
## LD := Linker. ## LD := Linker.
## ANDROID_SDK := Path to the Android SDK. ## ANDROID_SDK := Path to the Android SDK.
VERSION_CODE := 33 VERSION_CODE := 34
VERSION_CODE_IOS := 9 VERSION_CODE_IOS := 11
VERSION_NUMBER := 0.0.28 VERSION_NUMBER := 0.0.29-wip
VERSION_NAME := This program kills fascists. VERSION_NAME := This program kills fascists.
IPHONEOS_VERSION_MIN=14.0 IPHONEOS_VERSION_MIN=14.0

View File

@ -7,18 +7,17 @@ let kPingInterval = 60 * 1000;
/** /**
* TODOC * TODOC
* @param {*} out
* @param {*} error * @param {*} error
*/ */
function printError(out, error) { function printError(error) {
if (error.stackTrace) { if (error.stackTrace) {
out.print(error.fileName + ':' + error.lineNumber + ': ' + error.message); print(error.fileName + ':' + error.lineNumber + ': ' + error.message);
out.print(error.stackTrace); print(error.stackTrace);
} else { } else {
for (let [k, v] of Object.entries(error)) { for (let [k, v] of Object.entries(error)) {
out.print(k, v); print(k, v);
} }
out.print(error.toString()); print(error.toString());
} }
} }
@ -461,10 +460,10 @@ async function getProcessBlob(blobId, key, options) {
if (process.app) { if (process.app) {
process.app.makeFunction(['error'])(error); process.app.makeFunction(['error'])(error);
} else { } else {
printError({print: print}, error); printError(error);
} }
} catch (e) { } catch (e) {
printError({print: print}, error); printError(error);
} }
}; };
imports.ssb = Object.fromEntries( imports.ssb = Object.fromEntries(
@ -660,6 +659,7 @@ async function getProcessBlob(blobId, key, options) {
); );
return process.sendPermissions(); return process.sendPermissions();
}; };
ssb.registerImports(imports, process);
process.task.setImports(imports); process.task.setImports(imports);
process.task.activate(); process.task.activate();
let source = await ssb.blobGet(blobId); let source = await ssb.blobGet(blobId);
@ -686,7 +686,7 @@ async function getProcessBlob(blobId, key, options) {
); );
} }
} catch (e) { } catch (e) {
printError({print: print}, e); printError(e);
} }
broadcastEvent('onSessionBegin', [getUser(process, process)]); broadcastEvent('onSessionBegin', [getUser(process, process)]);
if (process.app) { if (process.app) {
@ -700,14 +700,10 @@ async function getProcessBlob(blobId, key, options) {
sendStats(); sendStats();
} }
} catch (error) { } catch (error) {
if (process.app) { if (process?.app && process?.task?.onError) {
if (process?.task?.onError) { process.task.onError(error);
process.task.onError(error);
} else {
printError({print: print}, error);
}
} else { } else {
printError({print: print}, error); printError(error);
} }
rejectReady(error); rejectReady(error);
} }

View File

@ -25,14 +25,14 @@
}: }:
pkgs.stdenv.mkDerivation rec { pkgs.stdenv.mkDerivation rec {
pname = "tildefriends"; pname = "tildefriends";
version = "0.0.27.1"; version = "0.0.28";
src = pkgs.fetchFromGitea { src = pkgs.fetchFromGitea {
domain = "dev.tildefriends.net"; domain = "dev.tildefriends.net";
owner = "cory"; owner = "cory";
repo = "tildefriends"; repo = "tildefriends";
rev = "v${version}"; rev = "v${version}";
hash = "sha256-3t1m9ZomQF3DteWyALJWrnCq0EAROEK8shKXh6Ao38c="; hash = "sha256-vcLJCXgIrjC37t9oavK2QMRcMJljghuzKDYxQ4nyTcE=";
fetchSubmodules = true; fetchSubmodules = true;
}; };

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unprompted.tildefriends" package="com.unprompted.tildefriends"
android:versionCode="33" android:versionCode="34"
android:versionName="0.0.28"> android:versionName="0.0.29-wip">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<application <application

19
src/api.js.c Normal file
View File

@ -0,0 +1,19 @@
#include "api.js.h"
#include "log.h"
#include <quickjs.h>
static JSValue _tf_api_register_imports(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
return JS_UNDEFINED;
}
void tf_api_register(JSContext* context)
{
JSValue global = JS_GetGlobalObject(context);
JSValue ssb = JS_GetPropertyStr(context, global, "ssb");
JS_SetPropertyStr(context, ssb, "registerImports", JS_NewCFunction(context, _tf_api_register_imports, "registerImports", 2));
JS_FreeValue(context, ssb);
JS_FreeValue(context, global);
}

18
src/api.js.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
/**
** \defgroup api_js JS API
** Functions that are ultimately exposed to apps.
** @{
*/
/** A JS context. */
typedef struct JSContext JSContext;
/**
** Register JS API functions.
** @param context The JS context.
*/
void tf_api_register(JSContext* context);
/** @} */

View File

@ -84,6 +84,7 @@ typedef struct _tf_http_listener_t
typedef struct _tf_http_t typedef struct _tf_http_t
{ {
bool is_shutting_down; bool is_shutting_down;
bool is_in_destroy;
tf_http_listener_t** listeners; tf_http_listener_t** listeners;
int listeners_count; int listeners_count;
@ -395,7 +396,7 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
if (fin) if (fin)
{ {
if (connection->request->on_message) if (connection->request && connection->request->on_message)
{ {
tf_trace_begin(connection->http->trace, connection->trace_name ? connection->trace_name : "websocket"); tf_trace_begin(connection->http->trace, connection->trace_name ? connection->trace_name : "websocket");
connection->request->on_message(connection->request, connection->fragment_length ? connection->fragment_op_code : op_code, connection->request->on_message(connection->request, connection->fragment_length ? connection->fragment_op_code : op_code,
@ -786,7 +787,13 @@ static void _http_free_listener_on_close(uv_handle_t* handle)
void tf_http_destroy(tf_http_t* http) void tf_http_destroy(tf_http_t* http)
{ {
if (http->is_in_destroy)
{
return;
}
http->is_shutting_down = true; http->is_shutting_down = true;
http->is_in_destroy = true;
for (int i = 0; i < http->connections_count; i++) for (int i = 0; i < http->connections_count; i++)
{ {
@ -845,6 +852,10 @@ void tf_http_destroy(tf_http_t* http)
tf_free(http); tf_free(http);
} }
else
{
http->is_in_destroy = false;
}
} }
const char* tf_http_status_text(int status) const char* tf_http_status_text(int status)

View File

@ -13,13 +13,13 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.0.28</string> <string>0.0.29</string>
<key>CFBundleSupportedPlatforms</key> <key>CFBundleSupportedPlatforms</key>
<array> <array>
<string>iPhoneOS</string> <string>iPhoneOS</string>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>9</string> <string>11</string>
<key>DTPlatformName</key> <key>DTPlatformName</key>
<string>iphoneos</string> <string>iphoneos</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -1,5 +1,6 @@
#include "task.h" #include "task.h"
#include "api.js.h"
#include "bcrypt.js.h" #include "bcrypt.js.h"
#include "database.js.h" #include "database.js.h"
#include "file.js.h" #include "file.js.h"
@ -1697,6 +1698,7 @@ void tf_task_activate(tf_task_t* task)
task->_ssb = tf_ssb_create(&task->_loop, task->_context, task->_db_path, task->_network_key); task->_ssb = tf_ssb_create(&task->_loop, task->_context, task->_db_path, task->_network_key);
tf_ssb_set_trace(task->_ssb, task->_trace); tf_ssb_set_trace(task->_ssb, task->_trace);
tf_ssb_register(context, task->_ssb); tf_ssb_register(context, task->_ssb);
tf_api_register(context);
tf_ssb_set_hitch_callback(task->_ssb, _tf_task_record_hitch, task); tf_ssb_set_hitch_callback(task->_ssb, _tf_task_record_hitch, task);
if (task->_args) if (task->_args)

View File

@ -1,2 +1,2 @@
#define VERSION_NUMBER "0.0.28" #define VERSION_NUMBER "0.0.29-wip"
#define VERSION_NAME "This program kills fascists." #define VERSION_NAME "This program kills fascists."