Compare commits
145 Commits
d814f7ee77
...
v0.0.30
Author | SHA1 | Date | |
---|---|---|---|
ddfa84f040 | |||
6b3a6ec7c1 | |||
4d037c02bf | |||
deaeab10d8 | |||
2a5375b1e7 | |||
e7a03e3283 | |||
efb3a12dcc | |||
3830d695d7 | |||
f36620927b | |||
5423cbd628 | |||
abde709e54 | |||
27f2d319ab | |||
66234b14bc | |||
6a9167e565 | |||
3c60f8ca06 | |||
c26bf5c112 | |||
41cbde934a | |||
946941d95e | |||
50f0104239 | |||
40fa7edadf | |||
d6926569c6 | |||
a8bba324ca | |||
5bba5776b3 | |||
8104f6f228 | |||
3f4738e593 | |||
1516e17f5d | |||
676d2702b7 | |||
5d39548964 | |||
67d458bd38 | |||
d9684c7d62 | |||
5a818d2119 | |||
6f96d4ce65 | |||
f72395756a | |||
38d746b310 | |||
f7270987ea | |||
6f565c0f0a | |||
7f252e79b6 | |||
ba2bb17638 | |||
bc7c658293 | |||
4d84e69bb5 | |||
03fac74908 | |||
5252ff1ecf | |||
20100d3fd4 | |||
dd3b2656ad | |||
657f25e22b | |||
8be354fc49 | |||
e574758340 | |||
40cf519492 | |||
0e4fda54e9 | |||
868f91e1ef | |||
b9000c154f | |||
894c72a82f | |||
c128cfc25c | |||
36c88b463c | |||
8a66e74074 | |||
ea60b165da | |||
1011e0026b | |||
9462521287 | |||
576022c41a | |||
70c38b7ea8 | |||
36370f2dea | |||
db9bf7f7bd | |||
fa7aef0c37 | |||
b135ea17f6 | |||
4b1643bc47 | |||
240a8ce9c7 | |||
8928e8722b | |||
d692734e55 | |||
50197198b4 | |||
1ee1107c93 | |||
cf90533b6c | |||
f0211f621e | |||
d9693af89b | |||
13722232fb | |||
0bcb033349 | |||
e92c439724 | |||
7f34b585d3 | |||
d7e9fd918a | |||
9899c0c5e2 | |||
c50de0b0f0 | |||
bb7d2d7ae0 | |||
862d172ca8 | |||
3671051d0e | |||
223e20cbbc | |||
9af4312561 | |||
934e40240e | |||
edb1980387 | |||
bb7b04013f | |||
26a3007268 | |||
5de2b09596 | |||
3660577a23 | |||
98b4c7cf04 | |||
427a7b8d25 | |||
67b84830cd | |||
973cd53266 | |||
1afdbe6932 | |||
942f582329 | |||
951a80389a | |||
b7ecfc9925 | |||
59e389d793 | |||
2ec047cc00 | |||
ee33f54745 | |||
7a79534ca8 | |||
a74a9fc821 | |||
e2c388b9db | |||
0f573ce09e | |||
bc70e41b7c | |||
f500e14aa3 | |||
8b47938238 | |||
8912212d8e | |||
6a346bf940 | |||
b5bdae4611 | |||
6590da5793 | |||
eb2b426ec7 | |||
4864a0411f | |||
68590cae33 | |||
abf2bbaec2 | |||
0da7e2722f | |||
60d4b06057 | |||
4c3df34950 | |||
7737e60b52 | |||
71e816bc13 | |||
c74f90ef04 | |||
26cb7e5a17 | |||
2bad6672d8 | |||
71c4011526 | |||
5e81078f59 | |||
31b78e74df | |||
2ff689aab0 | |||
0a6f0ed3f7 | |||
bfec46673d | |||
3a16614c72 | |||
9c9efb845c | |||
6192f1b94d | |||
ce451b2449 | |||
8534e16469 | |||
f6cc6f2eae | |||
0904425221 | |||
a729886522 | |||
e5dfedc7d1 | |||
f02423d084 | |||
8f4b6e83eb | |||
3029919553 | |||
ac67db0591 | |||
1e08838f5b |
1
.gitignore
vendored
@ -7,6 +7,7 @@ deps/openssl/
|
||||
dist/
|
||||
.flatpak-builder
|
||||
.keys
|
||||
**/.DS_Store
|
||||
logs/
|
||||
**/node_modules
|
||||
out
|
||||
|
12
Doxyfile
@ -943,7 +943,9 @@ WARN_LOGFILE =
|
||||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = README.md docs/ src/
|
||||
INPUT = README.md \
|
||||
docs/ \
|
||||
src/
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@ -1680,7 +1682,7 @@ DISABLE_INDEX = NO
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
GENERATE_TREEVIEW = NO
|
||||
GENERATE_TREEVIEW = YES
|
||||
|
||||
# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the
|
||||
# FULL_SIDEBAR option determines if the side bar is limited to only the treeview
|
||||
@ -2268,7 +2270,7 @@ GENERATE_AUTOGEN_DEF = NO
|
||||
# database with symbols found by doxygen stored in tables.
|
||||
# The default value is: NO.
|
||||
|
||||
GENERATE_SQLITE3 = NO
|
||||
#GENERATE_SQLITE3 = NO
|
||||
|
||||
# The SQLITE3_OUTPUT tag is used to specify where the Sqlite3 database will be
|
||||
# put. If a relative path is entered the value of OUTPUT_DIRECTORY will be put
|
||||
@ -2276,7 +2278,7 @@ GENERATE_SQLITE3 = NO
|
||||
# The default directory is: sqlite3.
|
||||
# This tag requires that the tag GENERATE_SQLITE3 is set to YES.
|
||||
|
||||
SQLITE3_OUTPUT = sqlite3
|
||||
#SQLITE3_OUTPUT = sqlite3
|
||||
|
||||
# The SQLITE3_OVERWRITE_DB tag is set to YES, the existing doxygen_sqlite3.db
|
||||
# database file will be recreated with each doxygen run. If set to NO, doxygen
|
||||
@ -2284,7 +2286,7 @@ SQLITE3_OUTPUT = sqlite3
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag GENERATE_SQLITE3 is set to YES.
|
||||
|
||||
SQLITE3_RECREATE_DB = YES
|
||||
#SQLITE3_RECREATE_DB = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the Perl module output
|
||||
|
70
GNUmakefile
@ -16,11 +16,14 @@ MAKEFLAGS += --no-builtin-rules
|
||||
## LD := Linker.
|
||||
## ANDROID_SDK := Path to the Android SDK.
|
||||
|
||||
VERSION_CODE := 33
|
||||
VERSION_NUMBER := 0.0.28-wip
|
||||
VERSION_CODE := 35
|
||||
VERSION_CODE_IOS := 12
|
||||
VERSION_NUMBER := 0.0.30
|
||||
VERSION_NAME := This program kills fascists.
|
||||
|
||||
SQLITE_URL := https://www.sqlite.org/2025/sqlite-amalgamation-3490000.zip
|
||||
IPHONEOS_VERSION_MIN=14.0
|
||||
|
||||
SQLITE_URL := https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip
|
||||
BUNDLETOOL_URL := https://github.com/google/bundletool/releases/download/1.17.0/bundletool-all-1.17.0.jar
|
||||
APPIMAGETOOL_URL := https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||
APPIMAGETOOL_MD5 := e989fadfc4d685fd3d6aeeb9b525d74d out/appimagetool
|
||||
@ -42,6 +45,10 @@ export TZ=UTC
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
BUILD_TYPES := debug release iosdebug iosrelease iossimdebug iossimrelease
|
||||
HAVE_ANDROID = 0
|
||||
HAVE_LINUX_IOS = 0
|
||||
HAVE_LINUX_MACOS = 0
|
||||
HAVE_WIN = 0
|
||||
else ifeq ($(UNAME_S),Linux)
|
||||
BUILD_TYPES := debug release
|
||||
HAVE_ANDROID = $(if $(shell which $(ANDROID_SDK)/platform-tools/adb),1)
|
||||
@ -59,6 +66,10 @@ LDFLAGS += \
|
||||
-lnetwork \
|
||||
-Wno-stringop-overflow
|
||||
USE_SYSTEM_SSL := 1
|
||||
HAVE_ANDROID = 0
|
||||
HAVE_LINUX_IOS = 0
|
||||
HAVE_LINUX_MACOS = 0
|
||||
HAVE_WIN = 0
|
||||
else ifeq ($(UNAME_S),OpenBSD)
|
||||
BUILD_TYPES := debug release
|
||||
CFLAGS += \
|
||||
@ -302,8 +313,8 @@ $(ANDROID_X86_64_TARGETS): LDFLAGS += -Lout/openssl/android/x86_64/usr/local/lib
|
||||
$(NONMACOS_TARGETS): CFLAGS += -Wno-cast-function-type
|
||||
$(MACOS_TARGETS): LDFLAGS += -Wl,-dead_strip
|
||||
$(NONMACOS_TARGETS): LDFLAGS += -Wl,--gc-sections -Wl,--as-needed
|
||||
$(IOS_TARGETS): CFLAGS += -miphoneos-version-min=9.0
|
||||
$(IOS_TARGETS): LDFLAGS += -miphoneos-version-min=9.0
|
||||
$(IOS_TARGETS): CFLAGS += -miphoneos-version-min=$(IPHONEOS_VERSION_MIN)
|
||||
$(IOS_TARGETS): LDFLAGS += -miphoneos-version-min=$(IPHONEOS_VERSION_MIN)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
$(IOS_TARGETS): CFLAGS += -Iout/openssl/ios/ios64-xcrun/usr/local/include
|
||||
$(IOS_TARGETS): LDFLAGS += -Lout/openssl/ios/ios64-xcrun/usr/local/lib
|
||||
@ -707,12 +718,12 @@ $(SQLITE_OBJS): CFLAGS += \
|
||||
-DSQLITE_MAX_COMPOUND_SELECT=300 \
|
||||
-DSQLITE_MAX_EXPR_DEPTH=40 \
|
||||
-DSQLITE_MAX_FUNCTION_ARG=8 \
|
||||
-DSQLITE_MAX_LENGTH=5242880 \
|
||||
-DSQLITE_MAX_LENGTH=10485760 \
|
||||
-DSQLITE_MAX_LIKE_PATTERN_LENGTH=50 \
|
||||
-DSQLITE_MAX_SQL_LENGTH=100000 \
|
||||
-DSQLITE_MAX_TRIGGER_DEPTH=10 \
|
||||
-DSQLITE_MAX_VARIABLE_NUMBER=100 \
|
||||
-DSQLITE_MAX_VDBE_OP=25000 \
|
||||
-DSQLITE_MAX_VDBE_OP=50000 \
|
||||
-DSQLITE_OMIT_DEPRECATED \
|
||||
-DSQLITE_OMIT_DESERIALIZE \
|
||||
-DSQLITE_OMIT_LOAD_EXTENSION \
|
||||
@ -910,6 +921,17 @@ src/android/AndroidManifest.xml : $(firstword $(MAKEFILE_LIST))
|
||||
-e 's/android:targetSdkVersion="[[:digit:]]*"/android:targetSdkVersion="$(ANDROID_TARGET_SDK_VERSION)"/' \
|
||||
$@
|
||||
|
||||
src/ios/Info.plist : $(firstword $(MAKEFILE_LIST))
|
||||
@echo "[ios_version] $@"
|
||||
@cat $@ | \
|
||||
tr '\n' '^' | \
|
||||
sed -r \
|
||||
-e 's@(<key>CFBundleShortVersionString</key>\^[[:space:]]*<string>)[0-9.]*(</string>)@\1$(VERSION_NUMBER:%-wip=%)\2@' \
|
||||
-e 's@(<key>CFBundleVersion</key>\^[[:space:]]*<string>)[[:digit:]]+(</string>)@\1$(VERSION_CODE_IOS)\2@' \
|
||||
-e 's@(<key>MinimumOSVersion</key>\^[[:space:]]*<string>)[0-9.]*(</string>)@\1$(IPHONEOS_VERSION_MIN)\2@' | \
|
||||
tr '^' '\n' > \
|
||||
$@.tmp && mv $@.tmp $@ || rm -f $@.tmp
|
||||
|
||||
##
|
||||
## Android targets:
|
||||
##
|
||||
@ -967,11 +989,12 @@ out/apk/classes.dex: $(CLASS_FILES)
|
||||
@$(ANDROID_BUILD_TOOLS)/d8 --lib $(ANDROID_PLATFORM)/android.jar --output $(dir $@) out/classes/com/unprompted/tildefriends/*.class
|
||||
|
||||
PACKAGE_DIRS := \
|
||||
apps/ \
|
||||
core/ \
|
||||
deps/codemirror/ \
|
||||
deps/prettier/ \
|
||||
deps/lit/
|
||||
apps \
|
||||
core \
|
||||
deps/codemirror \
|
||||
deps/prettier \
|
||||
deps/lit \
|
||||
deps/speedscope
|
||||
|
||||
RAW_FILES := $(sort $(filter-out apps/blog% apps/issues% apps/welcome% apps/journal% %.map, $(shell find $(PACKAGE_DIRS) -type f -not -name '.*')))
|
||||
|
||||
@ -1139,7 +1162,13 @@ out/zsign_build/zsign: $(wildcard deps/zsign/*.cpp deps/zsign/*.h deps/zsign/*.t
|
||||
@cmake -B out/zsign_build deps/zsign
|
||||
@cmake --build out/zsign_build -- COLOR=0 VERBOSE=0 MAKESILENT=-s
|
||||
|
||||
out/tildefriends-%.app/tildefriends: out/%/tildefriends out/tildefriends-%.app/Info.plist out/tildefriends-%.app/tildefriends.png out/data.zip $(if $(HAVE_LINUX_IOS),out/zsign_build/zsign)
|
||||
ifeq ($(HAVE_LINUX_IOS),1)
|
||||
ZSIGN_DEP = out/zsign_build/zsign
|
||||
else
|
||||
ZSIGN_DEP =
|
||||
endif
|
||||
|
||||
out/tildefriends-%.app/tildefriends: out/%/tildefriends out/tildefriends-%.app/Info.plist out/tildefriends-%.app/tildefriends.png out/data.zip $(ZSIGN_DEP)
|
||||
@mkdir -p $(dir $@)
|
||||
@cp -v $(filter-out out/zsign%,$<) $@
|
||||
@cp -v out/data.zip $(@D)/
|
||||
@ -1219,7 +1248,7 @@ $(LOCAL_DEPS):
|
||||
CROSS_TOP=../../deps/ios_toolchain/target \
|
||||
CROSS_SDK=iPhoneOS18.2.sdk \
|
||||
CC=clang \
|
||||
OPTIONS=-miphoneos-version-min=9.0 \
|
||||
OPTIONS=-miphoneos-version-min=$(IPHONEOS_VERSION_MIN) \
|
||||
tools/ssl-local
|
||||
$(filter $(BUILD_DIR)/ios%,$(APP_OBJS)): | $(LOCAL_DEPS)
|
||||
endif
|
||||
@ -1266,7 +1295,7 @@ endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
IOS_DEPS := out/openssl/ios/ios64-xcrun/usr/local/lib/libssl.a
|
||||
$(IOS_DEPS):
|
||||
+@BUILD_PLATFORM=ios BUILD_TARGET=ios64-xcrun SSL_TARGET=ios64-xcrun OPTIONS="-fPIC -Wno-macro-redefined -miphoneos-version-min=9.0" tools/ssl-local
|
||||
+@BUILD_PLATFORM=ios BUILD_TARGET=ios64-xcrun SSL_TARGET=ios64-xcrun OPTIONS="-fPIC -Wno-macro-redefined -miphoneos-version-min=$(IPHONEOS_VERSION_MIN)" tools/ssl-local
|
||||
+@BUILD_PLATFORM=ios BUILD_TARGET=iossimulator-xcrun SSL_TARGET=iossimulator-xcrun OPTIONS="-fPIC -Wno-macro-redefined" tools/ssl-local
|
||||
$(filter $(BUILD_DIR)/ios%,$(APP_OBJS)): | $(IOS_DEPS)
|
||||
endif
|
||||
@ -1400,6 +1429,17 @@ dist-test: dist ## Exercise some built distributable files, making sure they wor
|
||||
@rm -rf tildefriends-$(VERSION_NUMBER)
|
||||
.PHONY: dist-test
|
||||
|
||||
dist-ios: iosrelease-app
|
||||
rm -rfv out/Payload out/tildefriends.ipa
|
||||
mkdir -p out/Payload/tildefriends.app
|
||||
cp -avR out/tildefriends-iosrelease.app/* out/Payload/tildefriends.app/
|
||||
cp src/ios/tildefriends.png out/Payload/tildefriends.app/
|
||||
xcrun -sdk iphoneos actool --compile out/Payload/tildefriends.app/ --platform iphoneos --minimum-deployment-target $(IPHONEOS_VERSION_MIN) --app-icon AppIcon src/ios/icons/Assets.xcassets src/ios/icons/*.png --output-partial-info-plist out/actool.plist
|
||||
cp src/ios/distribution.mobileprovision out/Payload/tildefriends.app/embedded.mobileprovision
|
||||
xcrun -sdk iphoneos codesign -f -s 'Apple Distribution' --entitlements src/ios/Entitlements.plist --generate-entitlement-der out/Payload/tildefriends.app
|
||||
cd out; zip -r tildefriends.ipa Payload; cd ..
|
||||
xcrun -sdk iphoneos altool --upload-app -f out/tildefriends.ipa -t ios -u $$(cat .keys/altool-user) -p $$(cat .keys/altool-password)
|
||||
|
||||
##
|
||||
## Targets for tidying up:
|
||||
##
|
||||
|
@ -38,7 +38,7 @@ dependencies in the right places.
|
||||
|
||||
### Requirements
|
||||
|
||||
System OpenSSL libraries are assumed to be available on Haiku and OpenSSL.
|
||||
System OpenSSL libraries are assumed to be available on Haiku and OpenBSD.
|
||||
|
||||
On MacOS, Xcode's command-line tools are expected to be available.
|
||||
|
||||
@ -55,9 +55,8 @@ standard.
|
||||
## Running
|
||||
|
||||
By default, running the built `out/debug/tildefriends` executable will start a
|
||||
web server at <http://localhost:12345/>. It expects to be run with the
|
||||
repository root as the current working directory. `tildefriends -h` lists
|
||||
further options.
|
||||
web server at <http://localhost:12345/>. `tildefriends -h` lists further
|
||||
options.
|
||||
|
||||
The first user to create an account and log in will be granted administrative
|
||||
privileges. Further administration can be done in the `admin` app at
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* W3.CSS 4.15 December 2020 by Jan Egil and Borge Refsnes */
|
||||
/* W3.CSS 5.01 March 14 2025 by Jan Egil and Borge Refsnes */
|
||||
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
|
||||
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
|
||||
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
||||
@ -108,6 +108,10 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px}
|
||||
.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px}
|
||||
.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px}
|
||||
|
||||
.w3-grid{display:grid}.w3-grid-padding{display:grid;gap:16px}.w3-flex{display:flex}
|
||||
.w3-text-center{text-align:center}.w3-text-bold,.w3-bold{font-weight:bold}.w3-text-italic,.w3-italic{font-style:italic}
|
||||
|
||||
.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px}
|
||||
.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word}
|
||||
.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%}
|
||||
@ -149,9 +153,9 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-transparent,.w3-hover-none:hover{background-color:transparent!important}
|
||||
.w3-hover-none:hover{box-shadow:none!important}
|
||||
/* Colors */
|
||||
.w3-amber,.w3-hover-amber:hover{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-amber,.w3-hover-amber:hover,.w3-warning{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-aqua,.w3-hover-aqua:hover{color:#000!important;background-color:#00ffff!important}
|
||||
.w3-blue,.w3-hover-blue:hover{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-blue,.w3-hover-blue:hover,.w3-info,.w3-primary{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;background-color:#87CEEB!important}
|
||||
.w3-brown,.w3-hover-brown:hover{color:#fff!important;background-color:#795548!important}
|
||||
.w3-cyan,.w3-hover-cyan:hover{color:#000!important;background-color:#00bcd4!important}
|
||||
@ -166,15 +170,24 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-pink,.w3-hover-pink:hover{color:#fff!important;background-color:#e91e63!important}
|
||||
.w3-purple,.w3-hover-purple:hover{color:#fff!important;background-color:#9c27b0!important}
|
||||
.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;background-color:#673ab7!important}
|
||||
.w3-red,.w3-hover-red:hover{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-red,.w3-hover-red:hover,.w3-danger{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-sand,.w3-hover-sand:hover{color:#000!important;background-color:#fdf5e6!important}
|
||||
.w3-teal,.w3-hover-teal:hover{color:#fff!important;background-color:#009688!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover,.w3-note{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-white,.w3-hover-white:hover{color:#000!important;background-color:#fff!important}
|
||||
.w3-black,.w3-hover-black:hover{color:#fff!important;background-color:#000!important}
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover{color:#000!important;background-color:#9e9e9e!important}
|
||||
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover,.w3-secondary{color:#000!important;background-color:#9e9e9e!important}
|
||||
.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,.w3-hover-light-gray:hover{color:#000!important;background-color:#f1f1f1!important}
|
||||
.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,.w3-hover-dark-gray:hover{color:#fff!important;background-color:#616161!important}
|
||||
|
||||
.w3-asphalt,.w3-hover-asphalt:hover{color:#fff!important;background-color:#343a40!important}.w3-crimson,.w3-hover-crimson:hover{color:#fff!important;background-color:#a20025!important}
|
||||
.w3-cobalt,w3-hover-cobalt:hover{color:#fff!important;background-color:#0050ef!important}
|
||||
.w3-emerald,.w3-hover-emerald:hover,.w3-success{color:#fff!important;background-color:#008a00!important}
|
||||
.w3-olive,.w3-hover-olive:hover{color:#fff!important;background-color:#6d8764!important}
|
||||
.w3-paper,.w3-hover-paper:hover{color:#000!important;background-color:#f8f9fa!important}.w3-sienna,.w3-hover-sienna:hover{color:#fff!important;background-color:#a0522d!important}
|
||||
.w3-taupe,.w3-hover-taupe:hover{color:#fff!important;background-color:#87794e!important}
|
||||
|
||||
.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;background-color:#ffdddd!important}
|
||||
.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;background-color:#ddffdd!important}
|
||||
.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;background-color:#ffffcc!important}
|
||||
@ -232,4 +245,4 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-border-light-grey,.w3-hover-border-light-grey:hover,.w3-border-light-gray,.w3-hover-border-light-gray:hover{border-color:#f1f1f1!important}
|
||||
.w3-border-dark-grey,.w3-hover-border-dark-grey:hover,.w3-border-dark-gray,.w3-hover-border-dark-gray:hover{border-color:#616161!important}
|
||||
.w3-border-pale-red,.w3-hover-border-pale-red:hover{border-color:#ffe7e7!important}.w3-border-pale-green,.w3-hover-border-pale-green:hover{border-color:#e7ffe7!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* W3.CSS 4.15 December 2020 by Jan Egil and Borge Refsnes */
|
||||
/* W3.CSS 5.01 March 14 2025 by Jan Egil and Borge Refsnes */
|
||||
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
|
||||
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
|
||||
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
||||
@ -108,6 +108,10 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px}
|
||||
.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px}
|
||||
.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px}
|
||||
|
||||
.w3-grid{display:grid}.w3-grid-padding{display:grid;gap:16px}.w3-flex{display:flex}
|
||||
.w3-text-center{text-align:center}.w3-text-bold,.w3-bold{font-weight:bold}.w3-text-italic,.w3-italic{font-style:italic}
|
||||
|
||||
.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px}
|
||||
.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word}
|
||||
.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%}
|
||||
@ -149,9 +153,9 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-transparent,.w3-hover-none:hover{background-color:transparent!important}
|
||||
.w3-hover-none:hover{box-shadow:none!important}
|
||||
/* Colors */
|
||||
.w3-amber,.w3-hover-amber:hover{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-amber,.w3-hover-amber:hover,.w3-warning{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-aqua,.w3-hover-aqua:hover{color:#000!important;background-color:#00ffff!important}
|
||||
.w3-blue,.w3-hover-blue:hover{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-blue,.w3-hover-blue:hover,.w3-info,.w3-primary{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;background-color:#87CEEB!important}
|
||||
.w3-brown,.w3-hover-brown:hover{color:#fff!important;background-color:#795548!important}
|
||||
.w3-cyan,.w3-hover-cyan:hover{color:#000!important;background-color:#00bcd4!important}
|
||||
@ -166,15 +170,24 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-pink,.w3-hover-pink:hover{color:#fff!important;background-color:#e91e63!important}
|
||||
.w3-purple,.w3-hover-purple:hover{color:#fff!important;background-color:#9c27b0!important}
|
||||
.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;background-color:#673ab7!important}
|
||||
.w3-red,.w3-hover-red:hover{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-red,.w3-hover-red:hover,.w3-danger{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-sand,.w3-hover-sand:hover{color:#000!important;background-color:#fdf5e6!important}
|
||||
.w3-teal,.w3-hover-teal:hover{color:#fff!important;background-color:#009688!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover,.w3-note{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-white,.w3-hover-white:hover{color:#000!important;background-color:#fff!important}
|
||||
.w3-black,.w3-hover-black:hover{color:#fff!important;background-color:#000!important}
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover{color:#000!important;background-color:#9e9e9e!important}
|
||||
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover,.w3-secondary{color:#000!important;background-color:#9e9e9e!important}
|
||||
.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,.w3-hover-light-gray:hover{color:#000!important;background-color:#f1f1f1!important}
|
||||
.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,.w3-hover-dark-gray:hover{color:#fff!important;background-color:#616161!important}
|
||||
|
||||
.w3-asphalt,.w3-hover-asphalt:hover{color:#fff!important;background-color:#343a40!important}.w3-crimson,.w3-hover-crimson:hover{color:#fff!important;background-color:#a20025!important}
|
||||
.w3-cobalt,w3-hover-cobalt:hover{color:#fff!important;background-color:#0050ef!important}
|
||||
.w3-emerald,.w3-hover-emerald:hover,.w3-success{color:#fff!important;background-color:#008a00!important}
|
||||
.w3-olive,.w3-hover-olive:hover{color:#fff!important;background-color:#6d8764!important}
|
||||
.w3-paper,.w3-hover-paper:hover{color:#000!important;background-color:#f8f9fa!important}.w3-sienna,.w3-hover-sienna:hover{color:#fff!important;background-color:#a0522d!important}
|
||||
.w3-taupe,.w3-hover-taupe:hover{color:#fff!important;background-color:#87794e!important}
|
||||
|
||||
.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;background-color:#ffdddd!important}
|
||||
.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;background-color:#ddffdd!important}
|
||||
.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;background-color:#ffffcc!important}
|
||||
@ -232,4 +245,4 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-border-light-grey,.w3-hover-border-light-grey:hover,.w3-border-light-gray,.w3-hover-border-light-gray:hover{border-color:#f1f1f1!important}
|
||||
.w3-border-dark-grey,.w3-hover-border-dark-grey:hover,.w3-border-dark-gray,.w3-hover-border-dark-gray:hover{border-color:#616161!important}
|
||||
.w3-border-pale-red,.w3-hover-border-pale-red:hover{border-color:#ffe7e7!important}.w3-border-pale-green,.w3-hover-border-pale-green:hover{border-color:#e7ffe7!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
|
42
apps/blog/lit-all.min.js
vendored
@ -1,4 +1,4 @@
|
||||
/* W3.CSS 4.15 December 2020 by Jan Egil and Borge Refsnes */
|
||||
/* W3.CSS 5.01 March 14 2025 by Jan Egil and Borge Refsnes */
|
||||
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
|
||||
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
|
||||
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
||||
@ -108,6 +108,10 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px}
|
||||
.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px}
|
||||
.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px}
|
||||
|
||||
.w3-grid{display:grid}.w3-grid-padding{display:grid;gap:16px}.w3-flex{display:flex}
|
||||
.w3-text-center{text-align:center}.w3-text-bold,.w3-bold{font-weight:bold}.w3-text-italic,.w3-italic{font-style:italic}
|
||||
|
||||
.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px}
|
||||
.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word}
|
||||
.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%}
|
||||
@ -149,9 +153,9 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-transparent,.w3-hover-none:hover{background-color:transparent!important}
|
||||
.w3-hover-none:hover{box-shadow:none!important}
|
||||
/* Colors */
|
||||
.w3-amber,.w3-hover-amber:hover{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-amber,.w3-hover-amber:hover,.w3-warning{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-aqua,.w3-hover-aqua:hover{color:#000!important;background-color:#00ffff!important}
|
||||
.w3-blue,.w3-hover-blue:hover{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-blue,.w3-hover-blue:hover,.w3-info,.w3-primary{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;background-color:#87CEEB!important}
|
||||
.w3-brown,.w3-hover-brown:hover{color:#fff!important;background-color:#795548!important}
|
||||
.w3-cyan,.w3-hover-cyan:hover{color:#000!important;background-color:#00bcd4!important}
|
||||
@ -166,15 +170,24 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-pink,.w3-hover-pink:hover{color:#fff!important;background-color:#e91e63!important}
|
||||
.w3-purple,.w3-hover-purple:hover{color:#fff!important;background-color:#9c27b0!important}
|
||||
.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;background-color:#673ab7!important}
|
||||
.w3-red,.w3-hover-red:hover{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-red,.w3-hover-red:hover,.w3-danger{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-sand,.w3-hover-sand:hover{color:#000!important;background-color:#fdf5e6!important}
|
||||
.w3-teal,.w3-hover-teal:hover{color:#fff!important;background-color:#009688!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover,.w3-note{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-white,.w3-hover-white:hover{color:#000!important;background-color:#fff!important}
|
||||
.w3-black,.w3-hover-black:hover{color:#fff!important;background-color:#000!important}
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover{color:#000!important;background-color:#9e9e9e!important}
|
||||
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover,.w3-secondary{color:#000!important;background-color:#9e9e9e!important}
|
||||
.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,.w3-hover-light-gray:hover{color:#000!important;background-color:#f1f1f1!important}
|
||||
.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,.w3-hover-dark-gray:hover{color:#fff!important;background-color:#616161!important}
|
||||
|
||||
.w3-asphalt,.w3-hover-asphalt:hover{color:#fff!important;background-color:#343a40!important}.w3-crimson,.w3-hover-crimson:hover{color:#fff!important;background-color:#a20025!important}
|
||||
.w3-cobalt,w3-hover-cobalt:hover{color:#fff!important;background-color:#0050ef!important}
|
||||
.w3-emerald,.w3-hover-emerald:hover,.w3-success{color:#fff!important;background-color:#008a00!important}
|
||||
.w3-olive,.w3-hover-olive:hover{color:#fff!important;background-color:#6d8764!important}
|
||||
.w3-paper,.w3-hover-paper:hover{color:#000!important;background-color:#f8f9fa!important}.w3-sienna,.w3-hover-sienna:hover{color:#fff!important;background-color:#a0522d!important}
|
||||
.w3-taupe,.w3-hover-taupe:hover{color:#fff!important;background-color:#87794e!important}
|
||||
|
||||
.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;background-color:#ffdddd!important}
|
||||
.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;background-color:#ddffdd!important}
|
||||
.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;background-color:#ffffcc!important}
|
||||
@ -232,4 +245,4 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-border-light-grey,.w3-hover-border-light-grey:hover,.w3-border-light-gray,.w3-hover-border-light-gray:hover{border-color:#f1f1f1!important}
|
||||
.w3-border-dark-grey,.w3-hover-border-dark-grey:hover,.w3-border-dark-gray,.w3-hover-border-dark-gray:hover{border-color:#616161!important}
|
||||
.w3-border-pale-red,.w3-hover-border-pale-red:hover{border-color:#ffe7e7!important}.w3-border-pale-green,.w3-hover-border-pale-green:hover{border-color:#e7ffe7!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
|
42
apps/issues/lit-all.min.js
vendored
42
apps/journal/lit-all.min.js
vendored
@ -1,7 +1,9 @@
|
||||
async function main() {
|
||||
let host = core.url.match(/.*\/\/(.*?)\//)[1];
|
||||
print(core.url);
|
||||
let host = core.url.match(/.*?\/\/([^:/]*)/)[1];
|
||||
let port = await ssb.port();
|
||||
let id = (await ssb.getServerIdentity()).substring(1);
|
||||
let room = `net:${host}:${ssb.port}~shs:${id}:SSB+Room+SK3TLYC2T86EHQCUHBUHASCASE18JBV24=`;
|
||||
let room = `net:${host}:${port}~shs:${id}:SSB+Room+SK3TLYC2T86EHQCUHBUHASCASE18JBV24=`;
|
||||
await app.setDocument(`
|
||||
<body style="color: #fff">
|
||||
<h1>Server</h1>
|
||||
|
42
apps/sneaker/lit-all.min.js
vendored
@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🦀",
|
||||
"previous": "&jAAzd36Nmpw0sRA1Dx9wLiIwGX+q//+S/Han+RLlEOw=.sha256"
|
||||
"previous": "&Zv/eOewtUPxYuALmYV8v+JDKwH4+aN8zCTYFwB7oYEw=.sha256"
|
||||
}
|
||||
|
42
apps/ssb/lit-all.min.js
vendored
@ -175,63 +175,98 @@ class TfElement extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
let abouts = await tfrpc.rpc.query(
|
||||
`
|
||||
SELECT
|
||||
messages.author, json(messages.content) AS content, messages.sequence
|
||||
FROM
|
||||
messages,
|
||||
json_each(?1) AS following
|
||||
WHERE
|
||||
messages.author = following.value AND
|
||||
messages.rowid > ?3 AND
|
||||
messages.rowid <= ?4 AND
|
||||
json_extract(messages.content, '$.type') = 'about'
|
||||
UNION
|
||||
SELECT
|
||||
messages.author, json(messages.content) AS content, messages.sequence
|
||||
FROM
|
||||
messages,
|
||||
json_each(?2) AS following
|
||||
WHERE
|
||||
messages.author = following.value AND
|
||||
messages.rowid <= ?4 AND
|
||||
json_extract(messages.content, '$.type') = 'about'
|
||||
ORDER BY messages.author, messages.sequence
|
||||
`,
|
||||
[
|
||||
JSON.stringify(ids.filter((id) => cache.about[id])),
|
||||
JSON.stringify(ids.filter((id) => !cache.about[id])),
|
||||
cache.last_row_id,
|
||||
max_row_id,
|
||||
]
|
||||
const k_chunk_size = 1024;
|
||||
let min_row_id = 0;
|
||||
console.log(
|
||||
'loading about for',
|
||||
ids.length,
|
||||
'accounts',
|
||||
cache.last_row_id,
|
||||
'=>',
|
||||
max_row_id
|
||||
);
|
||||
for (let about of abouts) {
|
||||
let content = JSON.parse(about.content);
|
||||
if (content.about === about.author) {
|
||||
delete content.type;
|
||||
delete content.about;
|
||||
cache.about[about.author] = Object.assign(
|
||||
cache.about[about.author] || {},
|
||||
content
|
||||
try {
|
||||
while (true) {
|
||||
let abouts = await tfrpc.rpc.query(
|
||||
`
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
messages.rowid AS rowid, messages.author, json(messages.content) AS content, messages.sequence
|
||||
FROM
|
||||
messages,
|
||||
json_each(?1) AS following
|
||||
WHERE
|
||||
messages.author = following.value AND
|
||||
messages.content ->> 'type' = 'about' AND
|
||||
messages.rowid > ?3 AND
|
||||
messages.rowid <= ?4
|
||||
UNION
|
||||
SELECT
|
||||
messages.rowid AS rowid, messages.author, json(messages.content) AS content, messages.sequence
|
||||
FROM
|
||||
messages,
|
||||
json_each(?2) AS following
|
||||
WHERE
|
||||
messages.author = following.value AND
|
||||
messages.content ->> 'type' = 'about' AND
|
||||
messages.rowid > ?6 AND
|
||||
messages.rowid <= ?4
|
||||
)
|
||||
ORDER BY rowid LIMIT ?5
|
||||
`,
|
||||
[
|
||||
JSON.stringify(ids.filter((id) => cache.about[id])),
|
||||
JSON.stringify(ids.filter((id) => !cache.about[id])),
|
||||
cache.last_row_id,
|
||||
max_row_id,
|
||||
k_chunk_size,
|
||||
min_row_id,
|
||||
]
|
||||
);
|
||||
let max_seen;
|
||||
for (let about of abouts) {
|
||||
let content = JSON.parse(about.content);
|
||||
if (content.about === about.author) {
|
||||
delete content.type;
|
||||
delete content.about;
|
||||
cache.about[about.author] = Object.assign(
|
||||
cache.about[about.author] || {},
|
||||
content
|
||||
);
|
||||
}
|
||||
max_seen = about.rowid;
|
||||
}
|
||||
console.log(
|
||||
'cache =',
|
||||
cache.last_row_id,
|
||||
'seen =',
|
||||
max_seen,
|
||||
'max =',
|
||||
max_row_id
|
||||
);
|
||||
cache.last_row_id = Math.max(cache.last_row_id, max_seen ?? max_row_id);
|
||||
min_row_id = Math.max(min_row_id, max_seen ?? max_row_id);
|
||||
let new_cache = JSON.stringify(cache);
|
||||
if (new_cache !== original_cache) {
|
||||
let start_time = new Date();
|
||||
tfrpc.rpc.databaseSet('about', new_cache).then(function () {
|
||||
console.log('saving about took', (new Date() - start_time) / 1000);
|
||||
});
|
||||
}
|
||||
users = users || {};
|
||||
for (let id of Object.keys(cache.about)) {
|
||||
users[id] = Object.assign(
|
||||
{follow_depth: following[id]?.d},
|
||||
users[id] || {},
|
||||
cache.about[id]
|
||||
);
|
||||
}
|
||||
if (cache.last_row_id >= max_row_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cache.last_row_id = max_row_id;
|
||||
let new_cache = JSON.stringify(cache);
|
||||
if (new_cache !== original_cache) {
|
||||
let start_time = new Date();
|
||||
tfrpc.rpc.databaseSet('about', new_cache).then(function () {
|
||||
console.log('saving about took', (new Date() - start_time) / 1000);
|
||||
});
|
||||
}
|
||||
users = users || {};
|
||||
for (let id of Object.keys(cache.about)) {
|
||||
users[id] = Object.assign(
|
||||
{follow_depth: following[id]?.d},
|
||||
users[id] || {},
|
||||
cache.about[id]
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
return Object.assign({}, users);
|
||||
}
|
||||
@ -382,7 +417,6 @@ class TfElement extends LitElement {
|
||||
'🔐': latest[0],
|
||||
});
|
||||
console.log('private took', (new Date() - start_time) / 1000.0);
|
||||
console.log(latest);
|
||||
self.private_messages = latest[1];
|
||||
});
|
||||
}
|
||||
|
@ -255,10 +255,12 @@ class TfComposeElement extends LitElement {
|
||||
let self = this;
|
||||
let input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.onchange = function (event) {
|
||||
input.addEventListener('change', function (event) {
|
||||
input.parentNode.removeChild(input);
|
||||
let file = event.target.files[0];
|
||||
self.add_file(file);
|
||||
};
|
||||
});
|
||||
document.body.appendChild(input);
|
||||
input.click();
|
||||
}
|
||||
|
||||
@ -357,7 +359,7 @@ class TfComposeElement extends LitElement {
|
||||
remove_mention(id) {
|
||||
let draft = this.get_draft();
|
||||
delete draft.mentions[id];
|
||||
setTimeout(() => this.notify(), 0);
|
||||
setTimeout(() => this.notify(draft), 0);
|
||||
}
|
||||
|
||||
render_mention(mention) {
|
||||
|
@ -33,6 +33,25 @@ class TfMessageElement extends LitElement {
|
||||
this.channel_unread = -1;
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this._click_callback = this.document_click.bind(this);
|
||||
document.body.addEventListener('mouseup', this._click_callback);
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
document.body.removeEventListener('mouseup', this._click_callback);
|
||||
}
|
||||
|
||||
document_click(event) {
|
||||
let content = this.renderRoot.querySelector('.w3-dropdown-content');
|
||||
let target = event.target;
|
||||
if (content && !content.contains(target)) {
|
||||
content.classList.remove('w3-show');
|
||||
}
|
||||
}
|
||||
|
||||
show_reply() {
|
||||
let event = new CustomEvent('tf-draft', {
|
||||
bubbles: true,
|
||||
@ -291,32 +310,39 @@ class TfMessageElement extends LitElement {
|
||||
let self = this;
|
||||
if (this.message.child_messages?.length) {
|
||||
if (!this.expanded[this.message.id]) {
|
||||
return html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
@click=${() => self.set_expanded(true)}
|
||||
>
|
||||
+ ${this.total_child_messages(this.message) + ' More'}
|
||||
</button>`;
|
||||
return html`
|
||||
<button
|
||||
class="w3-button w3-theme-d1 w3-block w3-bar"
|
||||
style="box-sizing: border-box"
|
||||
@click=${() => self.set_expanded(true)}
|
||||
>
|
||||
+ ${this.total_child_messages(this.message) + ' More'}
|
||||
</button>
|
||||
`;
|
||||
} else {
|
||||
return html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
return html` <div class="w3-container w3-margin-bottom">
|
||||
${repeat(
|
||||
this.message.child_messages || [],
|
||||
(x) => x.id,
|
||||
(x) =>
|
||||
html`<tf-message
|
||||
.message=${x}
|
||||
whoami=${this.whoami}
|
||||
.users=${this.users}
|
||||
.drafts=${this.drafts}
|
||||
.expanded=${this.expanded}
|
||||
channel=${this.channel}
|
||||
channel_unread=${this.channel_unread}
|
||||
></tf-message>`
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
class="w3-button w3-theme-d1 w3-block w3-bar"
|
||||
style="box-sizing: border-box"
|
||||
@click=${() => self.set_expanded(false)}
|
||||
>
|
||||
Collapse</button
|
||||
>${repeat(
|
||||
this.message.child_messages || [],
|
||||
(x) => x.id,
|
||||
(x) =>
|
||||
html`<tf-message
|
||||
.message=${x}
|
||||
whoami=${this.whoami}
|
||||
.users=${this.users}
|
||||
.drafts=${this.drafts}
|
||||
.expanded=${this.expanded}
|
||||
channel=${this.channel}
|
||||
channel_unread=${this.channel_unread}
|
||||
></tf-message>`
|
||||
)}`;
|
||||
Collapse
|
||||
</button>`;
|
||||
}
|
||||
} else {
|
||||
return undefined;
|
||||
@ -371,62 +397,74 @@ class TfMessageElement extends LitElement {
|
||||
return content;
|
||||
}
|
||||
|
||||
render_raw_button() {
|
||||
copy_id(event) {
|
||||
navigator.clipboard.writeText(this.message?.id);
|
||||
}
|
||||
|
||||
toggle_menu(event) {
|
||||
event.srcElement.parentNode
|
||||
.querySelector('.w3-dropdown-content')
|
||||
.classList.toggle('w3-show');
|
||||
}
|
||||
|
||||
render_menu() {
|
||||
let content = this.get_content();
|
||||
let raw_button;
|
||||
switch (this.format) {
|
||||
case 'raw':
|
||||
if (content?.type == 'post' || content?.type == 'blog') {
|
||||
raw_button = html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
@click=${() => (this.format = 'md')}
|
||||
>
|
||||
Markdown
|
||||
</button>`;
|
||||
} else {
|
||||
raw_button = html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
@click=${() => (this.format = 'message')}
|
||||
>
|
||||
Message
|
||||
</button>`;
|
||||
}
|
||||
break;
|
||||
case 'md':
|
||||
raw_button = html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
@click=${() => (this.format = 'message')}
|
||||
>
|
||||
Message
|
||||
</button>`;
|
||||
break;
|
||||
case 'decrypted':
|
||||
raw_button = html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
@click=${() => (this.format = 'raw')}
|
||||
>
|
||||
Raw
|
||||
</button>`;
|
||||
break;
|
||||
default:
|
||||
if (this.message.decrypted) {
|
||||
raw_button = html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
@click=${() => (this.format = 'decrypted')}
|
||||
>
|
||||
Decrypted
|
||||
</button>`;
|
||||
} else {
|
||||
raw_button = html`<button
|
||||
class="w3-button w3-theme-d1"
|
||||
@click=${() => (this.format = 'raw')}
|
||||
>
|
||||
Raw
|
||||
</button>`;
|
||||
}
|
||||
break;
|
||||
let formats = [['message', 'Message']];
|
||||
if (content?.type == 'post' || content?.type == 'blog') {
|
||||
formats.push(['md', 'Markdown']);
|
||||
}
|
||||
return raw_button;
|
||||
if (this.message?.decrypted) {
|
||||
formats.push(['decrypted', 'Decrypted']);
|
||||
}
|
||||
formats.push(['raw', 'Raw']);
|
||||
return html`
|
||||
<div class="w3-bar-item w3-right">
|
||||
<button class="w3-button w3-theme-d1" @click=${this.toggle_menu}>
|
||||
%
|
||||
</button>
|
||||
<div
|
||||
class="w3-dropdown-content w3-bar-block w3-card-4 w3-theme-l1"
|
||||
style="right: 48px"
|
||||
>
|
||||
<a
|
||||
target="_top"
|
||||
class="w3-button w3-bar-item"
|
||||
href=${'#' + encodeURIComponent(this.message?.id)}
|
||||
>View Message</a
|
||||
>
|
||||
<button
|
||||
class="w3-button w3-bar-item w3-border-bottom"
|
||||
@click=${this.copy_id}
|
||||
>
|
||||
Copy ID
|
||||
</button>
|
||||
${this.drafts[this.message?.id] === undefined
|
||||
? html`
|
||||
<button class="w3-button w3-bar-item" @click=${this.show_reply}>
|
||||
⮢ Reply
|
||||
</button>
|
||||
`
|
||||
: undefined}
|
||||
<button
|
||||
class="w3-button w3-bar-item w3-border-bottom"
|
||||
@click=${this.react}
|
||||
>
|
||||
👍 React
|
||||
</button>
|
||||
${formats.map(
|
||||
([format, name]) => html`
|
||||
<button
|
||||
class="w3-button w3-bar-item"
|
||||
style=${format == this.format ? 'font-weight: bold' : ''}
|
||||
@click=${() => (this.format = format)}
|
||||
>
|
||||
${name}
|
||||
</button>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
render_header() {
|
||||
@ -440,14 +478,10 @@ class TfMessageElement extends LitElement {
|
||||
<span class="w3-bar-item">
|
||||
<tf-user id=${this.message.author} .users=${this.users}></tf-user>
|
||||
</span>
|
||||
${is_encrypted}
|
||||
<span class="w3-bar-item w3-right">${this.render_raw_button()}</span>
|
||||
<span class="w3-bar-item w3-right" style="text-wrap: nowrap"
|
||||
><a target="_top" href=${'#' + encodeURIComponent(this.message.id)}
|
||||
>%</a
|
||||
>
|
||||
${new Date(this.message.timestamp).toLocaleString()}</span
|
||||
>
|
||||
${is_encrypted} ${this.render_menu()}
|
||||
<div class="w3-bar-item w3-right" style="text-wrap: nowrap">
|
||||
${new Date(this.message.timestamp).toLocaleString()}
|
||||
</div>
|
||||
</header>
|
||||
`;
|
||||
}
|
||||
@ -516,19 +550,10 @@ class TfMessageElement extends LitElement {
|
||||
author=${this.message.author}
|
||||
></tf-compose>
|
||||
`
|
||||
: html`
|
||||
<button class="w3-button w3-theme-d1" @click=${this.show_reply}>
|
||||
Reply
|
||||
</button>
|
||||
`;
|
||||
: undefined;
|
||||
return html`
|
||||
<div class="w3-section w3-container">
|
||||
${reply}
|
||||
<button class="w3-button w3-theme-d1" @click=${this.react}>
|
||||
React
|
||||
</button>
|
||||
${this.render_children()}
|
||||
</div>
|
||||
<div class="w3-section w3-container">${reply}</div>
|
||||
<footer>${this.render_children()}</footer>
|
||||
`;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ class TfProfileElement extends LitElement {
|
||||
id: {type: String},
|
||||
users: {type: Object},
|
||||
size: {type: Number},
|
||||
sequence: {type: Number},
|
||||
following: {type: Boolean},
|
||||
blocking: {type: Boolean},
|
||||
};
|
||||
@ -26,6 +27,7 @@ class TfProfileElement extends LitElement {
|
||||
this.id = null;
|
||||
this.users = {};
|
||||
this.size = 0;
|
||||
this.sequence = 0;
|
||||
}
|
||||
|
||||
async load() {
|
||||
@ -139,7 +141,8 @@ class TfProfileElement extends LitElement {
|
||||
let self = this;
|
||||
let input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.onchange = function (event) {
|
||||
input.addEventListener('change', function (event) {
|
||||
input.parentNode.removeChild(input);
|
||||
let file = event.target.files[0];
|
||||
file
|
||||
.arrayBuffer()
|
||||
@ -154,7 +157,8 @@ class TfProfileElement extends LitElement {
|
||||
.catch(function (e) {
|
||||
alert(e.message);
|
||||
});
|
||||
};
|
||||
});
|
||||
document.body.appendChild(input);
|
||||
input.click();
|
||||
}
|
||||
|
||||
@ -168,11 +172,12 @@ class TfProfileElement extends LitElement {
|
||||
let profile = this.users[this.id] || {};
|
||||
tfrpc.rpc
|
||||
.query(
|
||||
`SELECT SUM(LENGTH(content)) AS size FROM messages WHERE author = ?`,
|
||||
`SELECT SUM(LENGTH(content)) AS size, MAX(sequence) AS sequence FROM messages WHERE author = ?`,
|
||||
[this.id]
|
||||
)
|
||||
.then(function (result) {
|
||||
self.size = result[0].size;
|
||||
self.sequence = result[0].sequence;
|
||||
});
|
||||
let edit;
|
||||
let follow;
|
||||
@ -243,7 +248,7 @@ class TfProfileElement extends LitElement {
|
||||
let description = this.editing?.description ?? profile.description;
|
||||
return html`<div class="w3-card-4 w3-container w3-theme-d3" style="box-sizing: border-box">
|
||||
<header class="w3-container">
|
||||
<p><tf-user id=${this.id} .users=${this.users}></tf-user> (${tfutils.human_readable_size(this.size)})</p>
|
||||
<p><tf-user id=${this.id} .users=${this.users}></tf-user> (${tfutils.human_readable_size(this.size)} in ${this.sequence} messages)</p>
|
||||
</header>
|
||||
<div class="w3-container">
|
||||
<div class="w3-margin-bottom" style="display: flex; flex-direction: row">
|
||||
|
@ -41,23 +41,26 @@ class TfReactionsModalElement extends LitElement {
|
||||
>
|
||||
</header>
|
||||
<ul class="w3-theme-dark w3-container w3-ul">
|
||||
${this.votes.map(
|
||||
(x) => html`
|
||||
<li class="w3-bar">
|
||||
<span class="w3-bar-item"
|
||||
>${x?.content?.vote?.expression}</span
|
||||
>
|
||||
<tf-user
|
||||
class="w3-bar-item"
|
||||
id=${x.author}
|
||||
.users=${this.users}
|
||||
></tf-user>
|
||||
<span class="w3-bar-item w3-right"
|
||||
>${new Date(x?.timestamp).toLocaleString()}</span
|
||||
>
|
||||
</li>
|
||||
`
|
||||
)}
|
||||
${this.votes
|
||||
.sort((x, y) => y.timestamp - x.timestamp)
|
||||
.map(
|
||||
(x) => html`
|
||||
<li style="display: flex; flex-direction: row; gap: 4px">
|
||||
<span style="flex-basis: 3em"
|
||||
>${x?.content?.vote?.expression}</span
|
||||
>
|
||||
<tf-user
|
||||
style="flex: 1 1"
|
||||
id=${x.author}
|
||||
.users=${this.users}
|
||||
></tf-user>
|
||||
<span
|
||||
style="flex-shrink: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
|
||||
>${new Date(x?.timestamp).toLocaleString()}</span
|
||||
>
|
||||
</li>
|
||||
`
|
||||
)}
|
||||
</ul>
|
||||
<footer class="w3-container w3-padding">
|
||||
<button class="w3-button" @click=${this.clear}>Close</button>
|
||||
|
@ -48,7 +48,7 @@ const tf = css`
|
||||
|
||||
// prettier-ignore
|
||||
const w3 = css`
|
||||
/* W3.CSS 4.15 December 2020 by Jan Egil and Borge Refsnes */
|
||||
/* W3.CSS 5.01 March 14 2025 by Jan Egil and Borge Refsnes */
|
||||
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
|
||||
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
|
||||
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
||||
@ -88,7 +88,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-table th:first-child,.w3-table td:first-child,.w3-table-all th:first-child,.w3-table-all td:first-child{padding-left:16px}
|
||||
.w3-btn,.w3-button{border:none;display:inline-block;padding:8px 16px;vertical-align:middle;overflow:hidden;text-decoration:none;color:inherit;background-color:inherit;text-align:center;cursor:pointer;white-space:nowrap}
|
||||
.w3-btn:hover{box-shadow:0 8px 16px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19)}
|
||||
.w3-btn,.w3-button{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
|
||||
.w3-btn,.w3-button{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
|
||||
.w3-disabled,.w3-btn:disabled,.w3-button:disabled{cursor:not-allowed;opacity:0.3}.w3-disabled *,:disabled *{pointer-events:none}
|
||||
.w3-btn.w3-disabled:hover,.w3-btn:disabled:hover{box-shadow:none}
|
||||
.w3-badge,.w3-tag{background-color:#000;color:#fff;display:inline-block;padding-left:8px;padding-right:8px;text-align:center}.w3-badge{border-radius:50%}
|
||||
@ -136,7 +136,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-hide{display:none!important}.w3-show-block,.w3-show{display:block!important}.w3-show-inline-block{display:inline-block!important}
|
||||
@media (max-width:1205px){.w3-auto{max-width:95%}}
|
||||
@media (max-width:600px){.w3-modal-content{margin:0 10px;width:auto!important}.w3-modal{padding-top:30px}
|
||||
.w3-dropdown-hover.w3-mobile .w3-dropdown-content,.w3-dropdown-click.w3-mobile .w3-dropdown-content{position:relative}
|
||||
.w3-dropdown-hover.w3-mobile .w3-dropdown-content,.w3-dropdown-click.w3-mobile .w3-dropdown-content{position:relative}
|
||||
.w3-hide-small{display:none!important}.w3-mobile{display:block;width:100%!important}.w3-bar-item.w3-mobile,.w3-dropdown-hover.w3-mobile,.w3-dropdown-click.w3-mobile{text-align:center}
|
||||
.w3-dropdown-hover.w3-mobile,.w3-dropdown-hover.w3-mobile .w3-btn,.w3-dropdown-hover.w3-mobile .w3-button,.w3-dropdown-click.w3-mobile,.w3-dropdown-click.w3-mobile .w3-btn,.w3-dropdown-click.w3-mobile .w3-button{width:100%}}
|
||||
@media (max-width:768px){.w3-modal-content{width:500px}.w3-modal{padding-top:50px}}
|
||||
@ -158,6 +158,10 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px}
|
||||
.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px}
|
||||
.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px}
|
||||
|
||||
.w3-grid{display:grid}.w3-grid-padding{display:grid;gap:16px}.w3-flex{display:flex}
|
||||
.w3-text-center{text-align:center}.w3-text-bold,.w3-bold{font-weight:bold}.w3-text-italic,.w3-italic{font-style:italic}
|
||||
|
||||
.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px}
|
||||
.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word}
|
||||
.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%}
|
||||
@ -199,9 +203,9 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-transparent,.w3-hover-none:hover{background-color:transparent!important}
|
||||
.w3-hover-none:hover{box-shadow:none!important}
|
||||
/* Colors */
|
||||
.w3-amber,.w3-hover-amber:hover{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-amber,.w3-hover-amber:hover,.w3-warning{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-aqua,.w3-hover-aqua:hover{color:#000!important;background-color:#00ffff!important}
|
||||
.w3-blue,.w3-hover-blue:hover{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-blue,.w3-hover-blue:hover,.w3-info,.w3-primary{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;background-color:#87CEEB!important}
|
||||
.w3-brown,.w3-hover-brown:hover{color:#fff!important;background-color:#795548!important}
|
||||
.w3-cyan,.w3-hover-cyan:hover{color:#000!important;background-color:#00bcd4!important}
|
||||
@ -216,15 +220,24 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-pink,.w3-hover-pink:hover{color:#fff!important;background-color:#e91e63!important}
|
||||
.w3-purple,.w3-hover-purple:hover{color:#fff!important;background-color:#9c27b0!important}
|
||||
.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;background-color:#673ab7!important}
|
||||
.w3-red,.w3-hover-red:hover{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-red,.w3-hover-red:hover,.w3-danger{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-sand,.w3-hover-sand:hover{color:#000!important;background-color:#fdf5e6!important}
|
||||
.w3-teal,.w3-hover-teal:hover{color:#fff!important;background-color:#009688!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover,.w3-note{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-white,.w3-hover-white:hover{color:#000!important;background-color:#fff!important}
|
||||
.w3-black,.w3-hover-black:hover{color:#fff!important;background-color:#000!important}
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover{color:#000!important;background-color:#9e9e9e!important}
|
||||
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover,.w3-secondary{color:#000!important;background-color:#9e9e9e!important}
|
||||
.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,.w3-hover-light-gray:hover{color:#000!important;background-color:#f1f1f1!important}
|
||||
.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,.w3-hover-dark-gray:hover{color:#fff!important;background-color:#616161!important}
|
||||
|
||||
.w3-asphalt,.w3-hover-asphalt:hover{color:#fff!important;background-color:#343a40!important}.w3-crimson,.w3-hover-crimson:hover{color:#fff!important;background-color:#a20025!important}
|
||||
.w3-cobalt,w3-hover-cobalt:hover{color:#fff!important;background-color:#0050ef!important}
|
||||
.w3-emerald,.w3-hover-emerald:hover,.w3-success{color:#fff!important;background-color:#008a00!important}
|
||||
.w3-olive,.w3-hover-olive:hover{color:#fff!important;background-color:#6d8764!important}
|
||||
.w3-paper,.w3-hover-paper:hover{color:#000!important;background-color:#f8f9fa!important}.w3-sienna,.w3-hover-sienna:hover{color:#fff!important;background-color:#a0522d!important}
|
||||
.w3-taupe,.w3-hover-taupe:hover{color:#fff!important;background-color:#87794e!important}
|
||||
|
||||
.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;background-color:#ffdddd!important}
|
||||
.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;background-color:#ddffdd!important}
|
||||
.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;background-color:#ffffcc!important}
|
||||
|
@ -103,6 +103,23 @@ class TfTabConnectionsElement extends LitElement {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
render_progress(name, value, max) {
|
||||
if (max && value != max) {
|
||||
return html`
|
||||
<div class="w3-theme-d1 w3-small">
|
||||
<div
|
||||
class="w3-container w3-theme-l1"
|
||||
style="width: ${Math.floor(
|
||||
(100.0 * value) / max
|
||||
)}%; text-wrap: nowrap"
|
||||
>
|
||||
${name} ${value} / ${max} (${Math.round((100.0 * value) / max)}%)
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
render_broadcast(connection) {
|
||||
let self = this;
|
||||
return html`
|
||||
@ -154,6 +171,16 @@ class TfTabConnectionsElement extends LitElement {
|
||||
: undefined}
|
||||
${connection.flags.one_shot ? '🔃' : undefined}
|
||||
<tf-user id=${connection.id} .users=${this.users}></tf-user>
|
||||
${this.render_progress(
|
||||
'recv',
|
||||
connection.progress.in.total - connection.progress.in.current,
|
||||
connection.progress.in.total
|
||||
)}
|
||||
${this.render_progress(
|
||||
'send',
|
||||
connection.progress.out.total - connection.progress.out.current,
|
||||
connection.progress.out.total
|
||||
)}
|
||||
${connection.tunnel !== undefined
|
||||
? '🚇'
|
||||
: html`(${connection.host}:${connection.port})`}
|
||||
@ -206,6 +233,21 @@ class TfTabConnectionsElement extends LitElement {
|
||||
});
|
||||
}
|
||||
|
||||
toggle_accordian(id) {
|
||||
let element = this.renderRoot.getElementById(id);
|
||||
element.classList.toggle('w3-hide');
|
||||
}
|
||||
|
||||
valid_connections() {
|
||||
return this.connections.filter((x) => x.tunnel === undefined);
|
||||
}
|
||||
|
||||
valid_broadcasts() {
|
||||
return this.broadcasts
|
||||
.filter((x) => x.address)
|
||||
.filter((x) => this.connections.map((c) => c.id).indexOf(x.pubkey) == -1);
|
||||
}
|
||||
|
||||
render() {
|
||||
let self = this;
|
||||
return html`
|
||||
@ -220,27 +262,33 @@ class TfTabConnectionsElement extends LitElement {
|
||||
>
|
||||
Connect
|
||||
</button>
|
||||
<h2>Broadcasts</h2>
|
||||
<ul class="w3-ul w3-border">
|
||||
${this.broadcasts
|
||||
.filter((x) => x.address)
|
||||
.filter(
|
||||
(x) => self.connections.map((c) => c.id).indexOf(x.pubkey) == -1
|
||||
)
|
||||
.map((x) => self.render_broadcast(x))}
|
||||
<h2
|
||||
class="w3-button w3-block w3-theme-d1"
|
||||
@click=${() => self.toggle_accordian('connections')}
|
||||
>
|
||||
Connections (${this.valid_connections().length})
|
||||
</h2>
|
||||
<ul class="w3-ul w3-border" id="connections">
|
||||
${this.valid_connections().map(
|
||||
(x) => html` <li class="w3-bar">${this.render_connection(x)}</li> `
|
||||
)}
|
||||
</ul>
|
||||
<h2>Connections</h2>
|
||||
<ul class="w3-ul w3-border">
|
||||
${this.connections
|
||||
.filter((x) => x.tunnel === undefined)
|
||||
.map(
|
||||
(x) => html`
|
||||
<li class="w3-bar">${this.render_connection(x)}</li>
|
||||
`
|
||||
)}
|
||||
<h2
|
||||
class="w3-button w3-block w3-theme-d1"
|
||||
@click=${() => self.toggle_accordian('broadcasts')}
|
||||
>
|
||||
Broadcasts (${this.valid_broadcasts().length})
|
||||
</h2>
|
||||
<ul class="w3-ul w3-border w3-hide" id="broadcasts">
|
||||
${this.valid_broadcasts().map((x) => self.render_broadcast(x))}
|
||||
</ul>
|
||||
<h2>Stored Connections</h2>
|
||||
<ul class="w3-ul w3-border">
|
||||
<h2
|
||||
class="w3-button w3-block w3-theme-d1"
|
||||
@click=${() => self.toggle_accordian('stored_connections')}
|
||||
>
|
||||
Stored Connections (${this.stored_connections.length})
|
||||
</h2>
|
||||
<ul class="w3-ul w3-border w3-hide" id="stored_connections">
|
||||
${this.stored_connections.map(
|
||||
(x) => html`
|
||||
<li>
|
||||
@ -267,8 +315,13 @@ class TfTabConnectionsElement extends LitElement {
|
||||
`
|
||||
)}
|
||||
</ul>
|
||||
<h2>Local Accounts</h2>
|
||||
<div class="w3-container">
|
||||
<h2
|
||||
class="w3-button w3-block w3-theme-d1"
|
||||
@click=${() => self.toggle_accordian('local_accounts')}
|
||||
>
|
||||
Local Accounts (${this.identities.length})
|
||||
</h2>
|
||||
<div class="w3-container w3-hide" id="local_accounts">
|
||||
${this.identities.map(
|
||||
(x) =>
|
||||
html`<div
|
||||
|
@ -46,6 +46,63 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
: this.hash.substring(1);
|
||||
}
|
||||
|
||||
async _fetch_related_messages(messages) {
|
||||
let refs = await tfrpc.rpc.query(
|
||||
`
|
||||
WITH
|
||||
news AS (
|
||||
SELECT value AS id FROM json_each(?)
|
||||
)
|
||||
SELECT refs_out.ref AS ref FROM messages_refs refs_out JOIN news ON refs_out.message = news.id
|
||||
UNION
|
||||
SELECT refs_in.message AS ref FROM messages_refs refs_in JOIN news ON refs_in.ref = news.id
|
||||
`,
|
||||
[JSON.stringify(messages.map((x) => x.id))]
|
||||
);
|
||||
let related_messages = await tfrpc.rpc.query(
|
||||
`
|
||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||
FROM messages
|
||||
JOIN json_each(?2) refs ON messages.id = refs.value
|
||||
JOIN json_each(?1) AS following ON messages.author = following.value
|
||||
`,
|
||||
[JSON.stringify(this.following), JSON.stringify(refs.map((x) => x.ref))]
|
||||
);
|
||||
let combined = [].concat(messages, related_messages);
|
||||
let refs2 = await tfrpc.rpc.query(
|
||||
`
|
||||
WITH
|
||||
news AS (
|
||||
SELECT value AS id FROM json_each(?)
|
||||
)
|
||||
SELECT refs_out.ref AS ref FROM messages_refs refs_out JOIN news ON refs_out.message = news.id
|
||||
UNION
|
||||
SELECT refs_in.message AS ref FROM messages_refs refs_in JOIN news ON refs_in.ref = news.id
|
||||
`,
|
||||
[JSON.stringify(combined.map((x) => x.id))]
|
||||
);
|
||||
let t0 = new Date();
|
||||
let result = [].concat(
|
||||
combined,
|
||||
await tfrpc.rpc.query(
|
||||
`
|
||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||
FROM json_each(?2) refs
|
||||
JOIN messages ON messages.id = refs.value
|
||||
JOIN json_each(?1) following ON messages.author = following.value
|
||||
WHERE messages.content ->> 'type' != 'post'
|
||||
`,
|
||||
[
|
||||
JSON.stringify(this.following),
|
||||
JSON.stringify(refs2.map((x) => x.ref)),
|
||||
]
|
||||
)
|
||||
);
|
||||
let t1 = new Date();
|
||||
console.log((t1 - t0) / 1000);
|
||||
return result;
|
||||
}
|
||||
|
||||
async fetch_messages(start_time, end_time) {
|
||||
this.time_loading = [start_time, end_time];
|
||||
let result;
|
||||
@ -107,7 +164,8 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
[this.hash.substring(1)]
|
||||
);
|
||||
} else if (this.hash.startsWith('##')) {
|
||||
result = await tfrpc.rpc.query(
|
||||
let t0 = new Date();
|
||||
let initial_messages = await tfrpc.rpc.query(
|
||||
`
|
||||
WITH
|
||||
all_news AS (
|
||||
@ -120,21 +178,11 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
FROM messages_fts(?5)
|
||||
JOIN messages ON messages.rowid = messages_fts.rowid
|
||||
JOIN json_each(?1) AS following ON messages.author = following.value
|
||||
JOIN json_tree(messages.content, '$.mentions') AS mention ON mention.value = '#' || ?4),
|
||||
news AS (SELECT * FROM all_news
|
||||
WHERE (?2 IS NULL OR all_news.timestamp >= ?2) AND all_news.timestamp < ?3
|
||||
ORDER BY all_news.timestamp DESC LIMIT 20)
|
||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||
FROM news
|
||||
JOIN messages_refs ON news.id = messages_refs.ref
|
||||
JOIN messages ON messages_refs.message = messages.id
|
||||
UNION
|
||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||
FROM news
|
||||
JOIN messages_refs ON news.id = messages_refs.message
|
||||
JOIN messages ON messages_refs.ref = messages.id
|
||||
UNION
|
||||
SELECT TRUE AS is_primary, news.* FROM news
|
||||
JOIN json_tree(messages.content, '$.mentions') AS mention ON mention.value = '#' || ?4
|
||||
)
|
||||
SELECT TRUE AS is_primary, all_news.* FROM all_news
|
||||
WHERE (?2 IS NULL OR all_news.timestamp >= ?2) AND all_news.timestamp < ?3
|
||||
ORDER BY all_news.timestamp DESC LIMIT 20
|
||||
`,
|
||||
[
|
||||
JSON.stringify(this.following),
|
||||
@ -144,6 +192,12 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
'"#' + this.hash.substring(2).replace('"', '""') + '"',
|
||||
]
|
||||
);
|
||||
let t1 = new Date();
|
||||
result = await this._fetch_related_messages(initial_messages);
|
||||
let t2 = new Date();
|
||||
console.log(
|
||||
`load of ${result.length} rows took ${(t2 - t0) / 1000} (${(t1 - t0) / 1000} to find ${initial_messages.length} initial messages, ${(t2 - t1) / 1000} to find ${result.length} total messages) following=${this.following.length} st=${start_time} et=${end_time}`
|
||||
);
|
||||
} else if (this.hash == '#🔐') {
|
||||
result = await tfrpc.rpc.query(
|
||||
`
|
||||
@ -159,33 +213,30 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
);
|
||||
result = (await this.decrypt(result)).filter((x) => x.decrypted);
|
||||
} else {
|
||||
result = await tfrpc.rpc.query(
|
||||
let t0 = new Date();
|
||||
let initial_messages = await tfrpc.rpc.query(
|
||||
`
|
||||
WITH
|
||||
all_news AS (
|
||||
SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||
FROM messages
|
||||
JOIN json_each(?) AS following ON messages.author = following.value
|
||||
WHERE timestamp >= 0 AND timestamp < ?3),
|
||||
),
|
||||
news AS (
|
||||
SELECT * FROM all_news
|
||||
WHERE (?2 IS NULL OR all_news.timestamp >= ?2) AND all_news.timestamp < ?3
|
||||
WHERE all_news.timestamp < ?3 AND (?2 IS NULL OR all_news.timestamp >= ?2)
|
||||
ORDER BY timestamp DESC LIMIT 20
|
||||
)
|
||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||
FROM news
|
||||
JOIN messages_refs ON news.id = messages_refs.ref
|
||||
JOIN messages ON messages_refs.message = messages.id
|
||||
UNION
|
||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||
FROM news
|
||||
JOIN messages_refs ON news.id = messages_refs.message
|
||||
JOIN messages ON messages_refs.ref = messages.id
|
||||
UNION
|
||||
SELECT TRUE AS is_primary, news.* FROM news
|
||||
`,
|
||||
[JSON.stringify(this.following), start_time, end_time]
|
||||
);
|
||||
let t1 = new Date();
|
||||
result = await this._fetch_related_messages(initial_messages);
|
||||
let t2 = new Date();
|
||||
console.log(
|
||||
`load of ${result.length} rows took ${(t2 - t0) / 1000} (${(t1 - t0) / 1000} to find ${initial_messages.length} initial messages, ${(t2 - t1) / 1000} to find ${result.length} total messages) following=${this.following.length} st=${start_time} et=${end_time}`
|
||||
);
|
||||
}
|
||||
this.time_loading = undefined;
|
||||
return result;
|
||||
@ -211,7 +262,11 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
try {
|
||||
let more = [];
|
||||
let last_start_time = this.time_range[0];
|
||||
more = await this.fetch_messages(null, last_start_time);
|
||||
try {
|
||||
more = await this.fetch_messages(null, last_start_time);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
this.update_time_range_from_messages(
|
||||
more.filter((x) => x.timestamp < last_start_time)
|
||||
);
|
||||
@ -311,7 +366,7 @@ class TfTabNewsFeedElement extends LitElement {
|
||||
this.messages = this.merge_messages(this.messages, messages);
|
||||
this.time_loading = undefined;
|
||||
console.log(
|
||||
`loading messages done for ${self.whoami} in ${(new Date() - start_time) / 1000}s`
|
||||
`loading ${messages.length} messages done for ${self.whoami} in ${(new Date() - start_time) / 1000}s`
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -232,6 +232,7 @@ class TfTabNewsElement extends LitElement {
|
||||
class="w3-bar-item"
|
||||
style="max-width: 100%"
|
||||
id=${x.id}
|
||||
fallback_name=${x.host}
|
||||
.users=${this.users}
|
||||
></tf-user>
|
||||
`
|
||||
@ -285,7 +286,7 @@ class TfTabNewsElement extends LitElement {
|
||||
return cache(html`
|
||||
${this.render_sidebar()}
|
||||
<div
|
||||
style="margin-left: 2in; padding: 0px; top: 0; max-height: 100%; overflow: auto"
|
||||
style="margin-left: 2in; padding: 0px; top: 0; max-height: 100%; overflow: auto; contain: layout"
|
||||
id="main"
|
||||
class="w3-main"
|
||||
>
|
||||
|
@ -6,6 +6,7 @@ class TfUserElement extends LitElement {
|
||||
static get properties() {
|
||||
return {
|
||||
id: {type: String},
|
||||
fallback_name: {type: String},
|
||||
users: {type: Object},
|
||||
};
|
||||
}
|
||||
@ -15,6 +16,7 @@ class TfUserElement extends LitElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.id = null;
|
||||
this.fallback_name = null;
|
||||
this.users = {};
|
||||
}
|
||||
|
||||
@ -31,7 +33,7 @@ class TfUserElement extends LitElement {
|
||||
>`;
|
||||
let name = this.users?.[this.id]?.name;
|
||||
name = html`<a target="_top" href=${'#' + this.id}
|
||||
>${name !== undefined ? name : this.id}</a
|
||||
>${name ?? this.fallback_name ?? this.id}</a
|
||||
>`;
|
||||
|
||||
if (user) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "💾",
|
||||
"previous": "&mvGTlWKFR5QM/3nb4fJ2WQq0n/gNKvBmhGDkAvb8ki8=.sha256"
|
||||
"previous": "&tzZFIe7Y54O4sx1QtAPdemkXh+p5qHXSG/dlS7NP6OQ=.sha256"
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ async function query(sql, args) {
|
||||
|
||||
async function get_biggest() {
|
||||
return query(`
|
||||
select author, sum(length(content)) as size from messages group by author order by size desc limit 10;
|
||||
select author, size from messages_stats group by author order by size desc limit 10;
|
||||
`);
|
||||
}
|
||||
|
||||
@ -62,15 +62,14 @@ function nice_size(bytes) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await app.setDocument(
|
||||
'<p style="color: #fff">Finding the top 10 largest feeds...</p>'
|
||||
);
|
||||
let most_follows = await get_most_follows();
|
||||
await app.setDocument('<p style="color: #fff">Analyzing feeds...</p>');
|
||||
let most_follows = get_most_follows();
|
||||
let total = await get_total();
|
||||
let identities = await ssb.getAllIdentities();
|
||||
let following1 = await ssb.following(identities, 1);
|
||||
let following2 = await ssb.following(identities, 2);
|
||||
let biggest = await get_biggest();
|
||||
most_follows = await most_follows;
|
||||
let names = await get_names(
|
||||
[].concat(
|
||||
biggest.map((x) => x.author),
|
||||
@ -94,7 +93,7 @@ async function main() {
|
||||
}
|
||||
let html = `<body style="color: #000; background-color: #ddd">\n
|
||||
<h1>Storage Summary</h1>
|
||||
<h2>Top 10 Accounts by Size</h2>
|
||||
<h2>Top Accounts by Size</h2>
|
||||
<ol>`;
|
||||
for (let item of biggest) {
|
||||
html += `<li>
|
||||
@ -105,7 +104,7 @@ async function main() {
|
||||
}
|
||||
html += `
|
||||
</ol>
|
||||
<h2>Top 10 Accounts by Follows</h2>
|
||||
<h2>Top Accounts by Follows</h2>
|
||||
<ol>`;
|
||||
for (let item of most_follows) {
|
||||
html += `<li>
|
||||
|
5
apps/web.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🕸",
|
||||
"previous": "&n7hu5b8/TsfiG6FDlCRG5nPCrIdCr96+xpIJ/aQT/uM=.sha256"
|
||||
}
|
100
apps/web/app.js
Normal file
@ -0,0 +1,100 @@
|
||||
let g_hash;
|
||||
|
||||
async function query(sql, params) {
|
||||
let results = [];
|
||||
await ssb.sqlAsync(sql, params, function (row) {
|
||||
results.push(row);
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
async function resolve(id) {
|
||||
try {
|
||||
let blob = await ssb.blobGet(id);
|
||||
if (blob) {
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(utf8Decode(blob));
|
||||
} catch {
|
||||
return {id: utf8Decode(blob)};
|
||||
}
|
||||
if (json?.links) {
|
||||
for (let [key, value] of Object.entries(json.links)) {
|
||||
json.links[key] = await resolve(value);
|
||||
}
|
||||
return json;
|
||||
} else {
|
||||
return 'huh?' + json;
|
||||
}
|
||||
} else {
|
||||
return `missing<${id}>`;
|
||||
}
|
||||
} catch (e) {
|
||||
return id + ': ' + e.message;
|
||||
}
|
||||
}
|
||||
|
||||
async function get_names(identities) {
|
||||
return Object.fromEntries(
|
||||
(
|
||||
await query(
|
||||
`
|
||||
SELECT author, name FROM (
|
||||
SELECT
|
||||
messages.author,
|
||||
RANK() OVER (PARTITION BY messages.author ORDER BY messages.sequence DESC) AS author_rank,
|
||||
messages.content ->> 'name' AS name
|
||||
FROM messages
|
||||
JOIN json_each(?) AS identities ON identities.value = messages.author
|
||||
WHERE
|
||||
json_extract(messages.content, '$.type') = 'about' AND
|
||||
content ->> 'about' = messages.author AND name IS NOT NULL)
|
||||
WHERE author_rank = 1
|
||||
`,
|
||||
[JSON.stringify(identities)]
|
||||
)
|
||||
).map((x) => [x.author, x.name])
|
||||
);
|
||||
}
|
||||
|
||||
async function render(hash) {
|
||||
g_hash = hash;
|
||||
if (!hash) {
|
||||
let sites = await query(
|
||||
`
|
||||
SELECT site.author, site.id
|
||||
FROM messages site
|
||||
WHERE site.content ->> 'type' = 'web-init'
|
||||
`,
|
||||
[]
|
||||
);
|
||||
let names = await get_names(sites.map((x) => x.author));
|
||||
if (hash === g_hash) {
|
||||
await app.setDocument(
|
||||
`<ul style="background-color: #ddd">${sites.map((x) => `<li><a target="_top" href="#${encodeURIComponent(x.id)}">${names[x.author] ?? x.author} - ${x.id}</a></li>`).join('\n')}</ul>`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let site_id =
|
||||
hash.charAt(0) == '#'
|
||||
? decodeURIComponent(hash.substring(1))
|
||||
: decodeURIComponent(hash);
|
||||
await app.setDocument(`<html style="margin: 0; padding: 0; width: 100vw; height: 100vh; margin: 0; padding: 0">
|
||||
<body style="display: flex; flex-direction: column; width: 100vw; height: 100vh">
|
||||
<iframe src="${encodeURIComponent(site_id)}/index.html" style="flex: 1 1; border: 0; background-color: #fff"></iframe>
|
||||
</body>
|
||||
</html>`);
|
||||
}
|
||||
}
|
||||
|
||||
core.register('message', async function message_handler(message) {
|
||||
if (message.event == 'hashChange') {
|
||||
await render(message.hash);
|
||||
}
|
||||
});
|
||||
|
||||
async function main() {
|
||||
render(null);
|
||||
}
|
||||
|
||||
main();
|
63
apps/web/handler.js
Normal file
@ -0,0 +1,63 @@
|
||||
async function query(sql, params) {
|
||||
let results = [];
|
||||
await ssb.sqlAsync(sql, params, function (row) {
|
||||
results.push(row);
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
function guess_content_type(name) {
|
||||
if (name.endsWith('.html')) {
|
||||
return 'text/html; charset=UTF-8';
|
||||
} else if (name.endsWith('.js') || name.endsWith('.mjs')) {
|
||||
return 'text/javascript; charset=UTF-8';
|
||||
} else if (name.endsWith('.css')) {
|
||||
return 'text/stylesheet; charset=UTF-8';
|
||||
} else {
|
||||
return 'application/binary';
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
let path = request.path.replaceAll(/(%[0-9a-fA-F]{2})/g, (x) =>
|
||||
String.fromCharCode(parseInt(x.substring(1), 16))
|
||||
);
|
||||
let match = path.match(/^(%.{44}\.sha256)(?:\/)?(.*)$/);
|
||||
|
||||
let content_type = guess_content_type(request.path);
|
||||
let root = await query(
|
||||
`
|
||||
SELECT root.content ->> 'root' AS root
|
||||
FROM messages site
|
||||
JOIN messages root
|
||||
ON site.id = ? AND root.author = site.author AND root.content ->> 'site' = site.id
|
||||
ORDER BY root.sequence DESC LIMIT 1
|
||||
`,
|
||||
[match[1]]
|
||||
);
|
||||
let root_id = root[0]['root'];
|
||||
let last_id = root_id;
|
||||
let blob = await ssb.blobGet(root_id);
|
||||
try {
|
||||
for (let part of match[2]?.split('/')) {
|
||||
let dir = JSON.parse(utf8Decode(blob));
|
||||
last_id = dir?.links[part];
|
||||
blob = await ssb.blobGet(dir?.links[part]);
|
||||
content_type = guess_content_type(part);
|
||||
}
|
||||
} catch {}
|
||||
|
||||
respond({
|
||||
status_code: 200,
|
||||
data: blob ? utf8Decode(blob) : `${last_id} not found`,
|
||||
content_type: content_type,
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(function (e) {
|
||||
respond({
|
||||
status_code: 200,
|
||||
data: `${e.message}\n${e.stack}`,
|
||||
content_type: 'text/plain',
|
||||
});
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
/* W3.CSS 4.15 December 2020 by Jan Egil and Borge Refsnes */
|
||||
/* W3.CSS 5.01 March 14 2025 by Jan Egil and Borge Refsnes */
|
||||
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
|
||||
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
|
||||
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
||||
@ -108,6 +108,10 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px}
|
||||
.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px}
|
||||
.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px}
|
||||
|
||||
.w3-grid{display:grid}.w3-grid-padding{display:grid;gap:16px}.w3-flex{display:flex}
|
||||
.w3-text-center{text-align:center}.w3-text-bold,.w3-bold{font-weight:bold}.w3-text-italic,.w3-italic{font-style:italic}
|
||||
|
||||
.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px}
|
||||
.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word}
|
||||
.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%}
|
||||
@ -149,9 +153,9 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-transparent,.w3-hover-none:hover{background-color:transparent!important}
|
||||
.w3-hover-none:hover{box-shadow:none!important}
|
||||
/* Colors */
|
||||
.w3-amber,.w3-hover-amber:hover{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-amber,.w3-hover-amber:hover,.w3-warning{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-aqua,.w3-hover-aqua:hover{color:#000!important;background-color:#00ffff!important}
|
||||
.w3-blue,.w3-hover-blue:hover{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-blue,.w3-hover-blue:hover,.w3-info,.w3-primary{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;background-color:#87CEEB!important}
|
||||
.w3-brown,.w3-hover-brown:hover{color:#fff!important;background-color:#795548!important}
|
||||
.w3-cyan,.w3-hover-cyan:hover{color:#000!important;background-color:#00bcd4!important}
|
||||
@ -166,15 +170,24 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-pink,.w3-hover-pink:hover{color:#fff!important;background-color:#e91e63!important}
|
||||
.w3-purple,.w3-hover-purple:hover{color:#fff!important;background-color:#9c27b0!important}
|
||||
.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;background-color:#673ab7!important}
|
||||
.w3-red,.w3-hover-red:hover{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-red,.w3-hover-red:hover,.w3-danger{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-sand,.w3-hover-sand:hover{color:#000!important;background-color:#fdf5e6!important}
|
||||
.w3-teal,.w3-hover-teal:hover{color:#fff!important;background-color:#009688!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover,.w3-note{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-white,.w3-hover-white:hover{color:#000!important;background-color:#fff!important}
|
||||
.w3-black,.w3-hover-black:hover{color:#fff!important;background-color:#000!important}
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover{color:#000!important;background-color:#9e9e9e!important}
|
||||
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover,.w3-secondary{color:#000!important;background-color:#9e9e9e!important}
|
||||
.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,.w3-hover-light-gray:hover{color:#000!important;background-color:#f1f1f1!important}
|
||||
.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,.w3-hover-dark-gray:hover{color:#fff!important;background-color:#616161!important}
|
||||
|
||||
.w3-asphalt,.w3-hover-asphalt:hover{color:#fff!important;background-color:#343a40!important}.w3-crimson,.w3-hover-crimson:hover{color:#fff!important;background-color:#a20025!important}
|
||||
.w3-cobalt,w3-hover-cobalt:hover{color:#fff!important;background-color:#0050ef!important}
|
||||
.w3-emerald,.w3-hover-emerald:hover,.w3-success{color:#fff!important;background-color:#008a00!important}
|
||||
.w3-olive,.w3-hover-olive:hover{color:#fff!important;background-color:#6d8764!important}
|
||||
.w3-paper,.w3-hover-paper:hover{color:#000!important;background-color:#f8f9fa!important}.w3-sienna,.w3-hover-sienna:hover{color:#fff!important;background-color:#a0522d!important}
|
||||
.w3-taupe,.w3-hover-taupe:hover{color:#fff!important;background-color:#87794e!important}
|
||||
|
||||
.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;background-color:#ffdddd!important}
|
||||
.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;background-color:#ddffdd!important}
|
||||
.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;background-color:#ffffcc!important}
|
||||
@ -232,4 +245,4 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-border-light-grey,.w3-hover-border-light-grey:hover,.w3-border-light-gray,.w3-hover-border-light-gray:hover{border-color:#f1f1f1!important}
|
||||
.w3-border-dark-grey,.w3-hover-border-dark-grey:hover,.w3-border-dark-gray,.w3-hover-border-dark-gray:hover{border-color:#616161!important}
|
||||
.w3-border-pale-red,.w3-hover-border-pale-red:hover{border-color:#ffe7e7!important}.w3-border-pale-green,.w3-hover-border-pale-green:hover{border-color:#e7ffe7!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
|
42
apps/wiki/lit-all.min.js
vendored
108
core/app.js
@ -1,53 +1,26 @@
|
||||
import * as core from './core.js';
|
||||
|
||||
let g_next_id = 1;
|
||||
let g_calls = {};
|
||||
|
||||
let gSessionIndex = 0;
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @returns
|
||||
*/
|
||||
function makeSessionId() {
|
||||
return 'session_' + (gSessionIndex++).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @returns
|
||||
*/
|
||||
function App() {
|
||||
this._on_output = null;
|
||||
this._send_queue = [];
|
||||
this.calls = {};
|
||||
this._next_call_id = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} callback
|
||||
*/
|
||||
App.prototype.readOutput = function (callback) {
|
||||
this._on_output = callback;
|
||||
};
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} api
|
||||
* @returns
|
||||
*/
|
||||
App.prototype.makeFunction = function (api) {
|
||||
let self = this;
|
||||
let result = function () {
|
||||
let id = g_next_id++;
|
||||
while (!id || g_calls[id]) {
|
||||
id = g_next_id++;
|
||||
let id = self._next_call_id++;
|
||||
while (!id || self.calls[id]) {
|
||||
id = self._next_call_id++;
|
||||
}
|
||||
let promise = new Promise(function (resolve, reject) {
|
||||
g_calls[id] = {resolve: resolve, reject: reject};
|
||||
self.calls[id] = {resolve: resolve, reject: reject};
|
||||
});
|
||||
let message = {
|
||||
message: 'tfrpc',
|
||||
action: 'tfrpc',
|
||||
method: api[0],
|
||||
params: [...arguments],
|
||||
id: id,
|
||||
@ -59,10 +32,6 @@ App.prototype.makeFunction = function (api) {
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} message
|
||||
*/
|
||||
App.prototype.send = function (message) {
|
||||
if (this._send_queue) {
|
||||
if (this._on_output) {
|
||||
@ -77,11 +46,6 @@ App.prototype.send = function (message) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} request
|
||||
* @param {*} response
|
||||
*/
|
||||
exports.app_socket = async function socket(request, response) {
|
||||
let process;
|
||||
let options = {};
|
||||
@ -102,10 +66,16 @@ exports.app_socket = async function socket(request, response) {
|
||||
try {
|
||||
message = JSON.parse(event.data);
|
||||
} catch (error) {
|
||||
print('ERROR', error, event.data, event.data.length, event.opCode);
|
||||
print(
|
||||
'WebSocket error:',
|
||||
error,
|
||||
event.data,
|
||||
event.data.length,
|
||||
event.opCode
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (message.action == 'hello') {
|
||||
if (!process && message.action == 'hello') {
|
||||
let packageOwner;
|
||||
let packageName;
|
||||
let blobId;
|
||||
@ -122,7 +92,7 @@ exports.app_socket = async function socket(request, response) {
|
||||
if (!blobId) {
|
||||
response.send(
|
||||
JSON.stringify({
|
||||
message: 'tfrpc',
|
||||
action: 'tfrpc',
|
||||
method: 'error',
|
||||
params: [message.path + ' not found'],
|
||||
id: -1,
|
||||
@ -163,7 +133,7 @@ exports.app_socket = async function socket(request, response) {
|
||||
options.packageOwner = packageOwner;
|
||||
options.packageName = packageName;
|
||||
options.url = message.url;
|
||||
let sessionId = makeSessionId();
|
||||
let sessionId = 'session_' + (gSessionIndex++).toString();
|
||||
if (blobId) {
|
||||
if (message.edit_only) {
|
||||
response.send(
|
||||
@ -175,9 +145,24 @@ exports.app_socket = async function socket(request, response) {
|
||||
}
|
||||
}
|
||||
if (process) {
|
||||
process.app.readOutput(function (message) {
|
||||
process.client_api.tfrpc = function (message) {
|
||||
if (message.id) {
|
||||
let calls = process?.app?.calls;
|
||||
if (calls) {
|
||||
let call = calls[message.id];
|
||||
if (call) {
|
||||
if (message.error !== undefined) {
|
||||
call.reject(message.error);
|
||||
} else {
|
||||
call.resolve(message.result);
|
||||
}
|
||||
delete calls[message.id];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
process.app._on_output = (message) =>
|
||||
response.send(JSON.stringify(message), 0x1);
|
||||
});
|
||||
process.app.send();
|
||||
}
|
||||
|
||||
@ -206,26 +191,13 @@ exports.app_socket = async function socket(request, response) {
|
||||
if (process && process.timeout > 0) {
|
||||
setTimeout(ping, process.timeout);
|
||||
}
|
||||
} else if (message.action == 'resetPermission') {
|
||||
if (process) {
|
||||
process.resetPermission(message.permission);
|
||||
}
|
||||
} else if (message.action == 'setActiveIdentity') {
|
||||
process.setActiveIdentity(message.identity);
|
||||
} else if (message.action == 'createIdentity') {
|
||||
await process.createIdentity();
|
||||
} else if (message.message == 'tfrpc') {
|
||||
if (message.id && g_calls[message.id]) {
|
||||
if (message.error !== undefined) {
|
||||
g_calls[message.id].reject(message.error);
|
||||
} else {
|
||||
g_calls[message.id].resolve(message.result);
|
||||
}
|
||||
delete g_calls[message.id];
|
||||
}
|
||||
} else {
|
||||
if (process && process.eventHandlers['message']) {
|
||||
await core.invoke(process.eventHandlers['message'], [message]);
|
||||
if (process) {
|
||||
if (process.client_api[message.action]) {
|
||||
process.client_api[message.action](message);
|
||||
} else if (process.eventHandlers['message']) {
|
||||
await core.invoke(process.eventHandlers['message'], [message]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event.opCode == 0x8) {
|
||||
|
@ -266,6 +266,7 @@ class TfNavigationElement extends LitElement {
|
||||
<button
|
||||
@click=${() => this.reset_permission(key)}
|
||||
class="w3-button w3-red"
|
||||
id=${'permission_reset:' + key}
|
||||
>
|
||||
Reset
|
||||
</button>
|
||||
@ -275,6 +276,7 @@ class TfNavigationElement extends LitElement {
|
||||
<button
|
||||
@click=${() => (this.show_permissions = false)}
|
||||
class="w3-button w3-blue"
|
||||
id="permissions_close"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
@ -1325,7 +1327,7 @@ function _receive_websocket_message(message) {
|
||||
line.append(key, message.stats[key]);
|
||||
}
|
||||
}
|
||||
} else if (message && message.message === 'tfrpc' && message.method) {
|
||||
} else if (message && message.action === 'tfrpc' && message.method) {
|
||||
let api = k_api[message.method];
|
||||
let id = message.id;
|
||||
let params = message.params;
|
||||
@ -1333,14 +1335,14 @@ function _receive_websocket_message(message) {
|
||||
Promise.resolve(api.func(...params))
|
||||
.then(function (result) {
|
||||
send({
|
||||
message: 'tfrpc',
|
||||
action: 'tfrpc',
|
||||
id: id,
|
||||
result: result,
|
||||
});
|
||||
})
|
||||
.catch(function (error) {
|
||||
send({
|
||||
message: 'tfrpc',
|
||||
action: 'tfrpc',
|
||||
id: id,
|
||||
error: error,
|
||||
});
|
||||
|
124
core/core.js
@ -3,31 +3,22 @@ import * as http from './http.js';
|
||||
|
||||
let gProcesses = {};
|
||||
let gStatsTimer = false;
|
||||
let kPingInterval = 60 * 1000;
|
||||
let g_handler_index = 0;
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} out
|
||||
* @param {*} error
|
||||
*/
|
||||
function printError(out, error) {
|
||||
const k_ping_interval = 60 * 1000;
|
||||
|
||||
function printError(error) {
|
||||
if (error.stackTrace) {
|
||||
out.print(error.fileName + ':' + error.lineNumber + ': ' + error.message);
|
||||
out.print(error.stackTrace);
|
||||
print(error.fileName + ':' + error.lineNumber + ': ' + error.message);
|
||||
print(error.stackTrace);
|
||||
} else {
|
||||
for (let [k, v] of Object.entries(error)) {
|
||||
out.print(k, v);
|
||||
print(k, v);
|
||||
}
|
||||
out.print(error.toString());
|
||||
print(error.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} handlers
|
||||
* @param {*} argv
|
||||
* @returns
|
||||
*/
|
||||
function invoke(handlers, argv) {
|
||||
let promises = [];
|
||||
if (handlers) {
|
||||
@ -48,12 +39,6 @@ function invoke(handlers, argv) {
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} eventName
|
||||
* @param {*} argv
|
||||
* @returns
|
||||
*/
|
||||
function broadcastEvent(eventName, argv) {
|
||||
let promises = [];
|
||||
for (let process of Object.values(gProcesses)) {
|
||||
@ -64,11 +49,6 @@ function broadcastEvent(eventName, argv) {
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} message
|
||||
* @returns
|
||||
*/
|
||||
function broadcast(message) {
|
||||
let sender = this;
|
||||
let promises = [];
|
||||
@ -85,12 +65,6 @@ function broadcast(message) {
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {String} eventName
|
||||
* @param {*} argv
|
||||
* @returns
|
||||
*/
|
||||
function broadcastAppEventToUser(
|
||||
user,
|
||||
packageOwner,
|
||||
@ -113,12 +87,6 @@ function broadcastAppEventToUser(
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} caller
|
||||
* @param {*} process
|
||||
* @returns
|
||||
*/
|
||||
function getUser(caller, process) {
|
||||
return {
|
||||
key: process.key,
|
||||
@ -129,12 +97,6 @@ function getUser(caller, process) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} user
|
||||
* @param {*} process
|
||||
* @returns
|
||||
*/
|
||||
async function getApps(user, process) {
|
||||
if (
|
||||
process.credentials &&
|
||||
@ -161,28 +123,13 @@ async function getApps(user, process) {
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} from
|
||||
* @param {*} to
|
||||
* @param {*} message
|
||||
* @returns
|
||||
*/
|
||||
function postMessageInternal(from, to, message) {
|
||||
if (to.eventHandlers['message']) {
|
||||
return invoke(to.eventHandlers['message'], [getUser(from, from), message]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} blobId
|
||||
* @param {*} key
|
||||
* @param {*} options
|
||||
* @returns
|
||||
*/
|
||||
async function getProcessBlob(blobId, key, options) {
|
||||
// TODO(tasiaiso): break this down ?
|
||||
let process = gProcesses[key];
|
||||
if (!process && !(options && 'create' in options && !options.create)) {
|
||||
let resolveReady;
|
||||
@ -201,7 +148,7 @@ async function getProcessBlob(blobId, key, options) {
|
||||
}
|
||||
process.lastActive = Date.now();
|
||||
process.lastPing = null;
|
||||
process.timeout = kPingInterval;
|
||||
process.timeout = k_ping_interval;
|
||||
process.ready = new Promise(function (resolve, reject) {
|
||||
resolveReady = resolve;
|
||||
rejectReady = reject;
|
||||
@ -461,10 +408,10 @@ async function getProcessBlob(blobId, key, options) {
|
||||
if (process.app) {
|
||||
process.app.makeFunction(['error'])(error);
|
||||
} else {
|
||||
printError({print: print}, error);
|
||||
printError(error);
|
||||
}
|
||||
} catch (e) {
|
||||
printError({print: print}, error);
|
||||
printError(error);
|
||||
}
|
||||
};
|
||||
imports.ssb = Object.fromEntries(
|
||||
@ -649,17 +596,26 @@ async function getProcessBlob(blobId, key, options) {
|
||||
permissions: await imports.core.permissionsGranted(),
|
||||
});
|
||||
};
|
||||
process.resetPermission = async function resetPermission(permission) {
|
||||
let user = process?.credentials?.session?.name;
|
||||
await ssb.setUserPermission(
|
||||
user,
|
||||
options?.packageOwner,
|
||||
options?.packageName,
|
||||
permission,
|
||||
undefined
|
||||
);
|
||||
return process.sendPermissions();
|
||||
process.client_api = {
|
||||
createIdentity: function () {
|
||||
return process.createIdentity();
|
||||
},
|
||||
resetPermission: async function resetPermission(message) {
|
||||
let user = process?.credentials?.session?.name;
|
||||
await ssb.setUserPermission(
|
||||
user,
|
||||
options?.packageOwner,
|
||||
options?.packageName,
|
||||
message.permission,
|
||||
undefined
|
||||
);
|
||||
return process.sendPermissions();
|
||||
},
|
||||
setActiveIdentity: function setActiveIdentity(message) {
|
||||
return process.setActiveIdentity(message.identity);
|
||||
},
|
||||
};
|
||||
ssb.registerImports(imports, process);
|
||||
process.task.setImports(imports);
|
||||
process.task.activate();
|
||||
let source = await ssb.blobGet(blobId);
|
||||
@ -686,7 +642,7 @@ async function getProcessBlob(blobId, key, options) {
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
printError({print: print}, e);
|
||||
printError(e);
|
||||
}
|
||||
broadcastEvent('onSessionBegin', [getUser(process, process)]);
|
||||
if (process.app) {
|
||||
@ -700,14 +656,10 @@ async function getProcessBlob(blobId, key, options) {
|
||||
sendStats();
|
||||
}
|
||||
} catch (error) {
|
||||
if (process.app) {
|
||||
if (process?.task?.onError) {
|
||||
process.task.onError(error);
|
||||
} else {
|
||||
printError({print: print}, error);
|
||||
}
|
||||
if (process?.app && process?.task?.onError) {
|
||||
process.task.onError(error);
|
||||
} else {
|
||||
printError({print: print}, error);
|
||||
printError(error);
|
||||
}
|
||||
rejectReady(error);
|
||||
}
|
||||
@ -727,9 +679,6 @@ ssb.addEventListener('connections', function () {
|
||||
broadcastEvent('onConnectionsChanged', []);
|
||||
});
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
*/
|
||||
async function loadSettings() {
|
||||
let data = {};
|
||||
try {
|
||||
@ -748,9 +697,6 @@ async function loadSettings() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
*/
|
||||
function sendStats() {
|
||||
let apps = Object.values(gProcesses)
|
||||
.filter((process) => process.app)
|
||||
@ -766,8 +712,6 @@ function sendStats() {
|
||||
}
|
||||
}
|
||||
|
||||
let g_handler_index = 0;
|
||||
|
||||
exports.callAppHandler = async function callAppHandler(
|
||||
response,
|
||||
app_blob_id,
|
||||
|
27
core/w3.css
@ -1,4 +1,4 @@
|
||||
/* W3.CSS 4.15 December 2020 by Jan Egil and Borge Refsnes */
|
||||
/* W3.CSS 5.01 March 14 2025 by Jan Egil and Borge Refsnes */
|
||||
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
|
||||
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
|
||||
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
|
||||
@ -108,6 +108,10 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px}
|
||||
.w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px}
|
||||
.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px}
|
||||
|
||||
.w3-grid{display:grid}.w3-grid-padding{display:grid;gap:16px}.w3-flex{display:flex}
|
||||
.w3-text-center{text-align:center}.w3-text-bold,.w3-bold{font-weight:bold}.w3-text-italic,.w3-italic{font-style:italic}
|
||||
|
||||
.w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px}
|
||||
.w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word}
|
||||
.w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%}
|
||||
@ -149,9 +153,9 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-transparent,.w3-hover-none:hover{background-color:transparent!important}
|
||||
.w3-hover-none:hover{box-shadow:none!important}
|
||||
/* Colors */
|
||||
.w3-amber,.w3-hover-amber:hover{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-amber,.w3-hover-amber:hover,.w3-warning{color:#000!important;background-color:#ffc107!important}
|
||||
.w3-aqua,.w3-hover-aqua:hover{color:#000!important;background-color:#00ffff!important}
|
||||
.w3-blue,.w3-hover-blue:hover{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-blue,.w3-hover-blue:hover,.w3-info,.w3-primary{color:#fff!important;background-color:#2196F3!important}
|
||||
.w3-light-blue,.w3-hover-light-blue:hover{color:#000!important;background-color:#87CEEB!important}
|
||||
.w3-brown,.w3-hover-brown:hover{color:#fff!important;background-color:#795548!important}
|
||||
.w3-cyan,.w3-hover-cyan:hover{color:#000!important;background-color:#00bcd4!important}
|
||||
@ -166,15 +170,24 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-pink,.w3-hover-pink:hover{color:#fff!important;background-color:#e91e63!important}
|
||||
.w3-purple,.w3-hover-purple:hover{color:#fff!important;background-color:#9c27b0!important}
|
||||
.w3-deep-purple,.w3-hover-deep-purple:hover{color:#fff!important;background-color:#673ab7!important}
|
||||
.w3-red,.w3-hover-red:hover{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-red,.w3-hover-red:hover,.w3-danger{color:#fff!important;background-color:#f44336!important}
|
||||
.w3-sand,.w3-hover-sand:hover{color:#000!important;background-color:#fdf5e6!important}
|
||||
.w3-teal,.w3-hover-teal:hover{color:#fff!important;background-color:#009688!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-yellow,.w3-hover-yellow:hover,.w3-note{color:#000!important;background-color:#ffeb3b!important}
|
||||
.w3-white,.w3-hover-white:hover{color:#000!important;background-color:#fff!important}
|
||||
.w3-black,.w3-hover-black:hover{color:#fff!important;background-color:#000!important}
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover{color:#000!important;background-color:#9e9e9e!important}
|
||||
|
||||
.w3-grey,.w3-hover-grey:hover,.w3-gray,.w3-hover-gray:hover,.w3-secondary{color:#000!important;background-color:#9e9e9e!important}
|
||||
.w3-light-grey,.w3-hover-light-grey:hover,.w3-light-gray,.w3-hover-light-gray:hover{color:#000!important;background-color:#f1f1f1!important}
|
||||
.w3-dark-grey,.w3-hover-dark-grey:hover,.w3-dark-gray,.w3-hover-dark-gray:hover{color:#fff!important;background-color:#616161!important}
|
||||
|
||||
.w3-asphalt,.w3-hover-asphalt:hover{color:#fff!important;background-color:#343a40!important}.w3-crimson,.w3-hover-crimson:hover{color:#fff!important;background-color:#a20025!important}
|
||||
.w3-cobalt,w3-hover-cobalt:hover{color:#fff!important;background-color:#0050ef!important}
|
||||
.w3-emerald,.w3-hover-emerald:hover,.w3-success{color:#fff!important;background-color:#008a00!important}
|
||||
.w3-olive,.w3-hover-olive:hover{color:#fff!important;background-color:#6d8764!important}
|
||||
.w3-paper,.w3-hover-paper:hover{color:#000!important;background-color:#f8f9fa!important}.w3-sienna,.w3-hover-sienna:hover{color:#fff!important;background-color:#a0522d!important}
|
||||
.w3-taupe,.w3-hover-taupe:hover{color:#fff!important;background-color:#87794e!important}
|
||||
|
||||
.w3-pale-red,.w3-hover-pale-red:hover{color:#000!important;background-color:#ffdddd!important}
|
||||
.w3-pale-green,.w3-hover-pale-green:hover{color:#000!important;background-color:#ddffdd!important}
|
||||
.w3-pale-yellow,.w3-hover-pale-yellow:hover{color:#000!important;background-color:#ffffcc!important}
|
||||
@ -232,4 +245,4 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0}
|
||||
.w3-border-light-grey,.w3-hover-border-light-grey:hover,.w3-border-light-gray,.w3-hover-border-light-gray:hover{border-color:#f1f1f1!important}
|
||||
.w3-border-dark-grey,.w3-hover-border-dark-grey:hover,.w3-border-dark-gray,.w3-hover-border-dark-gray:hover{border-color:#616161!important}
|
||||
.w3-border-pale-red,.w3-hover-border-pale-red:hover{border-color:#ffe7e7!important}.w3-border-pale-green,.w3-hover-border-pale-green:hover{border-color:#e7ffe7!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
.w3-border-pale-yellow,.w3-hover-border-pale-yellow:hover{border-color:#ffffcc!important}.w3-border-pale-blue,.w3-hover-border-pale-blue:hover{border-color:#e7ffff!important}
|
||||
|
@ -25,14 +25,14 @@
|
||||
}:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "tildefriends";
|
||||
version = "0.0.27.1";
|
||||
version = "0.0.29";
|
||||
|
||||
src = pkgs.fetchFromGitea {
|
||||
domain = "dev.tildefriends.net";
|
||||
owner = "cory";
|
||||
repo = "tildefriends";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-3t1m9ZomQF3DteWyALJWrnCq0EAROEK8shKXh6Ao38c=";
|
||||
hash = "sha256-bQXFpocOYOlFmVj9OZeQhNrgFuTJ8sx2RSw1tgmelOM=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
|
2
deps/c-ares
vendored
2
deps/codemirror/cm6.js
vendored
227
deps/codemirror_src/package-lock.json
generated
vendored
@ -30,9 +30,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/commands": {
|
||||
"version": "6.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.8.0.tgz",
|
||||
"integrity": "sha512-q8VPEFaEP4ikSlt6ZxjB3zW72+7osfAYW9i8Zu943uqbKuz6utc1+F170hyLUCUltXORjQXRyYQNfkckzA/bPQ==",
|
||||
"version": "6.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.8.1.tgz",
|
||||
"integrity": "sha512-KlGVYufHMQzxbdQONiLyGQDUW0itrLZwq3CcY7xpv9ZLRHqzkBSoteocBHtMCoY7/Ci4xhzSrToIeLg7FxHuaw==",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.4.0",
|
||||
@ -92,9 +92,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/language": {
|
||||
"version": "6.10.8",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.10.8.tgz",
|
||||
"integrity": "sha512-wcP8XPPhDH2vTqf181U8MbZnW+tDyPYy0UzVOa+oHORjyT+mhhom9vBd7dApJwoDz9Nb/a8kHjJIsuA/t8vNFw==",
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.11.0.tgz",
|
||||
"integrity": "sha512-A7+f++LodNNc1wGgoRDTt78cOwWm9KVezApgjOMp1W4hM0898nsqBXwF+sbePE7ZRcjN7Sa1Z5m2oN27XkmEjQ==",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.23.0",
|
||||
@ -105,9 +105,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lint": {
|
||||
"version": "6.8.4",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.8.4.tgz",
|
||||
"integrity": "sha512-u4q7PnZlJUojeRe8FJa/njJcMctISGgPQ4PnWsd9268R4ZTtU+tfFYmwkBvgcrK2+QQ8tYFVALVb5fVJykKc5A==",
|
||||
"version": "6.8.5",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.8.5.tgz",
|
||||
"integrity": "sha512-s3n3KisH7dx3vsoeGMxsbRAgKe4O1vbrnKBClm99PU0fWxmxsx5rR2PfqQgIt+2MMJBHbiJ5rfIdLYfB9NNvsA==",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.35.0",
|
||||
@ -115,9 +115,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/search": {
|
||||
"version": "6.5.9",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.5.9.tgz",
|
||||
"integrity": "sha512-7DdQ9aaZMMxuWB1u6IIFWWuK9NocVZwvo4nG8QjJTS6oZGvteoLSiXw3EbVZVlO08Ri2ltO89JVInMpfcJxhtg==",
|
||||
"version": "6.5.10",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.5.10.tgz",
|
||||
"integrity": "sha512-RMdPdmsrUf53pb2VwflKGHEe1XVM07hI7vV2ntgw1dmqhimpatSJKva4VA9h4TLUDOD4EIF02201oZurpnEFsg==",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
@ -144,9 +144,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/view": {
|
||||
"version": "6.36.2",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.36.2.tgz",
|
||||
"integrity": "sha512-DZ6ONbs8qdJK0fdN7AB82CgI6tYXf4HWk1wSVa0+9bhVznCuuvhQtX8bFBoy3dv8rZSQqUd8GvhVAcielcidrA==",
|
||||
"version": "6.36.5",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.36.5.tgz",
|
||||
"integrity": "sha512-cd+FZEUlu3GQCYnguYm3EkhJ8KJVisqqUsCOKedBoAt/d9c76JUUap6U0UrpElln5k6VyrEOYliMuDAKIeDQLg==",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.5.0",
|
||||
"style-mod": "^4.1.0",
|
||||
@ -217,9 +217,9 @@
|
||||
"integrity": "sha512-w7ojc8ejBqr2REPsWxJjrMFsA/ysDCFICn8zEOR9mrqzOu2amhITYuLD8ag6XZf0CFXDrhKqw7+tW8cX66NaDA=="
|
||||
},
|
||||
"node_modules/@lezer/css": {
|
||||
"version": "1.1.10",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.1.10.tgz",
|
||||
"integrity": "sha512-V5/89eDapjeAkWPBpWEfQjZ1Hag3aYUUJOL8213X0dFRuXJ4BXa5NKl9USzOnaLod4AOpmVCkduir2oKwZYZtg==",
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.1.11.tgz",
|
||||
"integrity": "sha512-FuAnusbLBl1SEAtfN8NdShxYJiESKw9LAFysfea1T96jD3ydBn12oYjaSG1a04BQRIUd93/0D8e5CV1cUMkmQg==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
@ -245,9 +245,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/javascript": {
|
||||
"version": "1.4.21",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.21.tgz",
|
||||
"integrity": "sha512-lL+1fcuxWYPURMM/oFZLEDm0XuLN128QPV+VuGtKpeaOGdcl9F2LYC3nh1S9LkPqx9M0mndZFdXCipNAZpzIkQ==",
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.1.tgz",
|
||||
"integrity": "sha512-ATOImjeVJuvgm3JQ/bpo2Tmv55HSScE2MTPnKRMRIPx2cLhHGyX2VnqpHhtIV1tVzIjZDbcWQm+NCTF40ggZVw==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.1.3",
|
||||
@ -344,9 +344,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.7.tgz",
|
||||
"integrity": "sha512-l6CtzHYo8D2TQ3J7qJNpp3Q1Iye56ssIAtqbM2H8axxCEEwvN7o8Ze9PuIapbxFL3OHrJU2JBX6FIIVnP/rYyw==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.0.tgz",
|
||||
"integrity": "sha512-+Fbls/diZ0RDerhE8kyC6hjADCXA1K4yVNlH0EYfd2XjyH0UGgzaQ8MlT0pCXAThfxv3QUAczHaL+qSv1E4/Cg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@ -356,9 +356,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm64": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.7.tgz",
|
||||
"integrity": "sha512-KvyJpFUueUnSp53zhAa293QBYqwm94TgYTIfXyOTtidhm5V0LbLCJQRGkQClYiX3FXDQGSvPxOTD/6rPStMMDg==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.40.0.tgz",
|
||||
"integrity": "sha512-PPA6aEEsTPRz+/4xxAmaoWDqh67N7wFbgFUJGMnanCFs0TV99M0M8QhhaSCks+n6EbQoFvLQgYOGXxlMGQe/6w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@ -368,9 +368,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-arm64": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.7.tgz",
|
||||
"integrity": "sha512-jq87CjmgL9YIKvs8ybtIC98s/M3HdbqXhllcy9EdLV0yMg1DpxES2gr65nNy7ObNo/vZ/MrOTxt0bE5LinL6mA==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.40.0.tgz",
|
||||
"integrity": "sha512-GwYOcOakYHdfnjjKwqpTGgn5a6cUX7+Ra2HeNj/GdXvO2VJOOXCiYYlRFU4CubFM67EhbmzLOmACKEfvp3J1kQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@ -380,9 +380,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-x64": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.7.tgz",
|
||||
"integrity": "sha512-rSI/m8OxBjsdnMMg0WEetu/w+LhLAcCDEiL66lmMX4R3oaml3eXz3Dxfvrxs1FbzPbJMaItQiksyMfv1hoIxnA==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.40.0.tgz",
|
||||
"integrity": "sha512-CoLEGJ+2eheqD9KBSxmma6ld01czS52Iw0e2qMZNpPDlf7Z9mj8xmMemxEucinev4LgHalDPczMyxzbq+Q+EtA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@ -392,9 +392,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-arm64": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.7.tgz",
|
||||
"integrity": "sha512-oIoJRy3ZrdsXpFuWDtzsOOa/E/RbRWXVokpVrNnkS7npz8GEG++E1gYbzhYxhxHbO2om1T26BZjVmdIoyN2WtA==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.40.0.tgz",
|
||||
"integrity": "sha512-r7yGiS4HN/kibvESzmrOB/PxKMhPTlz+FcGvoUIKYoTyGd5toHp48g1uZy1o1xQvybwwpqpe010JrcGG2s5nkg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@ -404,9 +404,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-x64": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.7.tgz",
|
||||
"integrity": "sha512-X++QSLm4NZfZ3VXGVwyHdRf58IBbCu9ammgJxuWZYLX0du6kZvdNqPwrjvDfwmi6wFdvfZ/s6K7ia0E5kI7m8Q==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.40.0.tgz",
|
||||
"integrity": "sha512-mVDxzlf0oLzV3oZOr0SMJ0lSDd3xC4CmnWJ8Val8isp9jRGl5Dq//LLDSPFrasS7pSm6m5xAcKaw3sHXhBjoRw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@ -416,9 +416,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.7.tgz",
|
||||
"integrity": "sha512-Z0TzhrsNqukTz3ISzrvyshQpFnFRfLunYiXxlCRvcrb3nvC5rVKI+ZXPFG/Aa4jhQa1gHgH3A0exHaRRN4VmdQ==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.40.0.tgz",
|
||||
"integrity": "sha512-y/qUMOpJxBMy8xCXD++jeu8t7kzjlOCkoxxajL58G62PJGBZVl/Gwpm7JK9+YvlB701rcQTzjUZ1JgUoPTnoQA==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@ -428,9 +428,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.7.tgz",
|
||||
"integrity": "sha512-nkznpyXekFAbvFBKBy4nNppSgneB1wwG1yx/hujN3wRnhnkrYVugMTCBXED4+Ni6thoWfQuHNYbFjgGH0MBXtw==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.40.0.tgz",
|
||||
"integrity": "sha512-GoCsPibtVdJFPv/BOIvBKO/XmwZLwaNWdyD8TKlXuqp0veo2sHE+A/vpMQ5iSArRUz/uaoj4h5S6Pn0+PdhRjg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@ -440,9 +440,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.7.tgz",
|
||||
"integrity": "sha512-KCjlUkcKs6PjOcxolqrXglBDcfCuUCTVlX5BgzgoJHw+1rWH1MCkETLkLe5iLLS9dP5gKC7mp3y6x8c1oGBUtA==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.40.0.tgz",
|
||||
"integrity": "sha512-L5ZLphTjjAD9leJzSLI7rr8fNqJMlGDKlazW2tX4IUF9P7R5TMQPElpH82Q7eNIDQnQlAyiNVfRPfP2vM5Avvg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@ -452,9 +452,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.7.tgz",
|
||||
"integrity": "sha512-uFLJFz6+utmpbR313TTx+NpPuAXbPz4BhTQzgaP0tozlLnGnQ6rCo6tLwaSa6b7l6gRErjLicXQ1iPiXzYotjw==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.40.0.tgz",
|
||||
"integrity": "sha512-ATZvCRGCDtv1Y4gpDIXsS+wfFeFuLwVxyUBSLawjgXK2tRE6fnsQEkE4csQQYWlBlsFztRzCnBvWVfcae/1qxQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@ -464,9 +464,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-loongarch64-gnu": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.7.tgz",
|
||||
"integrity": "sha512-ws8pc68UcJJqCpneDFepnwlsMUFoWvPbWXT/XUrJ7rWUL9vLoIN3GAasgG+nCvq8xrE3pIrd+qLX/jotcLy0Qw==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.40.0.tgz",
|
||||
"integrity": "sha512-wG9e2XtIhd++QugU5MD9i7OnpaVb08ji3P1y/hNbxrQ3sYEelKJOq1UJ5dXczeo6Hj2rfDEL5GdtkMSVLa/AOg==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
@ -476,9 +476,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.7.tgz",
|
||||
"integrity": "sha512-vrDk9JDa/BFkxcS2PbWpr0C/LiiSLxFbNOBgfbW6P8TBe9PPHx9Wqbvx2xgNi1TOAyQHQJ7RZFqBiEohm79r0w==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.40.0.tgz",
|
||||
"integrity": "sha512-vgXfWmj0f3jAUvC7TZSU/m/cOE558ILWDzS7jBhiCAFpY2WEBn5jqgbqvmzlMjtp8KlLcBlXVD2mkTSEQE6Ixw==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
@ -488,9 +488,21 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.7.tgz",
|
||||
"integrity": "sha512-rB+ejFyjtmSo+g/a4eovDD1lHWHVqizN8P0Hm0RElkINpS0XOdpaXloqM4FBkF9ZWEzg6bezymbpLmeMldfLTw==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.40.0.tgz",
|
||||
"integrity": "sha512-uJkYTugqtPZBS3Z136arevt/FsKTF/J9dEMTX/cwR7lsAW4bShzI2R0pJVw+hcBTWF4dxVckYh72Hk3/hWNKvA==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-riscv64-musl": {
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.40.0.tgz",
|
||||
"integrity": "sha512-rKmSj6EXQRnhSkE22+WvrqOqRtk733x3p5sWpZilhmjnkHkpeCgWsFFo0dGnUGeA+OZjRl3+VYq+HyCOEuwcxQ==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
@ -500,9 +512,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.7.tgz",
|
||||
"integrity": "sha512-nNXNjo4As6dNqRn7OrsnHzwTgtypfRA3u3AKr0B3sOOo+HkedIbn8ZtFnB+4XyKJojIfqDKmbIzO1QydQ8c+Pw==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.40.0.tgz",
|
||||
"integrity": "sha512-SpnYlAfKPOoVsQqmTFJ0usx0z84bzGOS9anAC0AZ3rdSo3snecihbhFTlJZ8XMwzqAcodjFU4+/SM311dqE5Sw==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
@ -512,9 +524,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.7.tgz",
|
||||
"integrity": "sha512-9kPVf9ahnpOMSGlCxXGv980wXD0zRR3wyk8+33/MXQIpQEOpaNe7dEHm5LMfyRZRNt9lMEQuH0jUKj15MkM7QA==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.40.0.tgz",
|
||||
"integrity": "sha512-RcDGMtqF9EFN8i2RYN2W+64CdHruJ5rPqrlYw+cgM3uOVPSsnAQps7cpjXe9be/yDp8UC7VLoCoKC8J3Kn2FkQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@ -524,9 +536,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-musl": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.7.tgz",
|
||||
"integrity": "sha512-7wJPXRWTTPtTFDFezA8sle/1sdgxDjuMoRXEKtx97ViRxGGkVQYovem+Q8Pr/2HxiHp74SSRG+o6R0Yq0shPwQ==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.40.0.tgz",
|
||||
"integrity": "sha512-HZvjpiUmSNx5zFgwtQAV1GaGazT2RWvqeDi0hV+AtC8unqqDSsaFjPxfsO6qPtKRRg25SisACWnJ37Yio8ttaw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@ -536,9 +548,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.7.tgz",
|
||||
"integrity": "sha512-MN7aaBC7mAjsiMEZcsJvwNsQVNZShgES/9SzWp1HC9Yjqb5OpexYnRjF7RmE4itbeesHMYYQiAtUAQaSKs2Rfw==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.40.0.tgz",
|
||||
"integrity": "sha512-UtZQQI5k/b8d7d3i9AZmA/t+Q4tk3hOC0tMOMSq2GlMYOfxbesxG4mJSeDp0EHs30N9bsfwUvs3zF4v/RzOeTQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@ -548,9 +560,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.7.tgz",
|
||||
"integrity": "sha512-aeawEKYswsFu1LhDM9RIgToobquzdtSc4jSVqHV8uApz4FVvhFl/mKh92wc8WpFc6aYCothV/03UjY6y7yLgbg==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.40.0.tgz",
|
||||
"integrity": "sha512-+m03kvI2f5syIqHXCZLPVYplP8pQch9JHyXKZ3AGMKlg8dCyr2PKHjwRLiW53LTrN/Nc3EqHOKxUxzoSPdKddA==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
@ -560,9 +572,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.7.tgz",
|
||||
"integrity": "sha512-4ZedScpxxIrVO7otcZ8kCX1mZArtH2Wfj3uFCxRJ9NO80gg1XV0U/b2f/MKaGwj2X3QopHfoWiDQ917FRpwY3w==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.40.0.tgz",
|
||||
"integrity": "sha512-lpPE1cLfP5oPzVjKMx10pgBmKELQnFJXHgvtHCtuJWOv8MxqdEIMNtgHgBFf7Ea2/7EuVwa9fodWUfXAlXZLZQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@ -572,9 +584,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
|
||||
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw=="
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz",
|
||||
"integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ=="
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.20.2",
|
||||
@ -582,9 +594,9 @@
|
||||
"integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz",
|
||||
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==",
|
||||
"version": "8.14.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz",
|
||||
"integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
@ -733,11 +745,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "4.34.7",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.7.tgz",
|
||||
"integrity": "sha512-8qhyN0oZ4x0H6wmBgfKxJtxM7qS98YJ0k0kNh5ECVtuchIJ7z9IVVvzpmtQyT10PXKMtBxYr1wQ5Apg8RS8kXQ==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.40.0.tgz",
|
||||
"integrity": "sha512-Noe455xmA96nnqH5piFtLobsGbCij7Tu+tb3c1vYjNbTkfzGqXqQXG3wJaYXkRZuQ0vEYN4bhwg7QnIrqB5B+w==",
|
||||
"dependencies": {
|
||||
"@types/estree": "1.0.6"
|
||||
"@types/estree": "1.0.7"
|
||||
},
|
||||
"bin": {
|
||||
"rollup": "dist/bin/rollup"
|
||||
@ -747,25 +759,26 @@
|
||||
"npm": ">=8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-android-arm-eabi": "4.34.7",
|
||||
"@rollup/rollup-android-arm64": "4.34.7",
|
||||
"@rollup/rollup-darwin-arm64": "4.34.7",
|
||||
"@rollup/rollup-darwin-x64": "4.34.7",
|
||||
"@rollup/rollup-freebsd-arm64": "4.34.7",
|
||||
"@rollup/rollup-freebsd-x64": "4.34.7",
|
||||
"@rollup/rollup-linux-arm-gnueabihf": "4.34.7",
|
||||
"@rollup/rollup-linux-arm-musleabihf": "4.34.7",
|
||||
"@rollup/rollup-linux-arm64-gnu": "4.34.7",
|
||||
"@rollup/rollup-linux-arm64-musl": "4.34.7",
|
||||
"@rollup/rollup-linux-loongarch64-gnu": "4.34.7",
|
||||
"@rollup/rollup-linux-powerpc64le-gnu": "4.34.7",
|
||||
"@rollup/rollup-linux-riscv64-gnu": "4.34.7",
|
||||
"@rollup/rollup-linux-s390x-gnu": "4.34.7",
|
||||
"@rollup/rollup-linux-x64-gnu": "4.34.7",
|
||||
"@rollup/rollup-linux-x64-musl": "4.34.7",
|
||||
"@rollup/rollup-win32-arm64-msvc": "4.34.7",
|
||||
"@rollup/rollup-win32-ia32-msvc": "4.34.7",
|
||||
"@rollup/rollup-win32-x64-msvc": "4.34.7",
|
||||
"@rollup/rollup-android-arm-eabi": "4.40.0",
|
||||
"@rollup/rollup-android-arm64": "4.40.0",
|
||||
"@rollup/rollup-darwin-arm64": "4.40.0",
|
||||
"@rollup/rollup-darwin-x64": "4.40.0",
|
||||
"@rollup/rollup-freebsd-arm64": "4.40.0",
|
||||
"@rollup/rollup-freebsd-x64": "4.40.0",
|
||||
"@rollup/rollup-linux-arm-gnueabihf": "4.40.0",
|
||||
"@rollup/rollup-linux-arm-musleabihf": "4.40.0",
|
||||
"@rollup/rollup-linux-arm64-gnu": "4.40.0",
|
||||
"@rollup/rollup-linux-arm64-musl": "4.40.0",
|
||||
"@rollup/rollup-linux-loongarch64-gnu": "4.40.0",
|
||||
"@rollup/rollup-linux-powerpc64le-gnu": "4.40.0",
|
||||
"@rollup/rollup-linux-riscv64-gnu": "4.40.0",
|
||||
"@rollup/rollup-linux-riscv64-musl": "4.40.0",
|
||||
"@rollup/rollup-linux-s390x-gnu": "4.40.0",
|
||||
"@rollup/rollup-linux-x64-gnu": "4.40.0",
|
||||
"@rollup/rollup-linux-x64-musl": "4.40.0",
|
||||
"@rollup/rollup-win32-arm64-msvc": "4.40.0",
|
||||
"@rollup/rollup-win32-ia32-msvc": "4.40.0",
|
||||
"@rollup/rollup-win32-x64-msvc": "4.40.0",
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
|
2
deps/libbacktrace
vendored
42
deps/lit/lit-all.min.js
vendored
2
deps/lit/lit-all.min.js.map
vendored
2
deps/openssl_src
vendored
22
deps/sqlite/sqlite3.c
vendored
@ -1,6 +1,6 @@
|
||||
/******************************************************************************
|
||||
** This file is an amalgamation of many separate C source files from SQLite
|
||||
** version 3.49.0. By combining all the individual C code files into this
|
||||
** version 3.49.1. By combining all the individual C code files into this
|
||||
** single large file, the entire code can be compiled as a single translation
|
||||
** unit. This allows many compilers to do optimizations that would not be
|
||||
** possible if the files were compiled separately. Performance improvements
|
||||
@ -18,7 +18,7 @@
|
||||
** separate file. This file contains only code for the core SQLite library.
|
||||
**
|
||||
** The content in this amalgamation comes from Fossil check-in
|
||||
** 4a7dd425dc2a0e5082a9049c9b4a9d4f199a with changes in files:
|
||||
** 873d4e274b4988d260ba8354a9718324a1c2 with changes in files:
|
||||
**
|
||||
**
|
||||
*/
|
||||
@ -465,9 +465,9 @@ extern "C" {
|
||||
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
||||
** [sqlite_version()] and [sqlite_source_id()].
|
||||
*/
|
||||
#define SQLITE_VERSION "3.49.0"
|
||||
#define SQLITE_VERSION_NUMBER 3049000
|
||||
#define SQLITE_SOURCE_ID "2025-02-06 11:55:18 4a7dd425dc2a0e5082a9049c9b4a9d4f199a71583d014c24b4cfe276c5a77cde"
|
||||
#define SQLITE_VERSION "3.49.1"
|
||||
#define SQLITE_VERSION_NUMBER 3049001
|
||||
#define SQLITE_SOURCE_ID "2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70"
|
||||
|
||||
/*
|
||||
** CAPI3REF: Run-Time Library Version Numbers
|
||||
@ -131067,7 +131067,7 @@ static void concatFuncCore(
|
||||
for(i=0; i<argc; i++){
|
||||
n += sqlite3_value_bytes(argv[i]);
|
||||
}
|
||||
n += (argc-1)*nSep;
|
||||
n += (argc-1)*(i64)nSep;
|
||||
z = sqlite3_malloc64(n+1);
|
||||
if( z==0 ){
|
||||
sqlite3_result_error_nomem(context);
|
||||
@ -182305,7 +182305,7 @@ SQLITE_API int sqlite3_config(int op, ...){
|
||||
static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
|
||||
#ifndef SQLITE_OMIT_LOOKASIDE
|
||||
void *pStart;
|
||||
sqlite3_int64 szAlloc = sz*(sqlite3_int64)cnt;
|
||||
sqlite3_int64 szAlloc;
|
||||
int nBig; /* Number of full-size slots */
|
||||
int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */
|
||||
|
||||
@ -182324,7 +182324,9 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
|
||||
*/
|
||||
sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */
|
||||
if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
|
||||
if( sz>65528 ) sz = 65528;
|
||||
if( cnt<0 ) cnt = 0;
|
||||
szAlloc = (i64)sz*(i64)cnt;
|
||||
if( sz==0 || cnt==0 ){
|
||||
sz = 0;
|
||||
pStart = 0;
|
||||
@ -182339,10 +182341,10 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
|
||||
#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
|
||||
if( sz>=LOOKASIDE_SMALL*3 ){
|
||||
nBig = szAlloc/(3*LOOKASIDE_SMALL+sz);
|
||||
nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
|
||||
nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL;
|
||||
}else if( sz>=LOOKASIDE_SMALL*2 ){
|
||||
nBig = szAlloc/(LOOKASIDE_SMALL+sz);
|
||||
nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
|
||||
nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL;
|
||||
}else
|
||||
#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */
|
||||
if( sz>0 ){
|
||||
@ -255872,7 +255874,7 @@ static void fts5SourceIdFunc(
|
||||
){
|
||||
assert( nArg==0 );
|
||||
UNUSED_PARAM2(nArg, apUnused);
|
||||
sqlite3_result_text(pCtx, "fts5: 2025-02-06 11:55:18 4a7dd425dc2a0e5082a9049c9b4a9d4f199a71583d014c24b4cfe276c5a77cde", -1, SQLITE_TRANSIENT);
|
||||
sqlite3_result_text(pCtx, "fts5: 2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70", -1, SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
6
deps/sqlite/sqlite3.h
vendored
@ -146,9 +146,9 @@ extern "C" {
|
||||
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
||||
** [sqlite_version()] and [sqlite_source_id()].
|
||||
*/
|
||||
#define SQLITE_VERSION "3.49.0"
|
||||
#define SQLITE_VERSION_NUMBER 3049000
|
||||
#define SQLITE_SOURCE_ID "2025-02-06 11:55:18 4a7dd425dc2a0e5082a9049c9b4a9d4f199a71583d014c24b4cfe276c5a77cde"
|
||||
#define SQLITE_VERSION "3.49.1"
|
||||
#define SQLITE_VERSION_NUMBER 3049001
|
||||
#define SQLITE_SOURCE_ID "2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70"
|
||||
|
||||
/*
|
||||
** CAPI3REF: Run-Time Library Version Numbers
|
||||
|
@ -4,12 +4,14 @@
|
||||
- run the tests
|
||||
- format + prettier
|
||||
- update metadata/en-US/changelogs
|
||||
- git tag
|
||||
- git tag v1.2.3
|
||||
- git tag -f latest_release
|
||||
- push
|
||||
- make dist
|
||||
- make a release on gitea
|
||||
- upload the artifacts
|
||||
- upload the AppImage and zsyncmake
|
||||
- upload to Google
|
||||
- upload to Apple with dist-ios on macos
|
||||
- nix
|
||||
- june and december: update release version
|
||||
- run `nix flake update`
|
||||
|
18
docs/upgrading.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Upgrading
|
||||
|
||||
Tilde Friends can be upgraded simply by running a new executable against an
|
||||
existing database.
|
||||
|
||||
Tilde Friends writes all data to a `db.sqlite` file, either in
|
||||
`~/.local/share/tildefriends/` or in the working directory where it is run,
|
||||
depending on the platform and whether each one already exists. Run with
|
||||
`tildefriends run -d DB_PATH` to specify the path to the database explicitly.
|
||||
|
||||
This file can be copied and moved across machines as needed like any [sqlite3
|
||||
database](https://www.sqlite.org/onefile.html).
|
||||
|
||||
Schema changes and compatibility breaks have been rare, by design. In general,
|
||||
upgrading is not expected to require any manual intervention and likely does
|
||||
not involve any automatic migration, either. Downgrading is not well-supported
|
||||
but will probably just work excepting rare changes that will be called out in
|
||||
the changelog.
|
15
metadata/en-US/changelogs/33.txt
Normal file
@ -0,0 +1,15 @@
|
||||
* Allow specifying all global settings from the command-line (CLI usage changed).
|
||||
* Replication improvements.
|
||||
* An iOS build is on TestFlight.
|
||||
* macOS targets are debug and release like everywhere else.
|
||||
* Running from a subdirectory is fine.
|
||||
* Patchwork compatibility improvements.
|
||||
* Invite fixes.
|
||||
* Follow/block UI fixes.
|
||||
* Mobile automatically logs in.
|
||||
* Updates:
|
||||
* CodeMirror
|
||||
* OpenSSL 3.4.1
|
||||
* libbacktrace
|
||||
* speedscope 1.22.2
|
||||
* sqlite 3.49.1
|
11
metadata/en-US/changelogs/34.txt
Normal file
@ -0,0 +1,11 @@
|
||||
* The connections tab now shows replication progress.
|
||||
* Replication performance and thoroughness improvements.
|
||||
* Bind only to localhost on mobile, configurable.
|
||||
* Request blobs referenced by referenced blobs, and improve performance of that
|
||||
query.
|
||||
* Fix file upload on iOS.
|
||||
* Add rough back/forward/refresh buttons on iOS.
|
||||
* Other crash fixes and performance improvements.
|
||||
* Updates:
|
||||
* CodeMirror
|
||||
* w3.css
|
12
metadata/en-US/changelogs/35.txt
Normal file
@ -0,0 +1,12 @@
|
||||
* Faster loads.
|
||||
* Replication fixes.
|
||||
* Shutdown fixes.
|
||||
* Consolidated message actions into a % menu.
|
||||
* Fixed and tested handling of user permissions.
|
||||
* Add a very work in progress "web" app.
|
||||
* Updates:
|
||||
* CodeMirror
|
||||
* Lit 3.3.0
|
||||
* OpenSSL 3.5.0
|
||||
* c-ares 1.34.5
|
||||
* libbacktrace
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 101 KiB |
@ -1 +1 @@
|
||||
A tool for making and sharing
|
||||
A Secure Scuttlebutt decentralized social network client
|
||||
|
6
package-lock.json
generated
@ -11,9 +11,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.1.tgz",
|
||||
"integrity": "sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==",
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz",
|
||||
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==",
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
|
@ -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="33"
|
||||
android:versionName="0.0.28-wip">
|
||||
android:versionCode="35"
|
||||
android:versionName="0.0.30">
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<application
|
||||
|
@ -347,7 +347,6 @@ public class TildeFriendsActivity extends Activity {
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
} catch (java.io.FileNotFoundException e) {
|
||||
Log.w("tildefriends", "Port file does not yet exist.");
|
||||
} catch (java.io.IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
19
src/api.js.c
Normal 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
@ -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);
|
||||
|
||||
/** @} */
|
102
src/http.c
@ -84,6 +84,7 @@ typedef struct _tf_http_listener_t
|
||||
typedef struct _tf_http_t
|
||||
{
|
||||
bool is_shutting_down;
|
||||
bool is_in_destroy;
|
||||
|
||||
tf_http_listener_t** listeners;
|
||||
int listeners_count;
|
||||
@ -395,7 +396,7 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
|
||||
|
||||
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");
|
||||
connection->request->on_message(connection->request, connection->fragment_length ? connection->fragment_op_code : op_code,
|
||||
@ -697,7 +698,7 @@ static void _http_on_connection(uv_stream_t* stream, int status)
|
||||
http->connections[http->connections_count++] = connection;
|
||||
}
|
||||
|
||||
int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls, tf_http_cleanup_t* cleanup, void* user_data)
|
||||
int tf_http_listen(tf_http_t* http, int port, bool local_only, tf_tls_context_t* tls, tf_http_cleanup_t* cleanup, void* user_data)
|
||||
{
|
||||
tf_http_listener_t* listener = tf_malloc(sizeof(tf_http_listener_t));
|
||||
*listener = (tf_http_listener_t) {
|
||||
@ -715,25 +716,29 @@ int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls, tf_http_cle
|
||||
|
||||
if (r == 0)
|
||||
{
|
||||
bool use_ipv6 = !tf_util_is_mobile();
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
/*
|
||||
** Binding to IPv6 here fails with an odd error, and the socket
|
||||
** becomes unusable. Since we probably want localhost only
|
||||
** on this single-user OS, let's just assume IPv4.
|
||||
*/
|
||||
struct sockaddr_in addr = {
|
||||
use_ipv6 = false;
|
||||
#endif
|
||||
|
||||
struct sockaddr_in addr4 = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_addr = { .s_addr = INADDR_ANY },
|
||||
.sin_addr = { .s_addr = local_only ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY) },
|
||||
.sin_port = ntohs(port),
|
||||
};
|
||||
#else
|
||||
struct sockaddr_in6 addr = {
|
||||
struct sockaddr_in6 addr6 = {
|
||||
.sin6_family = AF_INET6,
|
||||
.sin6_addr = IN6ADDR_ANY_INIT,
|
||||
.sin6_addr = local_only ? (struct in6_addr)IN6ADDR_LOOPBACK_INIT : (struct in6_addr)IN6ADDR_ANY_INIT,
|
||||
.sin6_port = ntohs(port),
|
||||
};
|
||||
#endif
|
||||
r = uv_tcp_bind(&listener->tcp, (struct sockaddr*)&addr, 0);
|
||||
struct sockaddr* addr = use_ipv6 ? (struct sockaddr*)&addr6 : (struct sockaddr*)&addr4;
|
||||
r = uv_tcp_bind(&listener->tcp, addr, 0);
|
||||
if (r)
|
||||
{
|
||||
tf_printf("%s:%d: uv_tcp_bind: %s\n", __FILE__, __LINE__, uv_strerror(r));
|
||||
@ -780,13 +785,36 @@ void tf_http_add_handler(tf_http_t* http, const char* pattern, tf_http_callback_
|
||||
static void _http_free_listener_on_close(uv_handle_t* handle)
|
||||
{
|
||||
tf_http_listener_t* listener = handle->data;
|
||||
tf_http_t* http = listener->http;
|
||||
for (int i = 0; i < http->listeners_count; i++)
|
||||
{
|
||||
if (http->listeners[i] == listener)
|
||||
{
|
||||
http->listeners[i] = http->listeners[http->listeners_count - 1];
|
||||
http->listeners_count--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
handle->data = NULL;
|
||||
tf_free(listener);
|
||||
|
||||
if (!http->listeners_count)
|
||||
{
|
||||
tf_free(http->listeners);
|
||||
http->listeners = NULL;
|
||||
tf_http_destroy(http);
|
||||
}
|
||||
}
|
||||
|
||||
void tf_http_destroy(tf_http_t* http)
|
||||
{
|
||||
if (http->is_in_destroy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
http->is_shutting_down = true;
|
||||
http->is_in_destroy = true;
|
||||
|
||||
for (int i = 0; i < http->connections_count; i++)
|
||||
{
|
||||
@ -801,6 +829,10 @@ void tf_http_destroy(tf_http_t* http)
|
||||
listener->cleanup(listener->user_data);
|
||||
listener->cleanup = NULL;
|
||||
}
|
||||
if (listener->tcp.data && !uv_is_closing((uv_handle_t*)&listener->tcp))
|
||||
{
|
||||
uv_close((uv_handle_t*)&listener->tcp, _http_free_listener_on_close);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < http->handlers_count; i++)
|
||||
@ -818,20 +850,11 @@ void tf_http_destroy(tf_http_t* http)
|
||||
http->user_data = NULL;
|
||||
}
|
||||
|
||||
if (http->connections_count == 0)
|
||||
if (http->connections_count == 0 && http->listeners_count == 0)
|
||||
{
|
||||
tf_free(http->connections);
|
||||
http->connections = NULL;
|
||||
|
||||
for (int i = 0; i < http->listeners_count; i++)
|
||||
{
|
||||
tf_http_listener_t* listener = http->listeners[i];
|
||||
uv_close((uv_handle_t*)&listener->tcp, _http_free_listener_on_close);
|
||||
}
|
||||
tf_free(http->listeners);
|
||||
http->listeners = NULL;
|
||||
http->listeners_count = 0;
|
||||
|
||||
for (int i = 0; i < http->handlers_count; i++)
|
||||
{
|
||||
if (http->handlers[i].pattern)
|
||||
@ -845,6 +868,10 @@ void tf_http_destroy(tf_http_t* http)
|
||||
|
||||
tf_free(http);
|
||||
}
|
||||
else
|
||||
{
|
||||
http->is_in_destroy = false;
|
||||
}
|
||||
}
|
||||
|
||||
const char* tf_http_status_text(int status)
|
||||
@ -963,9 +990,42 @@ static void _http_write(tf_http_connection_t* connection, const void* data, size
|
||||
}
|
||||
}
|
||||
|
||||
void tf_http_request_send(tf_http_request_t* request, const void* data, size_t size)
|
||||
void tf_http_request_websocket_send(tf_http_request_t* request, int op_code, const void* data, size_t size)
|
||||
{
|
||||
_http_write(request->connection, data, size);
|
||||
uint8_t* copy = tf_malloc(size + 16);
|
||||
bool fin = true;
|
||||
size_t header = 1;
|
||||
copy[0] = (fin ? (1 << 7) : 0) | (op_code & 0xf);
|
||||
if (size < 126)
|
||||
{
|
||||
copy[1] = size;
|
||||
header += 1;
|
||||
}
|
||||
else if (size < (1 << 16))
|
||||
{
|
||||
copy[1] = 126;
|
||||
copy[2] = (size >> 8) & 0xff;
|
||||
copy[3] = (size >> 0) & 0xff;
|
||||
header += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t high = ((uint64_t)size >> 32) & 0xffffffff;
|
||||
uint32_t low = (size >> 0) & 0xffffffff;
|
||||
copy[1] = 127;
|
||||
copy[2] = (high >> 24) & 0xff;
|
||||
copy[3] = (high >> 16) & 0xff;
|
||||
copy[4] = (high >> 8) & 0xff;
|
||||
copy[5] = (high >> 0) & 0xff;
|
||||
copy[6] = (low >> 24) & 0xff;
|
||||
copy[7] = (low >> 16) & 0xff;
|
||||
copy[8] = (low >> 8) & 0xff;
|
||||
copy[9] = (low >> 0) & 0xff;
|
||||
header += 9;
|
||||
}
|
||||
memcpy(copy + header, data, size);
|
||||
_http_write(request->connection, copy, header + size);
|
||||
tf_free(copy);
|
||||
}
|
||||
|
||||
void tf_http_respond(tf_http_request_t* request, int status, const char** headers, int headers_count, const void* body, size_t content_length)
|
||||
|
@ -116,12 +116,13 @@ void tf_http_set_trace(tf_http_t* http, tf_trace_t* trace);
|
||||
** times to listen on multiple ports.
|
||||
** @param http The HTTP instance.
|
||||
** @param port The port on which to listen, or 0 to assign a free port.
|
||||
** @param local_only Only access connections on localhost, otherwise any address.
|
||||
** @param tls An optional TLS context to use for HTTPS requests.
|
||||
** @param cleanup A function called when the HTTP instance is being cleaned up.
|
||||
** @param user_data User data passed to the cleanup callback.
|
||||
** @return The port number on which the HTTP instance is now listening.
|
||||
*/
|
||||
int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls, tf_http_cleanup_t* cleanup, void* user_data);
|
||||
int tf_http_listen(tf_http_t* http, int port, bool local_only, tf_tls_context_t* tls, tf_http_cleanup_t* cleanup, void* user_data);
|
||||
|
||||
/**
|
||||
** Add an HTTP request handler.
|
||||
@ -209,10 +210,11 @@ const char* tf_http_get_cookie(const char* cookie_header, const char* name);
|
||||
** Send a websocket message.
|
||||
** @param request The HTTP request which was previously updated to a websocket
|
||||
** session with tf_http_request_websocket_upgrade().
|
||||
** @param op_code Websocket op code.
|
||||
** @param data The message data.
|
||||
** @param size The size of data.
|
||||
*/
|
||||
void tf_http_request_send(tf_http_request_t* request, const void* data, size_t size);
|
||||
void tf_http_request_websocket_send(tf_http_request_t* request, int op_code, const void* data, size_t size);
|
||||
|
||||
/**
|
||||
** Upgrade an HTTP request to a websocket session.
|
||||
|
154
src/httpd.js.c
@ -5,6 +5,7 @@
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "ssb.db.h"
|
||||
#include "ssb.ebt.h"
|
||||
#include "ssb.h"
|
||||
#include "task.h"
|
||||
#include "tls.h"
|
||||
@ -46,7 +47,6 @@ static const char* _make_set_session_cookie_header(tf_http_request_t* request, c
|
||||
const char** _form_data_decode(const char* data, int length);
|
||||
const char* _form_data_get(const char** form_data, const char* key);
|
||||
|
||||
static JSClassID _httpd_class_id;
|
||||
static JSClassID _httpd_request_class_id;
|
||||
|
||||
typedef struct _http_user_data_t
|
||||
@ -152,44 +152,9 @@ static JSValue _httpd_response_send(JSContext* context, JSValueConst this_val, i
|
||||
tf_http_request_t* request = JS_GetOpaque(this_val, _httpd_request_class_id);
|
||||
int opcode = 0x1;
|
||||
JS_ToInt32(context, &opcode, argv[1]);
|
||||
uint64_t length = 0;
|
||||
size_t length_size = 0;
|
||||
const char* message = JS_ToCStringLen(context, &length_size, argv[0]);
|
||||
length = length_size;
|
||||
uint8_t* copy = tf_malloc(length + 16);
|
||||
bool fin = true;
|
||||
size_t header = 1;
|
||||
copy[0] = (fin ? (1 << 7) : 0) | (opcode & 0xf);
|
||||
if (length < 126)
|
||||
{
|
||||
copy[1] = length;
|
||||
header += 1;
|
||||
}
|
||||
else if (length < (1 << 16))
|
||||
{
|
||||
copy[1] = 126;
|
||||
copy[2] = (length >> 8) & 0xff;
|
||||
copy[3] = (length >> 0) & 0xff;
|
||||
header += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t high = (length >> 32) & 0xffffffff;
|
||||
uint32_t low = (length >> 0) & 0xffffffff;
|
||||
copy[1] = 127;
|
||||
copy[2] = (high >> 24) & 0xff;
|
||||
copy[3] = (high >> 16) & 0xff;
|
||||
copy[4] = (high >> 8) & 0xff;
|
||||
copy[5] = (high >> 0) & 0xff;
|
||||
copy[6] = (low >> 24) & 0xff;
|
||||
copy[7] = (low >> 16) & 0xff;
|
||||
copy[8] = (low >> 8) & 0xff;
|
||||
copy[9] = (low >> 0) & 0xff;
|
||||
header += 9;
|
||||
}
|
||||
memcpy(copy + header, message, length);
|
||||
tf_http_request_send(request, copy, header + length);
|
||||
tf_free(copy);
|
||||
size_t length = 0;
|
||||
const char* message = JS_ToCStringLen(context, &length, argv[0]);
|
||||
tf_http_request_websocket_send(request, opcode, message, length);
|
||||
JS_FreeCString(context, message);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
@ -572,12 +537,6 @@ static const char* _ext_to_content_type(const char* ext, bool use_fallback)
|
||||
return use_fallback ? "application/binary" : NULL;
|
||||
}
|
||||
|
||||
static void _httpd_finalizer(JSRuntime* runtime, JSValue value)
|
||||
{
|
||||
tf_http_t* http = JS_GetOpaque(value, _httpd_class_id);
|
||||
tf_http_destroy(http);
|
||||
}
|
||||
|
||||
static void _httpd_request_finalizer(JSRuntime* runtime, JSValue value)
|
||||
{
|
||||
tf_http_request_t* request = JS_GetOpaque(value, _httpd_request_class_id);
|
||||
@ -604,6 +563,50 @@ static void _httpd_endpoint_trace(tf_http_request_t* request)
|
||||
tf_free(json);
|
||||
}
|
||||
|
||||
static void _httpd_endpoint_ebt(tf_http_request_t* request)
|
||||
{
|
||||
if (_httpd_redirect(request))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tf_task_t* task = request->user_data;
|
||||
tf_ssb_t* ssb = tf_task_get_ssb(task);
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
|
||||
JSValue object = JS_NewObject(context);
|
||||
|
||||
tf_ssb_connection_t* connections[256];
|
||||
int connection_count = tf_ssb_get_connections(ssb, connections, tf_countof(connections));
|
||||
for (int i = 0; i < connection_count; i++)
|
||||
{
|
||||
char id[k_id_base64_len];
|
||||
tf_ssb_connection_get_id(connections[i], id, sizeof(id));
|
||||
|
||||
char key[256];
|
||||
JSValue clock = JS_NewObject(context);
|
||||
snprintf(key, sizeof(key), "%d:%s", i, id);
|
||||
|
||||
tf_ssb_ebt_t* ebt = tf_ssb_connection_get_ebt(connections[i]);
|
||||
tf_ssb_ebt_debug_clock(ebt, context, clock);
|
||||
JS_SetPropertyStr(context, object, key, clock);
|
||||
}
|
||||
|
||||
JSValue json_value = JS_JSONStringify(context, object, JS_NULL, JS_NewInt32(context, 2));
|
||||
const char* json = JS_ToCString(context, json_value);
|
||||
JS_FreeValue(context, json_value);
|
||||
|
||||
const char* headers[] = {
|
||||
"Content-Type",
|
||||
"application/json; charset=utf-8",
|
||||
"Access-Control-Allow-Origin",
|
||||
"*",
|
||||
};
|
||||
tf_http_respond(request, 200, headers, tf_countof(headers) / 2, json, json ? strlen(json) : 0);
|
||||
JS_FreeCString(context, json);
|
||||
JS_FreeValue(context, object);
|
||||
}
|
||||
|
||||
static void _httpd_endpoint_mem(tf_http_request_t* request)
|
||||
{
|
||||
if (_httpd_redirect(request))
|
||||
@ -1314,6 +1317,11 @@ static void _httpd_endpoint_save_work(tf_ssb_t* ssb, void* user_data)
|
||||
snprintf(save->blob_id, sizeof(save->blob_id), "%s", blob_id);
|
||||
save->response = 200;
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("Blob store or property set failed.\n");
|
||||
save->response = 500;
|
||||
}
|
||||
|
||||
JS_FreeCString(context, new_app_str);
|
||||
JS_FreeValue(context, new_app_json);
|
||||
@ -1330,7 +1338,7 @@ static void _httpd_endpoint_save_work(tf_ssb_t* ssb, void* user_data)
|
||||
}
|
||||
else
|
||||
{
|
||||
save->response = 401;
|
||||
save->response = 403;
|
||||
}
|
||||
tf_free(user_app);
|
||||
}
|
||||
@ -1342,12 +1350,21 @@ static void _httpd_endpoint_save_work(tf_ssb_t* ssb, void* user_data)
|
||||
snprintf(save->blob_id, sizeof(save->blob_id), "%s", blob_id);
|
||||
save->response = 200;
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("Blob store failed.\n");
|
||||
save->response = 500;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save->response = 400;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save->response = 401;
|
||||
}
|
||||
|
||||
tf_free((void*)session);
|
||||
JS_FreeCString(context, user_string);
|
||||
@ -1469,17 +1486,9 @@ static void _httpd_endpoint_delete(tf_http_request_t* request)
|
||||
static void _httpd_endpoint_root_callback(const char* path, void* user_data)
|
||||
{
|
||||
tf_http_request_t* request = user_data;
|
||||
const char* host = tf_http_request_get_header(request, "x-forwarded-host");
|
||||
if (!host)
|
||||
{
|
||||
host = tf_http_request_get_header(request, "host");
|
||||
}
|
||||
|
||||
char url[1024];
|
||||
snprintf(url, sizeof(url), "%s%s%s", request->is_tls ? "https://" : "http://", host, path ? path : "/~core/apps/");
|
||||
const char* headers[] = {
|
||||
"Location",
|
||||
url,
|
||||
path ? path : "/~core/apps/",
|
||||
};
|
||||
tf_http_respond(request, 303, headers, tf_countof(headers) / 2, NULL, 0);
|
||||
tf_http_request_unref(request);
|
||||
@ -2338,16 +2347,7 @@ static const char* _httpd_read_file(tf_task_t* task, const char* path)
|
||||
|
||||
void tf_httpd_register(JSContext* context)
|
||||
{
|
||||
JS_NewClassID(&_httpd_class_id);
|
||||
JS_NewClassID(&_httpd_request_class_id);
|
||||
JSClassDef httpd_def = {
|
||||
.class_name = "Httpd",
|
||||
.finalizer = &_httpd_finalizer,
|
||||
};
|
||||
if (JS_NewClass(JS_GetRuntime(context), _httpd_class_id, &httpd_def) != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to register Httpd.\n");
|
||||
}
|
||||
JSClassDef request_def = {
|
||||
.class_name = "Request",
|
||||
.finalizer = &_httpd_request_finalizer,
|
||||
@ -2358,22 +2358,29 @@ void tf_httpd_register(JSContext* context)
|
||||
}
|
||||
|
||||
JSValue global = JS_GetGlobalObject(context);
|
||||
JSValue httpd = JS_NewObjectClass(context, _httpd_class_id);
|
||||
JSValue httpd = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, httpd, "auth_query", JS_NewCFunction(context, _httpd_auth_query, "auth_query", 1));
|
||||
JS_SetPropertyStr(context, global, "httpd", httpd);
|
||||
JS_FreeValue(context, global);
|
||||
}
|
||||
|
||||
tf_http_t* tf_httpd_create(JSContext* context)
|
||||
{
|
||||
tf_task_t* task = tf_task_get(context);
|
||||
tf_ssb_t* ssb = tf_task_get_ssb(task);
|
||||
uv_loop_t* loop = tf_task_get_loop(task);
|
||||
tf_http_t* http = tf_http_create(loop);
|
||||
tf_http_set_trace(http, tf_task_get_trace(task));
|
||||
JS_SetOpaque(httpd, http);
|
||||
|
||||
int64_t http_port = 0;
|
||||
int64_t https_port = 0;
|
||||
char out_http_port_file[512] = "";
|
||||
bool local_only = false;
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
tf_ssb_db_get_global_setting_int64(db, "http_port", &http_port);
|
||||
tf_ssb_db_get_global_setting_int64(db, "https_port", &https_port);
|
||||
tf_ssb_db_get_global_setting_string(db, "out_http_port_file", out_http_port_file, sizeof(out_http_port_file));
|
||||
tf_ssb_db_get_global_setting_bool(db, "http_local_only", &local_only);
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
|
||||
if (https_port)
|
||||
@ -2420,6 +2427,7 @@ void tf_httpd_register(JSContext* context)
|
||||
tf_http_add_handler(http, "/hitches", _httpd_endpoint_hitches, NULL, task);
|
||||
tf_http_add_handler(http, "/mem", _httpd_endpoint_mem, NULL, task);
|
||||
tf_http_add_handler(http, "/trace", _httpd_endpoint_trace, NULL, task);
|
||||
tf_http_add_handler(http, "/ebt", _httpd_endpoint_ebt, NULL, task);
|
||||
|
||||
tf_http_add_handler(http, "/login/logout", _httpd_endpoint_logout, NULL, task);
|
||||
tf_http_add_handler(http, "/login/auto", _httpd_endpoint_login_auto, NULL, task);
|
||||
@ -2427,15 +2435,11 @@ void tf_httpd_register(JSContext* context)
|
||||
|
||||
tf_http_add_handler(http, "/app/socket", _httpd_endpoint_app_socket, NULL, task);
|
||||
|
||||
JS_SetPropertyStr(context, httpd, "auth_query", JS_NewCFunction(context, _httpd_auth_query, "auth_query", 1));
|
||||
JS_SetPropertyStr(context, global, "httpd", httpd);
|
||||
JS_FreeValue(context, global);
|
||||
|
||||
if (http_port > 0 || *out_http_port_file)
|
||||
{
|
||||
httpd_listener_t* listener = tf_malloc(sizeof(httpd_listener_t));
|
||||
*listener = (httpd_listener_t) { 0 };
|
||||
int assigned_port = tf_http_listen(http, http_port, NULL, _httpd_listener_cleanup, listener);
|
||||
int assigned_port = tf_http_listen(http, http_port, local_only, NULL, _httpd_listener_cleanup, listener);
|
||||
tf_printf(CYAN "~😎 Tilde Friends" RESET " " YELLOW VERSION_NUMBER RESET " is now up at " MAGENTA "http://127.0.0.1:%d/" RESET ".\n", assigned_port);
|
||||
|
||||
if (*out_http_port_file)
|
||||
@ -2468,11 +2472,17 @@ void tf_httpd_register(JSContext* context)
|
||||
tf_tls_context_set_private_key(tls, private_key);
|
||||
httpd_listener_t* listener = tf_malloc(sizeof(httpd_listener_t));
|
||||
*listener = (httpd_listener_t) { .tls = tls };
|
||||
int assigned_port = tf_http_listen(http, https_port, tls, _httpd_listener_cleanup, listener);
|
||||
int assigned_port = tf_http_listen(http, https_port, local_only, tls, _httpd_listener_cleanup, listener);
|
||||
tf_printf(CYAN "~😎 Tilde Friends" RESET " " YELLOW VERSION_NUMBER RESET " is now up at " MAGENTA "https://127.0.0.1:%d/" RESET ".\n", assigned_port);
|
||||
}
|
||||
tf_free((char*)certificate);
|
||||
tf_free((char*)private_key);
|
||||
}
|
||||
}
|
||||
return http;
|
||||
}
|
||||
|
||||
void tf_httpd_destroy(tf_http_t* http)
|
||||
{
|
||||
tf_http_destroy(http);
|
||||
}
|
||||
|
@ -13,6 +13,11 @@
|
||||
|
||||
#include "quickjs.h"
|
||||
|
||||
/**
|
||||
** An HTTP server instance.
|
||||
*/
|
||||
typedef struct _tf_http_t tf_http_t;
|
||||
|
||||
/**
|
||||
** Register the HTTP script interface. Also registers a number of built-in
|
||||
** request handlers. An ongoing project is to move the JS request handlers
|
||||
@ -21,4 +26,16 @@
|
||||
*/
|
||||
void tf_httpd_register(JSContext* context);
|
||||
|
||||
/**
|
||||
** Create the HTTP server instance.
|
||||
** @param context The JS context.
|
||||
*/
|
||||
tf_http_t* tf_httpd_create(JSContext* context);
|
||||
|
||||
/**
|
||||
** Destroy the HTTP server instance.
|
||||
** @param http The HTTP server instance.
|
||||
*/
|
||||
void tf_httpd_destroy(tf_http_t* http);
|
||||
|
||||
/** @} */
|
||||
|
54
src/ios.m
@ -4,12 +4,14 @@
|
||||
#import <WebKit/WKWebView.h>
|
||||
#import <WebKit/WKWebViewConfiguration.h>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include <libgen.h>
|
||||
#include <string.h>
|
||||
|
||||
void tf_run_thread_start(const char* zip_path);
|
||||
|
||||
@interface ViewController : UIViewController <WKUIDelegate, WKNavigationDelegate>
|
||||
@interface ViewController : UINavigationController <WKUIDelegate, WKNavigationDelegate>
|
||||
@property (strong, nonatomic) WKWebView* web_view;
|
||||
@property bool initial_load_complete;
|
||||
@end
|
||||
@ -19,19 +21,67 @@ static void _start_initial_load(WKWebView* web_view)
|
||||
[web_view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:12345/login/auto"]]];
|
||||
}
|
||||
|
||||
@implementation ViewController : UIViewController
|
||||
@implementation ViewController : UINavigationController
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self setToolbarHidden:false animated:false];
|
||||
self.toolbar.items = @[
|
||||
[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(goBack)],
|
||||
[[UIBarButtonItem alloc] initWithTitle:@"Forward" style:UIBarButtonItemStylePlain target:self action:@selector(goForward)],
|
||||
[[UIBarButtonItem alloc] initWithTitle:@"Refresh" style:UIBarButtonItemStylePlain target:self action:@selector(reload)]
|
||||
];
|
||||
|
||||
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
|
||||
self.web_view = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
|
||||
self.web_view.UIDelegate = self;
|
||||
self.web_view.navigationDelegate = self;
|
||||
self.web_view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
|
||||
self.web_view.translatesAutoresizingMaskIntoConstraints = false;
|
||||
[self.view addSubview:self.web_view];
|
||||
|
||||
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.web_view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0
|
||||
constant:0]];
|
||||
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.web_view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view
|
||||
attribute:NSLayoutAttributeBottom
|
||||
multiplier:1.0
|
||||
constant:-75]];
|
||||
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.web_view attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view
|
||||
attribute:NSLayoutAttributeLeft
|
||||
multiplier:1.0
|
||||
constant:0]];
|
||||
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.web_view attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view
|
||||
attribute:NSLayoutAttributeRight
|
||||
multiplier:1.0
|
||||
constant:0]];
|
||||
|
||||
_start_initial_load(self.web_view);
|
||||
}
|
||||
|
||||
- (void)goBack
|
||||
{
|
||||
if (self.web_view.canGoBack)
|
||||
{
|
||||
[self.web_view goBack];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)goForward
|
||||
{
|
||||
if (self.web_view.canGoForward)
|
||||
{
|
||||
[self.web_view goForward];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reload
|
||||
{
|
||||
[self.web_view reload];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation
|
||||
{
|
||||
self.initial_load_complete = true;
|
||||
|
@ -7,6 +7,6 @@
|
||||
<key>com.apple.developer.team-identifier</key>
|
||||
<string>EDVXQ27EB5</string>
|
||||
<key>get-task-allow</key>
|
||||
<true/>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -2,34 +2,86 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleName</key>
|
||||
<string>tildefriends</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>iPhoneOS</string>
|
||||
</array>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Tilde Friends</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>tildefriends</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.unprompted.tildefriends</string>
|
||||
<key>CFBundleResourceSpecification</key>
|
||||
<string>ResourceRules.plist</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>tildefriends</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.0.30</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>iPhoneOS</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>12</string>
|
||||
<key>DTPlatformName</key>
|
||||
<string>iphoneos</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Tilde Friends</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleIconName</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>tildefriends.png</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>14.0</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UILaunchScreen</key>
|
||||
<dict>
|
||||
<key>UIImageName</key>
|
||||
<string>tildefriends.png</string>
|
||||
</dict>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>24D70</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>22C146</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>18.2</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>22C146</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>iphoneos18.2</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1620</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>16C5032a</string>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~iphone</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleIcons</key>
|
||||
<dict>
|
||||
<key>CFBundlePrimaryIcon</key>
|
||||
<dict>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>AppIcon60x60</string>
|
||||
</array>
|
||||
<key>CFBundleIconName</key>
|
||||
<string>AppIcon</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
BIN
src/ios/distribution.mobileprovision
Normal file
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/100.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/1024.png
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/114.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/120.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/144.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/152.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/167.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/180.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/20.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/29.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/40.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/50.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/57.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/58.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/60.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/72.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/76.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/80.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
src/ios/icons/Assets.xcassets/AppIcon.appiconset/87.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
@ -0,0 +1 @@
|
||||
{"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"72x72","expected-size":"72","filename":"72.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"76x76","expected-size":"152","filename":"152.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"50x50","expected-size":"100","filename":"100.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"76x76","expected-size":"76","filename":"76.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"50x50","expected-size":"50","filename":"50.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"72x72","expected-size":"144","filename":"144.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"40x40","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"83.5x83.5","expected-size":"167","filename":"167.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"20x20","expected-size":"20","filename":"20.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"}]}
|
BIN
src/ios/icons/appstore.png
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
src/ios/icons/playstore.png
Normal file
After Width: | Height: | Size: 56 KiB |
53
src/main.c
@ -1057,7 +1057,7 @@ static int _tf_command_get_profile(const char* file, int argc, char* argv[])
|
||||
sqlite3_close(db);
|
||||
tf_free((void*)profile);
|
||||
tf_free((void*)default_db_path);
|
||||
return profile != NULL;
|
||||
return profile != NULL ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
static int _tf_command_get_contacts(const char* file, int argc, char* argv[])
|
||||
@ -1161,17 +1161,19 @@ static int _tf_command_verify(const char* file, int argc, char* argv[])
|
||||
const char* identity = NULL;
|
||||
const char* default_db_path = _get_db_path();
|
||||
const char* db_path = default_db_path;
|
||||
int64_t sequence = 0;
|
||||
bool show_usage = false;
|
||||
|
||||
while (!show_usage)
|
||||
{
|
||||
static const struct option k_options[] = {
|
||||
{ "id", required_argument, NULL, 'i' },
|
||||
{ "sequence", required_argument, NULL, 's' },
|
||||
{ "db-path", required_argument, NULL, 'd' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ 0 },
|
||||
};
|
||||
int c = getopt_long(argc, argv, "i:d:h", k_options, NULL);
|
||||
int c = getopt_long(argc, argv, "i:s:d:h", k_options, NULL);
|
||||
if (c == -1)
|
||||
{
|
||||
break;
|
||||
@ -1187,6 +1189,9 @@ static int _tf_command_verify(const char* file, int argc, char* argv[])
|
||||
case 'i':
|
||||
identity = optarg;
|
||||
break;
|
||||
case 's':
|
||||
sequence = atoll(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
db_path = optarg;
|
||||
break;
|
||||
@ -1198,15 +1203,45 @@ static int _tf_command_verify(const char* file, int argc, char* argv[])
|
||||
tf_printf("\n%s import [options] [paths...]\n\n", file);
|
||||
tf_printf("options:\n");
|
||||
tf_printf(" -i, --identity identity Identity to verify.\n");
|
||||
tf_printf(" -s, --sequence sequence Sequence number to debug.\n");
|
||||
tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path);
|
||||
tf_printf(" -h, --help Show this usage information.\n");
|
||||
tf_free((void*)default_db_path);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
tf_printf("Verifying %s...\n", identity);
|
||||
bool verified = false;
|
||||
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
|
||||
bool verified = tf_ssb_db_verify(ssb, identity);
|
||||
if (identity)
|
||||
{
|
||||
tf_printf("Verifying %s...\n", identity);
|
||||
verified = tf_ssb_db_verify(ssb, identity, sequence, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
sqlite3_stmt* statement = NULL;
|
||||
if (sqlite3_prepare(db, "SELECT DISTINCT author FROM messages ORDER BY author", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
verified = true;
|
||||
while (sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
const char* identity = (const char*)sqlite3_column_text(statement, 0);
|
||||
tf_printf("Verifying %s...", identity);
|
||||
if (tf_ssb_db_verify(ssb, identity, sequence, true))
|
||||
{
|
||||
tf_printf("success.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("fail.\n");
|
||||
verified = false;
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
}
|
||||
tf_ssb_destroy(ssb);
|
||||
tf_free((void*)default_db_path);
|
||||
return verified ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
@ -1299,10 +1334,12 @@ static int _tf_run_task(const tf_run_args_t* args, int index)
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
int64_t http_port = 0;
|
||||
int64_t https_port = 0;
|
||||
char out_http_port_file[512] = "";
|
||||
tf_ssb_db_get_global_setting_int64(db, "http_port", &http_port);
|
||||
tf_ssb_db_get_global_setting_int64(db, "https_port", &https_port);
|
||||
tf_ssb_db_get_global_setting_string(db, "out_http_port_file", out_http_port_file, sizeof(out_http_port_file));
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
if (http_port || https_port)
|
||||
if (http_port || https_port || *out_http_port_file)
|
||||
{
|
||||
if (args->zip)
|
||||
{
|
||||
@ -1483,6 +1520,12 @@ static int _tf_command_run(const char* file, int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = optind; i < argc; i++)
|
||||
{
|
||||
tf_printf("Unexpected argument: %s\n", argv[i]);
|
||||
show_usage = true;
|
||||
}
|
||||
|
||||
if (show_usage)
|
||||
{
|
||||
tf_printf("\n%s run [options]\n\n", file);
|
||||
|
@ -22,8 +22,6 @@ static int64_t s_tls_malloc_size;
|
||||
static int64_t s_js_malloc_size;
|
||||
static int64_t s_sqlite_malloc_size;
|
||||
|
||||
extern uint32_t fnv32a(const void* buffer, int length, uint32_t start);
|
||||
|
||||
static size_t _tf_mem_round_up(size_t size)
|
||||
{
|
||||
return (size + 7) & ~7;
|
||||
@ -156,7 +154,7 @@ static void _tf_mem_summarize(void* ptr, size_t size, int frames_count, void* co
|
||||
{
|
||||
summary_t* summary = user_data;
|
||||
tf_mem_allocation_t allocation = {
|
||||
.stack_hash = fnv32a(frames, sizeof(void*) * frames_count, 0),
|
||||
.stack_hash = tf_util_fnv32a(frames, sizeof(void*) * frames_count, 0),
|
||||
.count = 1,
|
||||
.size = size,
|
||||
.frames_count = frames_count,
|
||||
|
98
src/ssb.c
@ -37,6 +37,8 @@
|
||||
#define PRE_CALLBACK(ssb, cb) uint64_t pre_callback_hrtime_ns = _tf_ssb_callback_pre(ssb)
|
||||
#define POST_CALLBACK(ssb, cb) _tf_ssb_callback_post(ssb, cb, pre_callback_hrtime_ns)
|
||||
|
||||
const int k_read_back_pressure_threshold = 256;
|
||||
|
||||
static_assert(k_id_base64_len == sodium_base64_ENCODED_LEN(9 + crypto_box_PUBLICKEYBYTES, sodium_base64_VARIANT_ORIGINAL), "k_id_base64_len");
|
||||
static_assert(k_id_bin_len == crypto_box_PUBLICKEYBYTES, "k_id_bin_len");
|
||||
static_assert(k_blob_id_len == (sodium_base64_ENCODED_LEN(crypto_hash_sha256_BYTES, sodium_base64_VARIANT_ORIGINAL) + 8), "k_blob_id_len");
|
||||
@ -579,6 +581,11 @@ static void _tf_ssb_connection_box_stream_send(tf_ssb_connection_t* connection,
|
||||
{
|
||||
size_t send_size = size - offset > k_send_max ? k_send_max : size - offset;
|
||||
uint8_t* message_enc = tf_malloc(send_size + 34);
|
||||
if (!message_enc)
|
||||
{
|
||||
tf_ssb_connection_close(connection, "out of memory");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t nonce1[crypto_secretbox_NONCEBYTES];
|
||||
memcpy(nonce1, connection->send_nonce, sizeof(nonce1));
|
||||
@ -746,13 +753,16 @@ static bool _tf_ssb_connection_get_request_callback(
|
||||
*out_name = request->name;
|
||||
}
|
||||
request->last_active = uv_now(connection->ssb->loop);
|
||||
if (connection->flags & k_tf_ssb_connect_flag_one_shot)
|
||||
if (tf_ssb_connection_is_connected(connection) && !tf_ssb_connection_is_closing(connection) && !tf_ssb_is_shutting_down(tf_ssb_connection_get_ssb(connection)))
|
||||
{
|
||||
uv_timer_start(&connection->activity_timer, _tf_ssb_connection_activity_timer, k_activity_timeout_ms, 0);
|
||||
}
|
||||
if (uv_timer_get_due_in(&connection->ssb->request_activity_timer) == 0)
|
||||
{
|
||||
uv_timer_start(&connection->ssb->request_activity_timer, _tf_ssb_request_activity_timer, k_rpc_active_ms, 0);
|
||||
if ((connection->flags & k_tf_ssb_connect_flag_one_shot))
|
||||
{
|
||||
uv_timer_start(&connection->activity_timer, _tf_ssb_connection_activity_timer, k_activity_timeout_ms, 0);
|
||||
}
|
||||
if (uv_timer_get_due_in(&connection->ssb->request_activity_timer) == 0)
|
||||
{
|
||||
uv_timer_start(&connection->ssb->request_activity_timer, _tf_ssb_request_activity_timer, k_rpc_active_ms, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -799,13 +809,16 @@ void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t requ
|
||||
connection->requests_count++;
|
||||
connection->ssb->request_count++;
|
||||
}
|
||||
if (connection->flags & k_tf_ssb_connect_flag_one_shot)
|
||||
if (tf_ssb_connection_is_connected(connection) && !tf_ssb_connection_is_closing(connection) && !tf_ssb_is_shutting_down(tf_ssb_connection_get_ssb(connection)))
|
||||
{
|
||||
uv_timer_start(&connection->activity_timer, _tf_ssb_connection_activity_timer, k_activity_timeout_ms, 0);
|
||||
}
|
||||
if (uv_timer_get_due_in(&connection->ssb->request_activity_timer) == 0)
|
||||
{
|
||||
uv_timer_start(&connection->ssb->request_activity_timer, _tf_ssb_request_activity_timer, k_rpc_active_ms, 0);
|
||||
if (connection->flags & k_tf_ssb_connect_flag_one_shot)
|
||||
{
|
||||
uv_timer_start(&connection->activity_timer, _tf_ssb_connection_activity_timer, k_activity_timeout_ms, 0);
|
||||
}
|
||||
if (uv_timer_get_due_in(&connection->ssb->request_activity_timer) == 0)
|
||||
{
|
||||
uv_timer_start(&connection->ssb->request_activity_timer, _tf_ssb_request_activity_timer, k_rpc_active_ms, 0);
|
||||
}
|
||||
}
|
||||
_tf_ssb_notify_connections_changed(connection->ssb, k_tf_ssb_change_update, connection);
|
||||
connection->last_notified_active = now_ms;
|
||||
@ -1063,7 +1076,8 @@ void tf_ssb_calculate_message_id(JSContext* context, JSValue message, char* out_
|
||||
JS_FreeValue(context, idval);
|
||||
}
|
||||
|
||||
static bool _tf_ssb_verify_and_strip_signature_internal(JSContext* context, JSValue val, char* out_id, size_t out_id_size, char* out_signature, size_t out_signature_size)
|
||||
static bool _tf_ssb_verify_and_strip_signature_internal(
|
||||
JSContext* context, JSValue val, int verify_flags, char* out_id, size_t out_id_size, char* out_signature, size_t out_signature_size)
|
||||
{
|
||||
JSValue signature = JS_GetPropertyStr(context, val, "signature");
|
||||
if (JS_IsUndefined(signature))
|
||||
@ -1111,6 +1125,16 @@ static bool _tf_ssb_verify_and_strip_signature_internal(JSContext* context, JSVa
|
||||
{
|
||||
r = crypto_sign_verify_detached(binsig, (const uint8_t*)sigstr, strlen(sigstr), publickey);
|
||||
verified = r == 0;
|
||||
if (verify_flags & k_tf_ssb_verify_flag_debug)
|
||||
{
|
||||
tf_printf("verifying author=%s id=%s signature=%s success=%d\n", author, out_id, str, verified);
|
||||
tf_printf("signed string:\n%s\n\n", sigstr);
|
||||
for (int i = 0; sigstr[i]; i++)
|
||||
{
|
||||
tf_printf("%s%02x", (i && (i % 32) == 0) ? "\n" : (i && (i % 8) == 0) ? " " : (i ? " " : ""), sigstr[i]);
|
||||
}
|
||||
tf_printf("\n");
|
||||
}
|
||||
if (!verified)
|
||||
{
|
||||
// tf_printf("crypto_sign_verify_detached fail (r=%d)\n", r);
|
||||
@ -1148,7 +1172,8 @@ static bool _tf_ssb_verify_and_strip_signature_internal(JSContext* context, JSVa
|
||||
return verified;
|
||||
}
|
||||
|
||||
bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* out_id, size_t out_id_size, char* out_signature, size_t out_signature_size, int* out_flags)
|
||||
bool tf_ssb_verify_and_strip_signature(
|
||||
JSContext* context, JSValue val, int verify_flags, char* out_id, size_t out_id_size, char* out_signature, size_t out_signature_size, int* out_flags)
|
||||
{
|
||||
JSValue reordered = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, reordered, "previous", JS_GetPropertyStr(context, val, "previous"));
|
||||
@ -1158,7 +1183,7 @@ bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* ou
|
||||
JS_SetPropertyStr(context, reordered, "hash", JS_GetPropertyStr(context, val, "hash"));
|
||||
JS_SetPropertyStr(context, reordered, "content", JS_GetPropertyStr(context, val, "content"));
|
||||
JS_SetPropertyStr(context, reordered, "signature", JS_GetPropertyStr(context, val, "signature"));
|
||||
bool result = _tf_ssb_verify_and_strip_signature_internal(context, reordered, out_id, out_id_size, out_signature, out_signature_size);
|
||||
bool result = _tf_ssb_verify_and_strip_signature_internal(context, reordered, verify_flags, out_id, out_id_size, out_signature, out_signature_size);
|
||||
JS_FreeValue(context, reordered);
|
||||
|
||||
if (result)
|
||||
@ -1178,7 +1203,7 @@ bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* ou
|
||||
JS_SetPropertyStr(context, reordered, "hash", JS_GetPropertyStr(context, val, "hash"));
|
||||
JS_SetPropertyStr(context, reordered, "content", JS_GetPropertyStr(context, val, "content"));
|
||||
JS_SetPropertyStr(context, reordered, "signature", JS_GetPropertyStr(context, val, "signature"));
|
||||
result = _tf_ssb_verify_and_strip_signature_internal(context, reordered, out_id, out_id_size, out_signature, out_signature_size);
|
||||
result = _tf_ssb_verify_and_strip_signature_internal(context, reordered, verify_flags, out_id, out_id_size, out_signature, out_signature_size);
|
||||
JS_FreeValue(context, reordered);
|
||||
if (result)
|
||||
{
|
||||
@ -1997,7 +2022,7 @@ static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const ch
|
||||
if (!connection->is_closing)
|
||||
{
|
||||
connection->is_closing = true;
|
||||
uv_timer_start(&connection->linger_timer, _tf_ssb_connection_linger_timer, 5000, 0);
|
||||
uv_timer_start(&connection->linger_timer, _tf_ssb_connection_linger_timer, ssb->shutting_down ? 0 : 5000, 0);
|
||||
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_update, connection);
|
||||
}
|
||||
if (connection->connect_callback)
|
||||
@ -2069,6 +2094,11 @@ static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const ch
|
||||
JS_SetOpaque(object, NULL);
|
||||
JS_FreeValue(ssb->context, object);
|
||||
}
|
||||
if (connection->read_back_pressure >= k_read_back_pressure_threshold && connection->tunnel_connection)
|
||||
{
|
||||
tf_ssb_connection_adjust_read_backpressure(connection->tunnel_connection, -1);
|
||||
connection->read_back_pressure = 0;
|
||||
}
|
||||
if (connection->async.data && !uv_is_closing((uv_handle_t*)&connection->async))
|
||||
{
|
||||
uv_close((uv_handle_t*)&connection->async, _tf_ssb_connection_on_close);
|
||||
@ -3871,8 +3901,7 @@ JSValue tf_ssb_connection_get_object(tf_ssb_connection_t* connection)
|
||||
return connection ? connection->object : JS_UNDEFINED;
|
||||
}
|
||||
|
||||
void tf_ssb_add_message_added_callback(
|
||||
tf_ssb_t* ssb, void (*callback)(tf_ssb_t* ssb, const char* id, void* user_data), void (*cleanup)(tf_ssb_t* ssb, void* user_data), void* user_data)
|
||||
void tf_ssb_add_message_added_callback(tf_ssb_t* ssb, tf_ssb_message_added_callback_t* callback, void (*cleanup)(tf_ssb_t* ssb, void* user_data), void* user_data)
|
||||
{
|
||||
tf_ssb_message_added_callback_node_t* node = tf_malloc(sizeof(tf_ssb_message_added_callback_node_t));
|
||||
*node = (tf_ssb_message_added_callback_node_t) {
|
||||
@ -3913,7 +3942,7 @@ void tf_ssb_notify_blob_stored(tf_ssb_t* ssb, const char* id)
|
||||
ssb->blobs_stored++;
|
||||
}
|
||||
|
||||
void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* id, JSValue message_keys)
|
||||
void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* author, int64_t sequence, const char* id, JSValue message_keys)
|
||||
{
|
||||
tf_ssb_message_added_callback_node_t* next = NULL;
|
||||
ssb->messages_stored++;
|
||||
@ -3922,7 +3951,7 @@ void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* id, JSValue message_
|
||||
next = node->next;
|
||||
tf_trace_begin(ssb->trace, "message added callback");
|
||||
PRE_CALLBACK(ssb, node->callback);
|
||||
node->callback(ssb, id, node->user_data);
|
||||
node->callback(ssb, author, sequence, id, node->user_data);
|
||||
POST_CALLBACK(ssb, node->callback);
|
||||
tf_trace_end(ssb->trace);
|
||||
}
|
||||
@ -4145,7 +4174,7 @@ void tf_ssb_verify_strip_and_store_message(tf_ssb_t* ssb, JSValue value, tf_ssb_
|
||||
};
|
||||
char signature[crypto_sign_BYTES + 128] = { 0 };
|
||||
int flags = 0;
|
||||
if (tf_ssb_verify_and_strip_signature(context, value, async->id, sizeof(async->id), signature, sizeof(signature), &flags))
|
||||
if (tf_ssb_verify_and_strip_signature(context, value, 0, async->id, sizeof(async->id), signature, sizeof(signature), &flags))
|
||||
{
|
||||
async->verified = true;
|
||||
tf_ssb_db_store_message(ssb, context, async->id, value, signature, flags, _tf_ssb_verify_strip_and_store_callback, async);
|
||||
@ -4545,19 +4574,32 @@ JSValue tf_ssb_connection_requests_to_object(tf_ssb_connection_t* connection)
|
||||
|
||||
void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection, int delta)
|
||||
{
|
||||
const int k_threshold = 256;
|
||||
int old_pressure = connection->read_back_pressure;
|
||||
connection->read_back_pressure += delta;
|
||||
if (!connection->is_closing)
|
||||
{
|
||||
uv_async_send(&connection->scheduled_async);
|
||||
if (old_pressure < k_threshold && connection->read_back_pressure >= k_threshold)
|
||||
if (old_pressure < k_read_back_pressure_threshold && connection->read_back_pressure >= k_read_back_pressure_threshold)
|
||||
{
|
||||
_tf_ssb_connection_read_stop(connection);
|
||||
if (connection->tunnel_connection)
|
||||
{
|
||||
tf_ssb_connection_adjust_read_backpressure(connection->tunnel_connection, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tf_ssb_connection_read_stop(connection);
|
||||
}
|
||||
}
|
||||
else if (old_pressure >= k_threshold && connection->read_back_pressure < k_threshold)
|
||||
else if (old_pressure >= k_read_back_pressure_threshold && connection->read_back_pressure < k_read_back_pressure_threshold)
|
||||
{
|
||||
_tf_ssb_connection_read_start(connection);
|
||||
if (connection->tunnel_connection)
|
||||
{
|
||||
tf_ssb_connection_adjust_read_backpressure(connection->tunnel_connection, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tf_ssb_connection_read_start(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
connection->ref_count += delta;
|
||||
@ -4570,7 +4612,7 @@ void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection,
|
||||
void tf_ssb_connection_adjust_write_count(tf_ssb_connection_t* connection, int delta)
|
||||
{
|
||||
connection->active_write_count += delta;
|
||||
if (!connection->is_closing)
|
||||
if (!connection->is_closing && connection->active_write_count == 0)
|
||||
{
|
||||
uv_async_send(&connection->scheduled_async);
|
||||
}
|
||||
|
507
src/ssb.db.c
@ -23,6 +23,17 @@ typedef struct _message_store_t message_store_t;
|
||||
|
||||
static void _tf_ssb_db_store_message_after_work(tf_ssb_t* ssb, int status, void* user_data);
|
||||
|
||||
static int _tf_ssb_db_try_exec(sqlite3* db, const char* statement)
|
||||
{
|
||||
char* error = NULL;
|
||||
int result = sqlite3_exec(db, statement, NULL, NULL, &error);
|
||||
if (result != SQLITE_OK)
|
||||
{
|
||||
tf_printf("Error running '%s': %s.\n", statement, error ? error : sqlite3_errmsg(db));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void _tf_ssb_db_exec(sqlite3* db, const char* statement)
|
||||
{
|
||||
char* error = NULL;
|
||||
@ -60,11 +71,17 @@ static bool _tf_ssb_db_has_rows(sqlite3* db, const char* query)
|
||||
return found;
|
||||
}
|
||||
|
||||
static int _tf_ssb_db_busy_handler(void* user_data, int count)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _tf_ssb_db_init_internal(sqlite3* db)
|
||||
{
|
||||
sqlite3_extended_result_codes(db, 1);
|
||||
_tf_ssb_db_exec(db, "PRAGMA journal_mode = WAL");
|
||||
_tf_ssb_db_exec(db, "PRAGMA synchronous = NORMAL");
|
||||
sqlite3_busy_handler(db, _tf_ssb_db_busy_handler, db);
|
||||
}
|
||||
|
||||
void tf_ssb_db_init_reader(sqlite3* db)
|
||||
@ -108,24 +125,48 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
" flags INTEGER,"
|
||||
" UNIQUE(author, sequence)"
|
||||
")");
|
||||
if (_tf_ssb_db_has_rows(db, "PRAGMA table_list('messages_stats')"))
|
||||
{
|
||||
if (_tf_ssb_db_has_rows(db, "SELECT 1 FROM messages_stats WHERE max_sequence IS NULL LIMIT 1"))
|
||||
{
|
||||
tf_printf("Rebuilding messages_stats.\n");
|
||||
_tf_ssb_db_exec(db, "DROP TABLE messages_stats");
|
||||
}
|
||||
else if (!_tf_ssb_db_has_rows(db, "SELECT name FROM pragma_table_info('messages_stats') WHERE name = 'size'"))
|
||||
{
|
||||
tf_printf("Rebuilding messages_stats.\n");
|
||||
_tf_ssb_db_exec(db, "DROP TABLE messages_stats");
|
||||
}
|
||||
}
|
||||
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('messages_stats')"))
|
||||
{
|
||||
_tf_ssb_db_exec(db, "BEGIN TRANSACTION");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS messages_stats ("
|
||||
" author TEXT PRIMARY KEY,"
|
||||
" max_sequence INTEGER,"
|
||||
" max_timestamp READ"
|
||||
" max_sequence INTEGER NOT NULL,"
|
||||
" max_timestamp REAL NOT NULL,"
|
||||
" size INTEGER NOT NULL DEFAULT 0"
|
||||
")");
|
||||
_tf_ssb_db_exec(
|
||||
db, "INSERT OR REPLACE INTO messages_stats (author, max_sequence, max_timestamp) SELECT author, MAX(sequence), MAX(timestamp) FROM messages GROUP BY author");
|
||||
_tf_ssb_db_exec(db,
|
||||
"INSERT OR REPLACE INTO messages_stats (author, max_sequence, max_timestamp, size) SELECT author, MAX(sequence), MAX(timestamp), SUM(length(json(content))) FROM "
|
||||
"messages GROUP BY author");
|
||||
_tf_ssb_db_exec(db, "COMMIT TRANSACTION");
|
||||
}
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ai_stats AFTER INSERT ON messages BEGIN INSERT INTO messages_stats(author, max_sequence, max_timestamp) VALUES (new.author, "
|
||||
"new.sequence, new.timestamp) ON CONFLICT DO UPDATE SET max_sequence = MAX(max_sequence, excluded.max_sequence), max_timestamp = MAX(max_timestamp, "
|
||||
"excluded.max_timestamp); END");
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ai_stats AFTER INSERT ON messages BEGIN INSERT INTO messages_stats(author, max_sequence, max_timestamp, size) VALUES (new.author, "
|
||||
"new.sequence, new.timestamp, length(json(new.content))) ON CONFLICT DO UPDATE SET max_sequence = MAX(max_sequence, new.sequence), max_timestamp = MAX(max_timestamp, "
|
||||
"new.timestamp), size = size + length(json(new.content)); END");
|
||||
_tf_ssb_db_exec(db, "DROP TRIGGER IF EXISTS messages_ad_stats");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ad_stats AFTER DELETE ON messages BEGIN UPDATE messages_stats SET max_sequence = (SELECT MAX(messages.sequence) FROM messages WHERE "
|
||||
"messages.author = old.author), max_timestamp = (SELECT MAX(messages.timestamp) FROM messages WHERE messages.author = old.author); END");
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ad_stats AFTER DELETE ON messages BEGIN "
|
||||
"UPDATE messages_stats SET max_sequence = updated.sequence, max_timestamp = updated.timestamp, size = size - length(json(old.content)) "
|
||||
"FROM ("
|
||||
" SELECT COALESCE(MAX(messages.sequence), 0) AS sequence, COALESCE(MAX(messages.timestamp), 0) AS timestamp "
|
||||
" FROM messages WHERE messages.author = old.author) AS updated "
|
||||
"WHERE messages_stats.author = old.author; "
|
||||
"DELETE FROM messages_stats WHERE messages_stats.author = old.author AND messages_stats.max_sequence = 0; "
|
||||
"END");
|
||||
|
||||
if (_tf_ssb_db_has_rows(db, "SELECT name FROM pragma_table_info('messages') WHERE name = 'content' AND type == 'TEXT'"))
|
||||
{
|
||||
@ -149,13 +190,20 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
_tf_ssb_db_exec(db, "ALTER TABLE messages RENAME COLUMN sequence_before_author TO flags");
|
||||
}
|
||||
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_author_id_index ON messages (author, id)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_id_author_index ON messages (id, author)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_author_sequence_index ON messages (author, sequence)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_author_timestamp_index ON messages (author, timestamp)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_timestamp_index ON messages (timestamp)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_type_timestamp_index ON messages (content ->> 'type', timestamp)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_size_by_author_index ON messages (author, length(content))");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_type_author_channel_index ON messages (content ->> 'type', author, content ->> 'channel');");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_type_author_channel_root_timestamp_index ");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_channel_author_timestamp_root_index ON messages (content ->> 'channel', author, timestamp, content ->> 'root')");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_type_author_channel_index");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_author_id_index");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_by_author_index");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_timestamp_author_index");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_id_index");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_type_author_channel_root_rowid_index");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS blobs ("
|
||||
" id TEXT PRIMARY KEY,"
|
||||
@ -228,6 +276,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
|
||||
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('messages_refs')"))
|
||||
{
|
||||
_tf_ssb_db_exec(db, "BEGIN TRANSACTION");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS messages_refs ("
|
||||
" message TEXT, "
|
||||
@ -237,11 +286,12 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
tf_printf("Populating messages_refs...\n");
|
||||
_tf_ssb_db_exec(db,
|
||||
"INSERT INTO messages_refs(message, ref) "
|
||||
"SELECT messages.id, j.value FROM messages, json_tree(messages.content) as j WHERE "
|
||||
"SELECT messages.id, j.value FROM messages, json_tree(messages.content) AS j WHERE "
|
||||
"j.value LIKE '&%.sha256' OR "
|
||||
"j.value LIKE '%%%.sha256' OR "
|
||||
"j.value LIKE '@%.ed25519' "
|
||||
"ON CONFLICT DO NOTHING");
|
||||
_tf_ssb_db_exec(db, "COMMIT TRANSACTION");
|
||||
tf_printf("Done.\n");
|
||||
}
|
||||
|
||||
@ -249,7 +299,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ai_refs AFTER INSERT ON messages BEGIN "
|
||||
"INSERT INTO messages_refs(message, ref) "
|
||||
"SELECT DISTINCT new.id, j.value FROM json_tree(new.content) as j WHERE "
|
||||
"SELECT DISTINCT new.id, j.value FROM json_tree(new.content) AS j WHERE "
|
||||
"j.value LIKE '&%.sha256' OR "
|
||||
"j.value LIKE '%%%.sha256' OR "
|
||||
"j.value LIKE '@%.ed25519' "
|
||||
@ -257,26 +307,98 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
_tf_ssb_db_exec(db, "DROP TRIGGER IF EXISTS messages_ad_refs");
|
||||
_tf_ssb_db_exec(db, "CREATE TRIGGER IF NOT EXISTS messages_ad_refs AFTER DELETE ON messages BEGIN DELETE FROM messages_refs WHERE messages_refs.message = old.id; END");
|
||||
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_refs_message_idx ON messages_refs (message)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS messages_refs_ref_idx ON messages_refs (ref)");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_refs_message_idx");
|
||||
_tf_ssb_db_exec(db, "DROP INDEX IF EXISTS messages_refs_ref_idx");
|
||||
_tf_ssb_db_exec(db, "CREATE UNIQUE INDEX IF NOT EXISTS messages_refs_message_ref_idx ON messages_refs (message, ref)");
|
||||
_tf_ssb_db_exec(db, "CREATE UNIQUE INDEX IF NOT EXISTS messages_refs_ref_message_idx ON messages_refs (ref, message)");
|
||||
|
||||
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('blobs_refs')"))
|
||||
{
|
||||
_tf_ssb_db_exec(db, "BEGIN TRANSACTION");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS blobs_refs ("
|
||||
" blob TEXT, "
|
||||
" ref TEXT, "
|
||||
" UNIQUE(blob, ref)"
|
||||
")");
|
||||
tf_printf("Populating blobs_refs...\n");
|
||||
_tf_ssb_db_exec(db,
|
||||
"INSERT INTO blobs_refs(blob, ref) "
|
||||
"SELECT blobs.id, j.value FROM blobs, json_tree(blobs.content) AS j WHERE "
|
||||
"json_valid(blobs.content) AND j.value LIKE '&%.sha256' "
|
||||
"ON CONFLICT DO NOTHING");
|
||||
_tf_ssb_db_exec(db, "COMMIT TRANSACTION");
|
||||
tf_printf("Done.\n");
|
||||
}
|
||||
_tf_ssb_db_exec(db, "DROP TRIGGER IF EXISTS blobs_ai_refs");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS blobs_ai_refs AFTER INSERT ON blobs BEGIN "
|
||||
"INSERT INTO blobs_refs(blob, ref) "
|
||||
"SELECT DISTINCT new.id, j.value FROM json_tree(new.content) AS j WHERE "
|
||||
"json_valid(new.content) AND j.value LIKE '&%.sha256' "
|
||||
"ON CONFLICT DO NOTHING; END");
|
||||
_tf_ssb_db_exec(db, "DROP TRIGGER IF EXISTS blobs_ad_refs");
|
||||
_tf_ssb_db_exec(db, "CREATE TRIGGER IF NOT EXISTS blobs_ad_refs AFTER DELETE ON blobs BEGIN DELETE FROM blobs_refs WHERE blobs_refs.blob = old.id; END");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS blobs_refs_blob_idx ON blobs_refs (blob)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS blobs_refs_ref_idx ON blobs_refs (ref)");
|
||||
|
||||
_tf_ssb_db_exec(db, "DROP VIEW IF EXISTS blob_wants_view");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE VIEW IF NOT EXISTS blob_wants_view (id, timestamp) AS "
|
||||
" WITH wanted AS ( "
|
||||
" SELECT messages_refs.ref AS id, messages.timestamp AS timestamp "
|
||||
"CREATE VIEW IF NOT EXISTS blob_wants_view (source, id, timestamp) AS "
|
||||
" WITH RECURSIVE "
|
||||
" wanted1 AS ( "
|
||||
" SELECT messages_refs.message AS source, messages_refs.ref AS id, messages.timestamp AS timestamp "
|
||||
" FROM messages_refs "
|
||||
" JOIN messages ON messages.id = messages_refs.message "
|
||||
" UNION "
|
||||
" SELECT messages_refs.ref AS id, unixepoch() * 1000 AS timestamp "
|
||||
" SELECT messages_refs.message AS source, messages_refs.ref AS id, unixepoch() * 1000 AS timestamp "
|
||||
" FROM messages_refs "
|
||||
" JOIN messages ON messages.id = messages_refs.message "
|
||||
" WHERE messages.content ->> 'type' = 'about' "
|
||||
" ), "
|
||||
" wanted(source, id, timestamp) AS ( "
|
||||
" SELECT wanted1.source AS source, wanted1.id AS id, wanted1.timestamp AS timestamp FROM wanted1 "
|
||||
" UNION "
|
||||
" SELECT wanted.source AS source, br.ref AS id, wanted.timestamp AS timestamp FROM wanted JOIN blobs_refs br ON br.blob = wanted.id "
|
||||
" ) "
|
||||
" SELECT wanted.id, wanted.timestamp FROM wanted "
|
||||
" SELECT wanted.source, wanted.id, wanted.timestamp FROM wanted "
|
||||
" LEFT OUTER JOIN blobs ON wanted.id = blobs.id "
|
||||
" WHERE blobs.id IS NULL "
|
||||
" AND LENGTH(wanted.id) = 52 "
|
||||
" AND wanted.id LIKE '&%.sha256'");
|
||||
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('blob_wants_cache')"))
|
||||
{
|
||||
tf_printf("Populating blob_wants_cache...\n");
|
||||
_tf_ssb_db_exec(db, "BEGIN TRANSACTION");
|
||||
_tf_ssb_db_exec(db, "CREATE TABLE IF NOT EXISTS blob_wants_cache (source TEXT, id TEXT, timestamp REAL, UNIQUE(source, id))");
|
||||
_tf_ssb_db_exec(
|
||||
db, "INSERT INTO blob_wants_cache SELECT * FROM blob_wants_view WHERE true ON CONFLICT(source, id) DO UPDATE SET timestamp = MAX(timestamp, excluded.timestamp)");
|
||||
_tf_ssb_db_exec(db, "COMMIT TRANSACTION");
|
||||
tf_printf("Done.\n");
|
||||
}
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS blob_wants_cache_id_idx ON blob_wants_cache (id)");
|
||||
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS blob_wants_cache_timestamp_id_idx ON blob_wants_cache (timestamp, id)");
|
||||
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ai_blob_wants_cache AFTER INSERT ON messages_refs BEGIN "
|
||||
"INSERT INTO blob_wants_cache (source, id, timestamp) "
|
||||
"SELECT messages.id, new.ref, messages.timestamp FROM messages WHERE messages.id = new.message AND "
|
||||
"LENGTH(new.ref) = 52 AND new.ref LIKE '&%.sha256' "
|
||||
"ON CONFLICT (source, id) DO NOTHING; END");
|
||||
_tf_ssb_db_exec(db, "DROP TRIGGER IF EXISTS blobs_refs_ai_blob_wants_cache");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS blobs_refs_ai_blob_wants_cache AFTER INSERT ON blobs_refs BEGIN "
|
||||
"INSERT INTO blob_wants_cache (source, id, timestamp) "
|
||||
"SELECT messages.id, new.ref, messages.timestamp FROM messages "
|
||||
"JOIN blob_wants_cache bwc ON bwc.source = messages.id AND bwc.id = new.blob "
|
||||
"ON CONFLICT (source, id) DO NOTHING; END");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ad_blob_wants_cache AFTER DELETE ON messages BEGIN "
|
||||
"DELETE FROM blob_wants_cache WHERE blob_wants_cache.source = old.id; END");
|
||||
_tf_ssb_db_exec(db, "DROP TRIGGER IF EXISTS blobs_ai_blob_wants_cache");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS blobs_ai_blob_wants_cache AFTER INSERT ON blobs BEGIN "
|
||||
"DELETE FROM blob_wants_cache WHERE blob_wants_cache.id = new.id; END");
|
||||
|
||||
bool need_add_flags = true;
|
||||
bool need_convert_timestamp_to_real = false;
|
||||
@ -344,10 +466,9 @@ static bool _tf_ssb_db_previous_message_exists(sqlite3* db, const char* author,
|
||||
return exists;
|
||||
}
|
||||
|
||||
static int64_t _tf_ssb_db_store_message_raw(tf_ssb_t* ssb, const char* id, const char* previous, const char* author, int64_t sequence, double timestamp, const char* content,
|
||||
static int64_t _tf_ssb_db_store_message_raw(sqlite3* db, const char* id, const char* previous, const char* author, int64_t sequence, double timestamp, const char* content,
|
||||
size_t content_len, const char* signature, int flags)
|
||||
{
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
int64_t last_row_id = -1;
|
||||
bool id_mismatch = false;
|
||||
|
||||
@ -396,7 +517,6 @@ static int64_t _tf_ssb_db_store_message_raw(tf_ssb_t* ssb, const char* id, const
|
||||
*/
|
||||
tf_printf("%p: Previous message doesn't exist for author=%s sequence=%" PRId64 " previous=%s.\n", db, author, sequence, previous);
|
||||
}
|
||||
tf_ssb_release_db_writer(ssb, db);
|
||||
return last_row_id;
|
||||
}
|
||||
|
||||
@ -469,30 +589,47 @@ typedef struct _message_store_t
|
||||
static void _tf_ssb_db_store_message_work(tf_ssb_t* ssb, void* user_data)
|
||||
{
|
||||
message_store_t* store = user_data;
|
||||
int64_t last_row_id = _tf_ssb_db_store_message_raw(
|
||||
ssb, store->id, *store->previous ? store->previous : NULL, store->author, store->sequence, store->timestamp, store->content, store->length, store->signature, store->flags);
|
||||
if (last_row_id != -1)
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
bool in_transaction = _tf_ssb_db_try_exec(db, "BEGIN TRANSACTION") == SQLITE_OK;
|
||||
|
||||
while (store)
|
||||
{
|
||||
store->out_stored = true;
|
||||
store->out_blob_wants = _tf_ssb_db_get_message_blob_wants(ssb, last_row_id);
|
||||
int64_t last_row_id = _tf_ssb_db_store_message_raw(db, store->id, *store->previous ? store->previous : NULL, store->author, store->sequence, store->timestamp,
|
||||
store->content, store->length, store->signature, store->flags);
|
||||
if (last_row_id != -1)
|
||||
{
|
||||
store->out_stored = true;
|
||||
store->out_blob_wants = _tf_ssb_db_get_message_blob_wants(ssb, last_row_id);
|
||||
}
|
||||
store = store->next;
|
||||
}
|
||||
|
||||
if (in_transaction)
|
||||
{
|
||||
if (_tf_ssb_db_try_exec(db, "COMMIT TRANSACTION") != SQLITE_OK)
|
||||
{
|
||||
store = user_data;
|
||||
while (store)
|
||||
{
|
||||
store->out_stored = false;
|
||||
store = store->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
tf_ssb_release_db_writer(ssb, db);
|
||||
}
|
||||
|
||||
static void _wake_up_queue(tf_ssb_t* ssb, tf_ssb_store_queue_t* queue)
|
||||
{
|
||||
if (!queue->running)
|
||||
{
|
||||
message_store_t* next = queue->head;
|
||||
if (next)
|
||||
message_store_t* stores = queue->head;
|
||||
queue->head = NULL;
|
||||
queue->tail = NULL;
|
||||
if (stores)
|
||||
{
|
||||
queue->head = next->next;
|
||||
if (queue->tail == next)
|
||||
{
|
||||
queue->tail = NULL;
|
||||
}
|
||||
next->next = NULL;
|
||||
queue->running = true;
|
||||
tf_ssb_run_work(ssb, _tf_ssb_db_store_message_work, _tf_ssb_db_store_message_after_work, next);
|
||||
tf_ssb_run_work(ssb, _tf_ssb_db_store_message_work, _tf_ssb_db_store_message_after_work, stores);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -501,43 +638,63 @@ static void _tf_ssb_db_store_message_after_work(tf_ssb_t* ssb, int status, void*
|
||||
{
|
||||
message_store_t* store = user_data;
|
||||
tf_trace_t* trace = tf_ssb_get_trace(ssb);
|
||||
if (store->out_stored)
|
||||
|
||||
message_store_t* last_stored = NULL;
|
||||
|
||||
while (store)
|
||||
{
|
||||
if (store->out_stored)
|
||||
{
|
||||
last_stored = store;
|
||||
}
|
||||
if (store->out_blob_wants)
|
||||
{
|
||||
tf_trace_begin(trace, "notify_blob_wants_added");
|
||||
for (char* p = store->out_blob_wants; *p; p = p + strlen(p))
|
||||
{
|
||||
tf_ssb_notify_blob_want_added(ssb, p);
|
||||
}
|
||||
tf_free(store->out_blob_wants);
|
||||
tf_trace_end(trace);
|
||||
}
|
||||
|
||||
if (store->callback)
|
||||
{
|
||||
store->callback(store->id, store->out_stored, store->user_data);
|
||||
}
|
||||
store = store->next;
|
||||
}
|
||||
|
||||
if (last_stored)
|
||||
{
|
||||
tf_trace_begin(trace, "notify_message_added");
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
JSValue formatted =
|
||||
tf_ssb_format_message(context, store->previous, store->author, store->sequence, store->timestamp, "sha256", store->content, store->signature, store->flags);
|
||||
JSValue formatted = tf_ssb_format_message(context, last_stored->previous, last_stored->author, last_stored->sequence, last_stored->timestamp, "sha256",
|
||||
last_stored->content, last_stored->signature, last_stored->flags);
|
||||
JSValue message = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, message, "key", JS_NewString(context, store->id));
|
||||
JS_SetPropertyStr(context, message, "key", JS_NewString(context, last_stored->id));
|
||||
JS_SetPropertyStr(context, message, "value", formatted);
|
||||
char timestamp_string[256];
|
||||
snprintf(timestamp_string, sizeof(timestamp_string), "%f", store->timestamp);
|
||||
snprintf(timestamp_string, sizeof(timestamp_string), "%f", last_stored->timestamp);
|
||||
JS_SetPropertyStr(context, message, "timestamp", JS_NewString(context, timestamp_string));
|
||||
tf_ssb_notify_message_added(ssb, store->id, message);
|
||||
tf_ssb_notify_message_added(ssb, last_stored->author, last_stored->sequence, last_stored->id, message);
|
||||
JS_FreeValue(context, message);
|
||||
tf_trace_end(trace);
|
||||
}
|
||||
if (store->out_blob_wants)
|
||||
{
|
||||
tf_trace_begin(trace, "notify_blob_wants_added");
|
||||
for (char* p = store->out_blob_wants; *p; p = p + strlen(p))
|
||||
{
|
||||
tf_ssb_notify_blob_want_added(ssb, p);
|
||||
}
|
||||
tf_free(store->out_blob_wants);
|
||||
tf_trace_end(trace);
|
||||
}
|
||||
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
if (store->callback)
|
||||
store = user_data;
|
||||
while (store)
|
||||
{
|
||||
store->callback(store->id, store->out_stored, store->user_data);
|
||||
JS_FreeCString(context, store->content);
|
||||
message_store_t* last = store;
|
||||
store = store->next;
|
||||
tf_free(last);
|
||||
}
|
||||
JS_FreeCString(context, store->content);
|
||||
|
||||
tf_ssb_store_queue_t* queue = tf_ssb_get_store_queue(ssb);
|
||||
queue->running = false;
|
||||
_wake_up_queue(ssb, queue);
|
||||
tf_free(store);
|
||||
}
|
||||
|
||||
void tf_ssb_db_store_message(
|
||||
@ -788,7 +945,12 @@ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char*
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, id, -1, NULL) == SQLITE_OK && sqlite3_bind_blob(statement, 2, blob, size, NULL) == SQLITE_OK)
|
||||
{
|
||||
result = sqlite3_step(statement) == SQLITE_DONE;
|
||||
int r = sqlite3_step(statement);
|
||||
result = r == SQLITE_DONE;
|
||||
if (!result)
|
||||
{
|
||||
tf_printf("Blob store failed (%s: %zd): %s / %s.\n", id, size, sqlite3_errstr(r), sqlite3_errmsg(db));
|
||||
}
|
||||
rows = sqlite3_changes(db);
|
||||
}
|
||||
else
|
||||
@ -880,27 +1042,52 @@ bool tf_ssb_db_get_latest_message_by_author(tf_ssb_t* ssb, const char* author, i
|
||||
bool found = false;
|
||||
sqlite3_stmt* statement;
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
const char* query = "SELECT id, sequence FROM messages WHERE author = ?1 AND sequence = (SELECT MAX(sequence) FROM messages WHERE author = ?1)";
|
||||
if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK)
|
||||
|
||||
if (out_message_id)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, author, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW)
|
||||
const char* query = "SELECT id, sequence FROM messages WHERE author = ?1 ORDER BY sequence DESC LIMIT 1";
|
||||
if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (out_sequence)
|
||||
if (sqlite3_bind_text(statement, 1, author, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
*out_sequence = sqlite3_column_int64(statement, 1);
|
||||
if (out_sequence)
|
||||
{
|
||||
*out_sequence = sqlite3_column_int64(statement, 1);
|
||||
}
|
||||
if (out_message_id)
|
||||
{
|
||||
strncpy(out_message_id, (const char*)sqlite3_column_text(statement, 0), out_message_id_size - 1);
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
if (out_message_id)
|
||||
{
|
||||
strncpy(out_message_id, (const char*)sqlite3_column_text(statement, 0), out_message_id_size - 1);
|
||||
}
|
||||
found = true;
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("%s: prepare failed: %s\n", __FUNCTION__, sqlite3_errmsg(db));
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("%s: prepare failed: %s\n", __FUNCTION__, sqlite3_errmsg(db));
|
||||
const char* query = "SELECT max_sequence FROM messages_stats WHERE author = ?1";
|
||||
if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, author, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
if (out_sequence)
|
||||
{
|
||||
*out_sequence = sqlite3_column_int64(statement, 0);
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("%s: prepare failed: %s\n", __FUNCTION__, sqlite3_errmsg(db));
|
||||
}
|
||||
}
|
||||
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
return found;
|
||||
}
|
||||
@ -1004,8 +1191,8 @@ int tf_ssb_sqlite_authorizer(void* user_data, int action_code, const char* arg0,
|
||||
result = SQLITE_OK;
|
||||
break;
|
||||
case SQLITE_READ:
|
||||
result = (strcmp(arg0, "blob_wants_view") == 0 || strcmp(arg0, "json_each") == 0 || strcmp(arg0, "json_tree") == 0 || strcmp(arg0, "messages") == 0 ||
|
||||
strcmp(arg0, "messages_stats") == 0 || strcmp(arg0, "messages_fts") == 0 || strcmp(arg0, "messages_fts_idx") == 0 ||
|
||||
result = (strcmp(arg0, "blob_wants_cache") == 0 || strcmp(arg0, "blob_wants_view") == 0 || strcmp(arg0, "json_each") == 0 || strcmp(arg0, "json_tree") == 0 ||
|
||||
strcmp(arg0, "messages") == 0 || strcmp(arg0, "messages_stats") == 0 || strcmp(arg0, "messages_fts") == 0 || strcmp(arg0, "messages_fts_idx") == 0 ||
|
||||
strcmp(arg0, "messages_fts_config") == 0 || strcmp(arg0, "messages_refs") == 0 || strcmp(arg0, "messages_refs_message_idx") == 0 ||
|
||||
strcmp(arg0, "messages_refs_ref_idx") == 0 || strcmp(arg0, "sqlite_master") == 0 || false)
|
||||
? SQLITE_OK
|
||||
@ -1277,7 +1464,7 @@ static int _following_compare(const void* a, const void* b)
|
||||
|
||||
static bool _has_following_entry(const char* id, following_t** list, int count)
|
||||
{
|
||||
return count ? bsearch(id, list, count, sizeof(following_t*), _following_compare) != 0 : false;
|
||||
return count ? bsearch(id, list, count, sizeof(following_t*), _following_compare) != NULL : false;
|
||||
}
|
||||
|
||||
static bool _add_following_entry(following_t*** list, int* count, following_t* add)
|
||||
@ -1367,9 +1554,9 @@ static void _populate_follows_and_blocks(tf_ssb_t* ssb, following_t* entry, foll
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
sqlite3_stmt* statement = NULL;
|
||||
if (sqlite3_prepare(db,
|
||||
"SELECT json_extract(content, '$.contact') AS contact, json_extract(content, '$.following'), json_extract(content, '$.blocking') "
|
||||
"SELECT content ->> '$.contact' AS contact, content ->> '$.following', content ->> '$.blocking' "
|
||||
"FROM messages "
|
||||
"WHERE contact IS NOT NULL AND author = ? AND json_extract(content, '$.type') = 'contact' "
|
||||
"WHERE contact IS NOT NULL AND author = ? AND content ->> '$.type' = 'contact' "
|
||||
"ORDER BY sequence",
|
||||
-1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
@ -1432,21 +1619,22 @@ static void _populate_follows_and_blocks(tf_ssb_t* ssb, following_t* entry, foll
|
||||
static void _get_following(
|
||||
tf_ssb_t* ssb, following_t* entry, following_t*** following, int* following_count, int depth, int max_depth, block_node_t* active_blocks, bool include_blocks)
|
||||
{
|
||||
int old_depth = entry->depth;
|
||||
entry->depth = tf_min(depth, entry->depth);
|
||||
if (depth < max_depth && !entry->populated && !_is_blocked_by_active_blocks(entry->id, active_blocks))
|
||||
if (depth < max_depth && depth < old_depth)
|
||||
{
|
||||
entry->populated = true;
|
||||
_populate_follows_and_blocks(ssb, entry, following, following_count, active_blocks, include_blocks);
|
||||
|
||||
if (depth < max_depth)
|
||||
if (!_is_blocked_by_active_blocks(entry->id, active_blocks))
|
||||
{
|
||||
if (!entry->populated)
|
||||
{
|
||||
entry->populated = true;
|
||||
_populate_follows_and_blocks(ssb, entry, following, following_count, active_blocks, include_blocks);
|
||||
}
|
||||
|
||||
block_node_t blocks = { .entry = entry, .parent = active_blocks };
|
||||
for (int i = 0; i < entry->following_count; i++)
|
||||
{
|
||||
if (!_has_following_entry(entry->following[i]->id, entry->blocking, entry->blocking_count))
|
||||
{
|
||||
_get_following(ssb, entry->following[i], following, following_count, depth + 1, max_depth, &blocks, include_blocks);
|
||||
}
|
||||
_get_following(ssb, entry->following[i], following, following_count, depth + 1, max_depth, &blocks, include_blocks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1959,7 +2147,25 @@ void tf_ssb_db_resolve_index_async(tf_ssb_t* ssb, const char* host, void (*callb
|
||||
tf_ssb_run_work(ssb, _tf_ssb_db_resolve_index_work, _tf_ssb_db_resolve_index_after_work, request);
|
||||
}
|
||||
|
||||
bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id)
|
||||
static void _tf_ssb_db_set_flags(tf_ssb_t* ssb, const char* message_id, int flags)
|
||||
{
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
sqlite3_stmt* statement = NULL;
|
||||
if (sqlite3_prepare(db, "UPDATE messages SET flags = ? WHERE id = ?", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_int(statement, 1, flags) == SQLITE_OK && sqlite3_bind_text(statement, 2, message_id, -1, NULL) == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_step(statement) != SQLITE_DONE)
|
||||
{
|
||||
tf_printf("Setting flags of %s to %d failed: %s.\n", message_id, flags, sqlite3_errmsg(db));
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
tf_ssb_release_db_writer(ssb, db);
|
||||
}
|
||||
|
||||
bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id, int64_t debug_sequence, bool fix)
|
||||
{
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
bool verified = true;
|
||||
@ -1982,7 +2188,8 @@ bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id)
|
||||
char calculated_id[k_id_base64_len];
|
||||
char extracted_signature[256];
|
||||
int calculated_flags = 0;
|
||||
if (!tf_ssb_verify_and_strip_signature(context, message, calculated_id, sizeof(calculated_id), extracted_signature, sizeof(extracted_signature), &calculated_flags))
|
||||
if (!tf_ssb_verify_and_strip_signature(context, message, i == debug_sequence ? k_tf_ssb_verify_flag_debug : 0, calculated_id, sizeof(calculated_id),
|
||||
extracted_signature, sizeof(extracted_signature), &calculated_flags))
|
||||
{
|
||||
tf_printf("author=%s sequence=%" PRId64 " verify failed.\n", id, i);
|
||||
verified = false;
|
||||
@ -1990,7 +2197,14 @@ bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id)
|
||||
if (calculated_flags != flags)
|
||||
{
|
||||
tf_printf("author=%s sequence=%" PRId64 " flag mismatch %d => %d.\n", id, i, flags, calculated_flags);
|
||||
verified = false;
|
||||
if (fix)
|
||||
{
|
||||
_tf_ssb_db_set_flags(ssb, message_id, calculated_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
verified = false;
|
||||
}
|
||||
}
|
||||
if (strcmp(message_id, calculated_id))
|
||||
{
|
||||
@ -2204,7 +2418,7 @@ const char* tf_ssb_db_get_profile_name(sqlite3* db, const char* id)
|
||||
if (sqlite3_prepare(db,
|
||||
"SELECT name FROM (SELECT messages.author, RANK() OVER (PARTITION BY messages.author ORDER BY messages.sequence DESC) AS author_rank, "
|
||||
"messages.content ->> 'name' AS name FROM messages WHERE messages.author = ? "
|
||||
"AND json_extract(messages.content, '$.type') = 'about' AND content ->> 'about' = messages.author AND name IS NOT NULL) "
|
||||
"AND messages.content ->> '$.type' = 'about' AND content ->> 'about' = messages.author AND name IS NOT NULL) "
|
||||
"WHERE author_rank = 1",
|
||||
-1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
@ -2330,3 +2544,120 @@ bool tf_ssb_db_has_invite(sqlite3* db, const char* id)
|
||||
}
|
||||
return has;
|
||||
}
|
||||
|
||||
static void _tf_ssb_db_get_identity_info_visit(const char* identity, void* user_data)
|
||||
{
|
||||
tf_ssb_identity_info_t* info = user_data;
|
||||
info->identity = tf_resize_vec(info->identity, (info->count + 1) * sizeof(char*));
|
||||
info->name = tf_resize_vec(info->name, (info->count + 1) * sizeof(char*));
|
||||
char buffer[k_id_base64_len];
|
||||
snprintf(buffer, sizeof(buffer), "@%s", identity);
|
||||
info->identity[info->count] = tf_strdup(buffer);
|
||||
info->name[info->count] = NULL;
|
||||
info->count++;
|
||||
}
|
||||
|
||||
tf_ssb_identity_info_t* tf_ssb_db_get_identity_info(tf_ssb_t* ssb, const char* user, const char* package_owner, const char* package_name)
|
||||
{
|
||||
tf_ssb_identity_info_t* info = tf_malloc(sizeof(tf_ssb_identity_info_t));
|
||||
*info = (tf_ssb_identity_info_t) { 0 };
|
||||
|
||||
char id[k_id_base64_len] = "";
|
||||
if (tf_ssb_db_user_has_permission(ssb, NULL, user, "administration"))
|
||||
{
|
||||
if (tf_ssb_whoami(ssb, id, sizeof(id)))
|
||||
{
|
||||
_tf_ssb_db_get_identity_info_visit(*id == '@' ? id + 1 : id, info);
|
||||
}
|
||||
}
|
||||
tf_ssb_db_identity_visit(ssb, user, _tf_ssb_db_get_identity_info_visit, info);
|
||||
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
sqlite3_stmt* statement = NULL;
|
||||
int result = sqlite3_prepare(db,
|
||||
"SELECT author, name FROM ( "
|
||||
" SELECT "
|
||||
" messages.author, "
|
||||
" RANK() OVER (PARTITION BY messages.author ORDER BY messages.sequence DESC) AS author_rank, "
|
||||
" messages.content ->> 'name' AS name "
|
||||
" FROM messages "
|
||||
" JOIN identities ON messages.author = ('@' || identities.public_key) "
|
||||
" WHERE "
|
||||
" (identities.user = ? OR identities.public_key = ?) AND "
|
||||
" messages.content ->> '$.type' = 'about' AND "
|
||||
" content ->> 'about' = messages.author AND name IS NOT NULL) "
|
||||
"WHERE author_rank = 1 ",
|
||||
-1, &statement, NULL);
|
||||
if (result == SQLITE_OK)
|
||||
{
|
||||
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 2, *id == '@' ? id + 1 : id, -1, NULL) == SQLITE_OK)
|
||||
{
|
||||
int r = SQLITE_OK;
|
||||
while ((r = sqlite3_step(statement)) == SQLITE_ROW)
|
||||
{
|
||||
const char* identity = (const char*)sqlite3_column_text(statement, 0);
|
||||
const char* name = (const char*)sqlite3_column_text(statement, 1);
|
||||
for (int i = 0; i < info->count; i++)
|
||||
{
|
||||
if (!info->name[i] && strcmp(info->identity[i], identity) == 0)
|
||||
{
|
||||
info->name[i] = tf_strdup(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("prepare failed: %s.\n", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
tf_ssb_db_identity_get_active(db, user, package_owner, package_name, info->active_identity, sizeof(info->active_identity));
|
||||
if (!*info->active_identity && info->count)
|
||||
{
|
||||
snprintf(info->active_identity, sizeof(info->active_identity), "%s", info->identity[0]);
|
||||
}
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
|
||||
size_t size = sizeof(tf_ssb_identity_info_t) + sizeof(char*) * info->count * 2;
|
||||
for (int i = 0; i < info->count; i++)
|
||||
{
|
||||
size += strlen(info->identity[i]) + 1;
|
||||
size += info->name[i] ? strlen(info->name[i]) + 1 : 0;
|
||||
}
|
||||
tf_ssb_identity_info_t* copy = tf_malloc(size);
|
||||
*copy = *info;
|
||||
|
||||
copy->identity = (const char**)(copy + 1);
|
||||
copy->name = (const char**)(copy + 1) + copy->count;
|
||||
|
||||
char* p = (char*)((const char**)(copy + 1) + copy->count * 2);
|
||||
|
||||
for (int i = 0; i < info->count; i++)
|
||||
{
|
||||
size_t length = strlen(info->identity[i]);
|
||||
memcpy(p, info->identity[i], length + 1);
|
||||
copy->identity[i] = p;
|
||||
p += length + 1;
|
||||
tf_free((void*)info->identity[i]);
|
||||
|
||||
if (info->name[i])
|
||||
{
|
||||
length = strlen(info->name[i]);
|
||||
memcpy(p, info->name[i], length + 1);
|
||||
copy->name[i] = p;
|
||||
p += length + 1;
|
||||
tf_free((void*)info->name[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy->name[i] = NULL;
|
||||
}
|
||||
}
|
||||
tf_free(info->name);
|
||||
tf_free(info->identity);
|
||||
tf_free(info);
|
||||
return copy;
|
||||
}
|
||||
|
29
src/ssb.db.h
@ -444,9 +444,11 @@ void tf_ssb_db_resolve_index_async(tf_ssb_t* ssb, const char* host, void (*callb
|
||||
** Verify an author's feed.
|
||||
** @param ssb The SSB instance.
|
||||
** @param id The author'd identity.
|
||||
** @param debug_sequence Message sequence number to debug if non-zero.
|
||||
** @param fix Fix invalid messages when possible.
|
||||
** @return true If the feed verified successfully.
|
||||
*/
|
||||
bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id);
|
||||
bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id, int64_t debug_sequence, bool fix);
|
||||
|
||||
/**
|
||||
** Check if a user has a specific permission.
|
||||
@ -564,4 +566,29 @@ int tf_ssb_sqlite_authorizer(void* user_data, int action_code, const char* arg0,
|
||||
*/
|
||||
bool tf_ssb_db_has_invite(sqlite3* db, const char* id);
|
||||
|
||||
/**
|
||||
** Identity information
|
||||
*/
|
||||
typedef struct _tf_ssb_identity_info_t
|
||||
{
|
||||
/** An array of identities. */
|
||||
const char** identity;
|
||||
/** A array of identities, one for each identity. */
|
||||
const char** name;
|
||||
/** The number of elements in both the identity and name arrays. */
|
||||
int count;
|
||||
/** The active identity. */
|
||||
char active_identity[k_id_base64_len];
|
||||
} tf_ssb_identity_info_t;
|
||||
|
||||
/**
|
||||
** Get available identities, names, and the active identity for a user.
|
||||
** @param ssb The SSB instance.
|
||||
** @param user The user name.
|
||||
** @param package_owner The owner of the package for which identity info is being fetched.
|
||||
** @param package_name The name of the package for which identity info is being fetched.
|
||||
** @return A struct of identities, names, and the active identity. Free with tf_free().
|
||||
*/
|
||||
tf_ssb_identity_info_t* tf_ssb_db_get_identity_info(tf_ssb_t* ssb, const char* user, const char* package_owner, const char* package_name);
|
||||
|
||||
/** @} */
|
||||
|
170
src/ssb.ebt.c
@ -7,6 +7,7 @@
|
||||
|
||||
#include "uv.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct _ebt_entry_t
|
||||
@ -29,6 +30,9 @@ typedef struct _tf_ssb_ebt_t
|
||||
int entries_count;
|
||||
|
||||
int send_clock_pending;
|
||||
|
||||
int max_in;
|
||||
int max_out;
|
||||
} tf_ssb_ebt_t;
|
||||
|
||||
tf_ssb_ebt_t* tf_ssb_ebt_create(tf_ssb_connection_t* connection)
|
||||
@ -55,8 +59,33 @@ static int _ebt_entry_compare(const void* a, const void* b)
|
||||
return strcmp(id, entry->id);
|
||||
}
|
||||
|
||||
static void _ebt_count_messages(tf_ssb_ebt_t* ebt, int* in, int* out)
|
||||
{
|
||||
for (int i = 0; i < ebt->entries_count; i++)
|
||||
{
|
||||
ebt_entry_t* entry = &ebt->entries[i];
|
||||
if (entry->in >= 0 && entry->out >= 0)
|
||||
{
|
||||
if (entry->out_receive && entry->in > entry->out)
|
||||
{
|
||||
*in += entry->in - entry->out;
|
||||
}
|
||||
else if (entry->in_receive && entry->out > entry->in)
|
||||
{
|
||||
*out += entry->out - entry->in;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ebt_entry_t* _ebt_get_entry(tf_ssb_ebt_t* ebt, const char* id)
|
||||
{
|
||||
uint8_t bin[k_id_bin_len];
|
||||
if (!tf_ssb_id_str_to_bin(bin, id))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int index = tf_util_insert_index(id, ebt->entries, ebt->entries_count, sizeof(ebt_entry_t), _ebt_entry_compare);
|
||||
if (index < ebt->entries_count && strcmp(id, ebt->entries[index].id) == 0)
|
||||
{
|
||||
@ -104,27 +133,37 @@ void tf_ssb_ebt_receive_clock(tf_ssb_ebt_t* ebt, JSContext* context, JSValue clo
|
||||
JS_ToInt64(context, &sequence, in_clock);
|
||||
|
||||
ebt_entry_t* entry = _ebt_get_entry(ebt, author);
|
||||
if (sequence < 0)
|
||||
if (entry)
|
||||
{
|
||||
entry->in = -1;
|
||||
entry->in_replicate = false;
|
||||
entry->in_receive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->in = sequence >> 1;
|
||||
entry->in_replicate = true;
|
||||
entry->in_receive = (sequence & 1) == 0;
|
||||
}
|
||||
if (!entry->in_receive)
|
||||
{
|
||||
tf_ssb_connection_remove_new_message_request(ebt->connection, author);
|
||||
if (sequence < 0)
|
||||
{
|
||||
entry->in = tf_max(entry->in, -1);
|
||||
entry->in_replicate = false;
|
||||
entry->in_receive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->in = tf_max(entry->in, sequence >> 1);
|
||||
entry->in_replicate = true;
|
||||
entry->in_receive = (sequence & 1) == 0;
|
||||
}
|
||||
if (!entry->in_receive)
|
||||
{
|
||||
tf_ssb_connection_remove_new_message_request(ebt->connection, author);
|
||||
}
|
||||
}
|
||||
JS_FreeCString(context, author);
|
||||
JS_FreeValue(context, key);
|
||||
}
|
||||
JS_FreeValue(context, in_clock);
|
||||
}
|
||||
|
||||
int in = 0;
|
||||
int out = 0;
|
||||
_ebt_count_messages(ebt, &in, &out);
|
||||
ebt->max_in = tf_max(in, ebt->max_in);
|
||||
ebt->max_out = tf_max(out, ebt->max_out);
|
||||
|
||||
uv_mutex_unlock(&ebt->mutex);
|
||||
for (uint32_t i = 0; i < plen; ++i)
|
||||
{
|
||||
@ -154,29 +193,33 @@ static void _ebt_add_to_clock(ebt_get_clock_t* work, const char* id, int64_t val
|
||||
{
|
||||
int count = work->clock ? work->clock->count : 0;
|
||||
ebt_entry_t* entry = _ebt_get_entry(work->ebt, id);
|
||||
if ((replicate && !entry->out_replicate) || (receive && !entry->out_receive) || ((replicate || receive || entry->out_replicate || entry->out_receive) && entry->out != value))
|
||||
if (entry)
|
||||
{
|
||||
entry->out = value;
|
||||
if ((replicate && !entry->out_replicate) || (receive && !entry->out_receive) ||
|
||||
((replicate || receive || entry->out_replicate || entry->out_receive) && entry->out != value))
|
||||
{
|
||||
int index = tf_util_insert_index(id, count ? work->clock->entries : NULL, count, sizeof(tf_ssb_ebt_clock_entry_t), _ebt_compare_entry);
|
||||
int64_t out_value = (entry->out_replicate || replicate) ? ((tf_max(entry->out, value) << 1) | ((entry->out_receive || receive) ? 0 : 1)) : -1;
|
||||
if (index < count && strcmp(id, work->clock->entries[index].id) == 0)
|
||||
{
|
||||
work->clock->entries[index].value = out_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
work->clock = tf_resize_vec(work->clock, sizeof(tf_ssb_ebt_clock_t) + (count + 1) * sizeof(tf_ssb_ebt_clock_entry_t));
|
||||
if (index < count)
|
||||
{
|
||||
memmove(work->clock->entries + index + 1, work->clock->entries + index, (count - index) * sizeof(tf_ssb_ebt_clock_entry_t));
|
||||
}
|
||||
work->clock->entries[index] = (tf_ssb_ebt_clock_entry_t) { .value = out_value };
|
||||
snprintf(work->clock->entries[index].id, sizeof(work->clock->entries[index].id), "%s", id);
|
||||
work->clock->count = count + 1;
|
||||
}
|
||||
}
|
||||
|
||||
entry->out = tf_max(entry->out, value);
|
||||
entry->out_replicate = entry->out_replicate || replicate;
|
||||
entry->out_receive = entry->out_receive || receive;
|
||||
|
||||
int index = tf_util_insert_index(id, count ? work->clock->entries : NULL, count, sizeof(tf_ssb_ebt_clock_entry_t), _ebt_compare_entry);
|
||||
int64_t out_value = entry->out_replicate ? ((value << 1) | (entry->out_receive ? 0 : 1)) : -1;
|
||||
if (index < count && strcmp(id, work->clock->entries[index].id) == 0)
|
||||
{
|
||||
work->clock->entries[index].value = out_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
work->clock = tf_resize_vec(work->clock, sizeof(tf_ssb_ebt_clock_t) + (count + 1) * sizeof(tf_ssb_ebt_clock_entry_t));
|
||||
if (index < count)
|
||||
{
|
||||
memmove(work->clock->entries + index + 1, work->clock->entries + index, (count - index) * sizeof(tf_ssb_ebt_clock_entry_t));
|
||||
}
|
||||
work->clock->entries[index] = (tf_ssb_ebt_clock_entry_t) { .value = out_value };
|
||||
snprintf(work->clock->entries[index].id, sizeof(work->clock->entries[index].id), "%s", id);
|
||||
work->clock->count = count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,6 +300,14 @@ static void _tf_ssb_ebt_get_send_clock_work(tf_ssb_connection_t* connection, voi
|
||||
uv_mutex_unlock(&work->ebt->mutex);
|
||||
tf_free(requested);
|
||||
}
|
||||
|
||||
uv_mutex_lock(&work->ebt->mutex);
|
||||
int in = 0;
|
||||
int out = 0;
|
||||
_ebt_count_messages(work->ebt, &in, &out);
|
||||
work->ebt->max_in = tf_max(in, work->ebt->max_in);
|
||||
work->ebt->max_out = tf_max(out, work->ebt->max_out);
|
||||
uv_mutex_unlock(&work->ebt->mutex);
|
||||
}
|
||||
|
||||
static void _tf_ssb_ebt_get_send_clock_after_work(tf_ssb_connection_t* connection, int status, void* user_data)
|
||||
@ -303,10 +354,24 @@ void tf_ssb_ebt_set_messages_sent(tf_ssb_ebt_t* ebt, const char* id, int64_t seq
|
||||
{
|
||||
uv_mutex_lock(&ebt->mutex);
|
||||
ebt_entry_t* entry = _ebt_get_entry(ebt, id);
|
||||
entry->in = tf_max(entry->in, sequence);
|
||||
if (entry->in == entry->out && (tf_ssb_connection_get_flags(ebt->connection) & k_tf_ssb_connect_flag_one_shot) == 0)
|
||||
if (entry)
|
||||
{
|
||||
tf_ssb_connection_add_new_message_request(ebt->connection, id, tf_ssb_connection_get_ebt_request_number(ebt->connection), false);
|
||||
entry->in = tf_max(entry->in, sequence);
|
||||
if (entry->in == entry->out && (tf_ssb_connection_get_flags(ebt->connection) & k_tf_ssb_connect_flag_one_shot) == 0)
|
||||
{
|
||||
tf_ssb_connection_add_new_message_request(ebt->connection, id, tf_ssb_connection_get_ebt_request_number(ebt->connection), false);
|
||||
}
|
||||
}
|
||||
uv_mutex_unlock(&ebt->mutex);
|
||||
}
|
||||
|
||||
void tf_ssb_ebt_set_messages_received(tf_ssb_ebt_t* ebt, const char* id, int64_t sequence)
|
||||
{
|
||||
uv_mutex_lock(&ebt->mutex);
|
||||
ebt_entry_t* entry = _ebt_get_entry(ebt, id);
|
||||
if (entry)
|
||||
{
|
||||
entry->out = tf_max(entry->out, sequence);
|
||||
}
|
||||
uv_mutex_unlock(&ebt->mutex);
|
||||
}
|
||||
@ -320,3 +385,34 @@ void tf_ssb_ebt_set_send_clock_pending(tf_ssb_ebt_t* ebt, int pending)
|
||||
{
|
||||
ebt->send_clock_pending = pending;
|
||||
}
|
||||
|
||||
void tf_ssb_ebt_debug_clock(tf_ssb_ebt_t* ebt, JSContext* context, JSValue debug)
|
||||
{
|
||||
uv_mutex_lock(&ebt->mutex);
|
||||
for (int i = 0; i < ebt->entries_count; i++)
|
||||
{
|
||||
ebt_entry_t* entry = &ebt->entries[i];
|
||||
JSValue clock = JS_NewObject(context);
|
||||
JSValue out = JS_NewObject(context);
|
||||
JSValue in = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, out, "value", JS_NewInt64(context, entry->out));
|
||||
JS_SetPropertyStr(context, out, "replicate", JS_NewBool(context, entry->out_replicate));
|
||||
JS_SetPropertyStr(context, out, "receive", JS_NewBool(context, entry->out_receive));
|
||||
JS_SetPropertyStr(context, clock, "out", out);
|
||||
JS_SetPropertyStr(context, in, "value", JS_NewInt64(context, entry->in));
|
||||
JS_SetPropertyStr(context, in, "replicate", JS_NewBool(context, entry->in_replicate));
|
||||
JS_SetPropertyStr(context, in, "receive", JS_NewBool(context, entry->in_receive));
|
||||
JS_SetPropertyStr(context, clock, "in", in);
|
||||
JS_SetPropertyStr(context, debug, entry->id, clock);
|
||||
}
|
||||
uv_mutex_unlock(&ebt->mutex);
|
||||
}
|
||||
|
||||
void tf_ssb_ebt_get_progress(tf_ssb_ebt_t* ebt, int* in_pending, int* in_total, int* out_pending, int* out_total)
|
||||
{
|
||||
uv_mutex_lock(&ebt->mutex);
|
||||
_ebt_count_messages(ebt, in_pending, out_pending);
|
||||
*in_total = tf_max(*in_pending, ebt->max_in);
|
||||
*out_total = tf_max(*out_pending, ebt->max_out);
|
||||
uv_mutex_unlock(&ebt->mutex);
|
||||
}
|
||||
|