Compare commits
7 Commits
v0.0.19
...
tasiaiso-h
Author | SHA1 | Date | |
---|---|---|---|
5e72c9caf4
|
|||
71329c5532 | |||
feb4bf9e87 | |||
5d5567e94c | |||
684e6fb9cb | |||
ee21fa6d03
|
|||
7a2974e54f |
1
.husky/pre-commit
Normal file
1
.husky/pre-commit
Normal file
@ -0,0 +1 @@
|
||||
make format || exit 0
|
@ -2,6 +2,7 @@ node_modules
|
||||
src
|
||||
deps
|
||||
.clang-format
|
||||
flake.lock
|
||||
|
||||
# Minified files
|
||||
**/*.min.css
|
||||
|
@ -3,9 +3,9 @@
|
||||
MAKEFLAGS += --warn-undefined-variables
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
VERSION_CODE := 19
|
||||
VERSION_NUMBER := 0.0.19
|
||||
VERSION_NAME := Don't let your loyalty become a burden.
|
||||
VERSION_CODE := 20
|
||||
VERSION_NUMBER := 0.0.20-wip
|
||||
VERSION_NAME := One word all lowercase four words all uppercase.
|
||||
|
||||
SQLITE_URL := https://www.sqlite.org/2024/sqlite-amalgamation-3460000.zip
|
||||
LIBUV_URL := https://dist.libuv.org/dist/v1.48.0/libuv-v1.48.0.tar.gz
|
||||
@ -902,7 +902,7 @@ dist-test: dist
|
||||
@rm -rf tildefriends-$(VERSION_NUMBER)
|
||||
.PHONY: dist-test
|
||||
|
||||
format:
|
||||
format: prettier
|
||||
@clang-format -i $(wildcard src/*.c src/*.h src/*.m)
|
||||
.PHONY: format
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🐌",
|
||||
"previous": "&YhfwSB0+2jmPcHlxOXN73/81H5VEyQ1MaTJmWZbwqHU=.sha256"
|
||||
"previous": "&zRv7YNZBT/NoliiTS7Jn/Q+3przdFZljUl8yPBIpSSE=.sha256"
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
import * as tfrpc from '/static/tfrpc.js';
|
||||
import {html, render} from './lit-all.min.js';
|
||||
import {styles} from './tf-styles.js';
|
||||
|
||||
let g_emojis;
|
||||
|
||||
@ -36,11 +38,6 @@ export async function picker(callback, anchor, author) {
|
||||
div.style.background = '#fff';
|
||||
div.style.border = '1px solid #000';
|
||||
div.style.display = 'block';
|
||||
div.style.position = 'absolute';
|
||||
div.style.minWidth = 'min(16em, 90vw)';
|
||||
div.style.width = 'min(16em, 90vw)';
|
||||
div.style.maxWidth = 'min(16em, 90vw)';
|
||||
div.style.maxHeight = '16em';
|
||||
div.style.overflow = 'scroll';
|
||||
div.style.fontWeight = 'bold';
|
||||
div.style.fontSize = 'xx-large';
|
||||
@ -58,14 +55,6 @@ export async function picker(callback, anchor, author) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
function cleanup() {
|
||||
console.log('emoji cleanup');
|
||||
div.parentElement.removeChild(div);
|
||||
window.removeEventListener('keydown', key_down);
|
||||
console.log('removing click');
|
||||
document.body.removeEventListener('mousedown', cleanup);
|
||||
}
|
||||
|
||||
function key_down(event) {
|
||||
if (event.key == 'Escape') {
|
||||
cleanup();
|
||||
@ -153,13 +142,23 @@ export async function picker(callback, anchor, author) {
|
||||
}
|
||||
refresh();
|
||||
input.oninput = refresh;
|
||||
document.body.appendChild(div);
|
||||
div.style.position = 'fixed';
|
||||
div.style.top = '50%';
|
||||
div.style.left = '50%';
|
||||
div.style.transform = 'translate(-50%, -50%)';
|
||||
let modal = html`
|
||||
<style>
|
||||
${styles}
|
||||
</style>
|
||||
<div class="w3-modal" style="display: block">
|
||||
<div class="w3-modal-content w3-card-4">${div}</div>
|
||||
</div>
|
||||
`;
|
||||
let parent = document.createElement('div');
|
||||
document.body.appendChild(parent);
|
||||
function cleanup() {
|
||||
parent.parentElement.removeChild(parent);
|
||||
window.removeEventListener('keydown', key_down);
|
||||
document.body.removeEventListener('mousedown', cleanup);
|
||||
}
|
||||
render(modal, parent);
|
||||
input.focus();
|
||||
console.log('adding click');
|
||||
document.body.addEventListener('mousedown', cleanup);
|
||||
window.addEventListener('keydown', key_down);
|
||||
}
|
||||
|
@ -15,9 +15,6 @@
|
||||
# - Build again, this time it should work.
|
||||
# - Check the release notes, if there's a new dependency or a change to `GNUMakefile`, this file might need to be changed too.
|
||||
# For more details, contact tasiaiso @ https://tilde.club/~tasiaiso/
|
||||
#
|
||||
# WARNING: currently it is pinned to `47838d5e482cb4aac40190fa0414f08b8cf94d40`. I couldn't get v0.0.18 to work for some reason.
|
||||
# I'll change this in the next release - tasiaiso
|
||||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
lib ? import <nixpkgs/lib>,
|
||||
@ -30,9 +27,8 @@ pkgs.stdenv.mkDerivation rec {
|
||||
domain = "dev.tildefriends.net";
|
||||
owner = "cory";
|
||||
repo = "tildefriends";
|
||||
# rev = "v${version}";
|
||||
rev = "47838d5e482cb4aac40190fa0414f08b8cf94d40";
|
||||
hash = "sha256-mb5KYvWPIqgV64FOaXKHm2ownBJiiSRtdH8+YWiXwvE="; # 47838d5e482cb4aac40190fa0414f08b8cf94d40
|
||||
rev = "v${version}";
|
||||
hash = "sha256-ttqL2wz06Jvn2f6kKIAGpF0nSSle+g4nSlj4jL0D+Fk=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
|
21
package-lock.json
generated
21
package-lock.json
generated
@ -6,12 +6,29 @@
|
||||
"": {
|
||||
"name": "tildefriends",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prettier": "^3.2.5"
|
||||
"devDependencies": {
|
||||
"husky": "9.0.11",
|
||||
"prettier": "3.2.5"
|
||||
}
|
||||
},
|
||||
"node_modules/husky": {
|
||||
"version": "9.0.11",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz",
|
||||
"integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"husky": "bin.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/typicode"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.2.5",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
|
@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "tildefriends",
|
||||
"scripts": {
|
||||
"prettier": "prettier . --check --cache --write"
|
||||
"prettier": "prettier . --check --cache --write",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"author": "Cory McWilliams",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prettier": "^3.2.5"
|
||||
"devDependencies": {
|
||||
"prettier": "3.2.5",
|
||||
"husky": "9.0.11"
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.unprompted.tildefriends"
|
||||
android:versionCode="19"
|
||||
android:versionName="0.0.19">
|
||||
android:versionCode="20"
|
||||
android:versionName="0.0.20-wip">
|
||||
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="34"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<application
|
||||
|
51
src/ssb.c
51
src/ssb.c
@ -344,6 +344,7 @@ typedef struct _tf_ssb_connection_t
|
||||
int ref_count;
|
||||
|
||||
int read_back_pressure;
|
||||
int active_write_count;
|
||||
} tf_ssb_connection_t;
|
||||
|
||||
static JSClassID _connection_class_id;
|
||||
@ -460,9 +461,10 @@ static void _tf_ssb_connection_on_tcp_alloc(uv_handle_t* handle, size_t suggeste
|
||||
|
||||
static void _tf_ssb_connection_on_write(uv_write_t* req, int status)
|
||||
{
|
||||
tf_ssb_connection_t* connection = req->data;
|
||||
tf_ssb_connection_adjust_write_count(connection, -1);
|
||||
if (status)
|
||||
{
|
||||
tf_ssb_connection_t* connection = req->data;
|
||||
char buffer[256];
|
||||
snprintf(buffer, sizeof(buffer), "write failed asynchronously: %s", uv_strerror(status));
|
||||
_tf_ssb_connection_close(connection, buffer);
|
||||
@ -477,9 +479,11 @@ static void _tf_ssb_write(tf_ssb_connection_t* connection, void* data, size_t si
|
||||
uv_write_t* write = tf_malloc(sizeof(uv_write_t) + size);
|
||||
*write = (uv_write_t) { .data = connection };
|
||||
memcpy(write + 1, data, size);
|
||||
tf_ssb_connection_adjust_write_count(connection, 1);
|
||||
int result = uv_write(write, (uv_stream_t*)&connection->tcp, &(uv_buf_t) { .base = (char*)(write + 1), .len = size }, 1, _tf_ssb_connection_on_write);
|
||||
if (result)
|
||||
{
|
||||
tf_ssb_connection_adjust_write_count(connection, -1);
|
||||
_tf_ssb_connection_close(connection, "write failed");
|
||||
tf_free(write);
|
||||
}
|
||||
@ -606,6 +610,19 @@ static void _tf_ssb_connection_box_stream_send(tf_ssb_connection_t* connection,
|
||||
}
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_dispatch_scheduled(tf_ssb_connection_t* connection)
|
||||
{
|
||||
while ((connection->active_write_count == 0 || connection->closing) && connection->scheduled_count && connection->scheduled)
|
||||
{
|
||||
tf_ssb_connection_scheduled_t scheduled = connection->scheduled[0];
|
||||
memmove(connection->scheduled, connection->scheduled + 1, sizeof(tf_ssb_connection_scheduled_t) * (connection->scheduled_count - 1));
|
||||
connection->scheduled_count--;
|
||||
tf_trace_begin(connection->ssb->trace, "scheduled callback");
|
||||
scheduled.callback(connection, scheduled.user_data);
|
||||
tf_trace_end(connection->ssb->trace);
|
||||
}
|
||||
}
|
||||
|
||||
void tf_ssb_connection_schedule_idle(tf_ssb_connection_t* connection, tf_ssb_scheduled_callback_t* callback, void* user_data)
|
||||
{
|
||||
connection->scheduled = tf_resize_vec(connection->scheduled, sizeof(tf_ssb_connection_scheduled_t) * (connection->scheduled_count + 1));
|
||||
@ -613,7 +630,7 @@ void tf_ssb_connection_schedule_idle(tf_ssb_connection_t* connection, tf_ssb_sch
|
||||
.callback = callback,
|
||||
.user_data = user_data,
|
||||
};
|
||||
uv_async_send(&connection->async);
|
||||
_tf_ssb_connection_dispatch_scheduled(connection);
|
||||
}
|
||||
|
||||
static int _request_compare(const void* a, const void* b)
|
||||
@ -1815,24 +1832,6 @@ JSValue tf_ssb_sign_message(tf_ssb_t* ssb, const char* author, const uint8_t* pr
|
||||
return root;
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_dispatch_scheduled(tf_ssb_connection_t* connection)
|
||||
{
|
||||
const int k_scheduled_batch_count = 8;
|
||||
for (int i = 0; i < k_scheduled_batch_count && connection->scheduled_count && connection->scheduled; i++)
|
||||
{
|
||||
tf_ssb_connection_scheduled_t scheduled = connection->scheduled[0];
|
||||
memmove(connection->scheduled, connection->scheduled + 1, sizeof(tf_ssb_connection_scheduled_t) * (connection->scheduled_count - 1));
|
||||
connection->scheduled_count--;
|
||||
tf_trace_begin(connection->ssb->trace, "scheduled callback");
|
||||
scheduled.callback(connection, scheduled.user_data);
|
||||
tf_trace_end(connection->ssb->trace);
|
||||
}
|
||||
if (connection->scheduled_count)
|
||||
{
|
||||
uv_async_send(&connection->async);
|
||||
}
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const char* reason)
|
||||
{
|
||||
tf_ssb_t* ssb = connection->ssb;
|
||||
@ -1841,10 +1840,7 @@ static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const ch
|
||||
{
|
||||
connection->destroy_reason = reason;
|
||||
}
|
||||
while (connection->scheduled_count)
|
||||
{
|
||||
_tf_ssb_connection_dispatch_scheduled(connection);
|
||||
}
|
||||
_tf_ssb_connection_dispatch_scheduled(connection);
|
||||
tf_free(connection->scheduled);
|
||||
connection->scheduled = NULL;
|
||||
while (connection->requests)
|
||||
@ -2613,7 +2609,6 @@ static void _tf_ssb_connection_process_message_async(uv_async_t* async)
|
||||
{
|
||||
uv_async_send(&connection->async);
|
||||
}
|
||||
_tf_ssb_connection_dispatch_scheduled(connection);
|
||||
}
|
||||
|
||||
tf_ssb_connection_t* tf_ssb_connection_create(tf_ssb_t* ssb, const char* host, const struct sockaddr_in* addr, const uint8_t* public_key)
|
||||
@ -4108,3 +4103,9 @@ void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection,
|
||||
_tf_ssb_connection_destroy(connection, "backpressure released");
|
||||
}
|
||||
}
|
||||
|
||||
void tf_ssb_connection_adjust_write_count(tf_ssb_connection_t* connection, int delta)
|
||||
{
|
||||
connection->active_write_count += delta;
|
||||
_tf_ssb_connection_dispatch_scheduled(connection);
|
||||
}
|
||||
|
11
src/ssb.h
11
src/ssb.h
@ -745,7 +745,7 @@ JSValue tf_ssb_connection_requests_to_object(tf_ssb_connection_t* connection);
|
||||
typedef void(tf_ssb_scheduled_callback_t)(tf_ssb_connection_t* connection, void* user_data);
|
||||
|
||||
/**
|
||||
** Schedule work to be run when the server is next idle.
|
||||
** Schedule work to be run when the connection is next idle.
|
||||
** @param connection The owning connection.
|
||||
** @param callback The callback to call.
|
||||
** @param user_data User data to pass to the callback.
|
||||
@ -1005,4 +1005,13 @@ bool tf_ssb_hmacsha256_verify(const char* public_key, const void* payload, size_
|
||||
*/
|
||||
void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection, int delta);
|
||||
|
||||
/**
|
||||
** Adjust write count. Work scheduled by tf_ssb_connection_schedule_idle will
|
||||
** only start when this reaches zero.
|
||||
** @param connection The connection on which to affect backpressure.
|
||||
** @param delta The change in write count. Higher will pause processing
|
||||
** scheduled idle work queue. Lower will resume it.
|
||||
*/
|
||||
void tf_ssb_connection_adjust_write_count(tf_ssb_connection_t* connection, int delta);
|
||||
|
||||
/** @} */
|
||||
|
@ -744,6 +744,7 @@ static void _tf_ssb_connection_send_history_stream_work(tf_ssb_connection_t* con
|
||||
static void _tf_ssb_connection_send_history_stream_after_work(tf_ssb_connection_t* connection, int result, void* user_data)
|
||||
{
|
||||
tf_ssb_connection_send_history_stream_t* request = user_data;
|
||||
tf_ssb_connection_adjust_write_count(connection, -1);
|
||||
if (tf_ssb_connection_is_connected(connection))
|
||||
{
|
||||
for (int i = 0; i < request->out_messages_count; i++)
|
||||
@ -768,6 +769,15 @@ static void _tf_ssb_connection_send_history_stream_after_work(tf_ssb_connection_
|
||||
tf_free(request);
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_send_history_stream_callback(tf_ssb_connection_t* connection, void* user_data)
|
||||
{
|
||||
tf_ssb_connection_adjust_write_count(connection, 1);
|
||||
if (tf_ssb_connection_is_connected(connection))
|
||||
{
|
||||
tf_ssb_connection_run_work(connection, _tf_ssb_connection_send_history_stream_work, _tf_ssb_connection_send_history_stream_after_work, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_send_history_stream(tf_ssb_connection_t* connection, int32_t request_number, const char* author, int64_t sequence, bool keys, bool live)
|
||||
{
|
||||
tf_ssb_connection_send_history_stream_t* async = tf_malloc(sizeof(tf_ssb_connection_send_history_stream_t));
|
||||
@ -778,7 +788,7 @@ static void _tf_ssb_connection_send_history_stream(tf_ssb_connection_t* connecti
|
||||
.live = live,
|
||||
};
|
||||
snprintf(async->author, sizeof(async->author), "%s", author);
|
||||
tf_ssb_connection_run_work(connection, _tf_ssb_connection_send_history_stream_work, _tf_ssb_connection_send_history_stream_after_work, async);
|
||||
tf_ssb_connection_schedule_idle(connection, _tf_ssb_connection_send_history_stream_callback, async);
|
||||
}
|
||||
|
||||
static void _tf_ssb_rpc_createHistoryStream(
|
||||
|
@ -1,2 +1,2 @@
|
||||
#define VERSION_NUMBER "0.0.19"
|
||||
#define VERSION_NAME "Don't let your loyalty become a burden."
|
||||
#define VERSION_NUMBER "0.0.20-wip"
|
||||
#define VERSION_NAME "One word all lowercase four words all uppercase."
|
||||
|
Reference in New Issue
Block a user