~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

The next grain.social and grain-ios, drawn by HUD

Open chadtmiller.com wants to merge into main from grain.social/grain:feature/hud
.knotless/workflows/android.ymlnew+58−0
@@ -0,0 +1,58 @@
# The Android app, android/: its debug build, with HUD's Android kit
# (place.hud:hudkit) from HUD's Maven registry, as `just android-build`
# makes it. The SDK setup, the image and the memory settings are
# grain-android's own workflows' (its .knotless/workflows), which run on
# these runners:
#
# - x86_64 alone: AGP publishes no linux-arm64 AAPT2, so on an arm64 runner
# the build dies in `processDebugResources`.
# - A run has 3 GB, and android/gradle.properties asks for a 4 GB heap, so
# Gradle gets less here and compiles Kotlin in its own process.
# - The SDK (cmdline-tools pinned, so an SDK moving under the pipeline turns
# no unrelated push red) and Gradle's caches are kept between runs.
#
# The debug build is signed with the SDK's debug key, so it needs no
# keystore and no secret. The release build is not here: R8 is slow.
image: eclipse-temurin:17-jdk
runners: [runner.knotless.dev]
on:
push: { refs: [refs/heads/main, refs/heads/feature/*] }
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths:
- android/**
- next/grain.social.json
- .knotless/workflows/android.yml
cache: [/opt/android-sdk, /root/.gradle/caches, /root/.gradle/wrapper]
env:
CMDLINE_TOOLS: commandlinetools-linux-16111833_latest.zip
# Both track android/app/build.gradle.kts: compileSdk 37 is packaged as
# `android-37.0` under the newer SDK versioning.
ANDROID_PLATFORM: platforms;android-37.0
ANDROID_BUILD_TOOLS: build-tools;36.0.0
ANDROID_HOME: /opt/android-sdk
GRADLE_FLAGS: >-
--no-daemon
-Dorg.gradle.jvmargs=-Xmx1536m
-Pkotlin.compiler.execution.strategy=in-process
-Dorg.gradle.workers.max=2
steps:
- name: android sdk
run: |
apt-get update -qq
apt-get install -y -qq git unzip curl >/dev/null
have="$CMDLINE_TOOLS $ANDROID_PLATFORM $ANDROID_BUILD_TOOLS"
[ "$(cat "$ANDROID_HOME/.installed" 2>/dev/null)" = "$have" ] && exit 0
find "$ANDROID_HOME" -mindepth 1 -delete 2>/dev/null || true
mkdir -p "$ANDROID_HOME/cmdline-tools"
curl -fsSL -o /tmp/cmdline-tools.zip "https://dl.google.com/android/repository/$CMDLINE_TOOLS"
unzip -q /tmp/cmdline-tools.zip -d "$ANDROID_HOME/cmdline-tools"
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest"
sdk="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
# sdkmanager reads yes once per licence and closes the pipe.
yes 2>/dev/null | "$sdk" --licenses >/dev/null 2>&1 || true
"$sdk" "platform-tools" "$ANDROID_PLATFORM" "$ANDROID_BUILD_TOOLS" >/dev/null
echo "$have" > "$ANDROID_HOME/.installed"
- name: assemble debug
timeout: 30
run: cd android && ./gradlew $GRADLE_FLAGS :app:assembleDebug
.knotless/workflows/next-deploy.ymlnew+51−0
@@ -0,0 +1,51 @@
# Deploys the next grain.social, next/, to next.grain.social on each push to
# feature/hud touching it, with deploy/next-deploy.sh: its server-rendered
# app is built on grain's box as an image from next/Dockerfile, as a
# candidate beside what serves, then put up by grain-next-deploy
# (hetzner-infra's services/grain-next) with Grain's app for HUD from the
# same commit. hud-next, the HUD in front of next.grain.social that answers
# its own paths and hands the pages to the app, is restarted on those
# apps; then the app rolls over to the candidate with no gap, a new
# container beside the old. If either does not come up healthy, both go
# back to what ran before and the run fails. hud-next itself is deployed
# from hetzner-infra's services/hud.
#
# It runs on ci.knotless.dev alone, the runner on knotless.dev's own host,
# so the key never reaches the hosted runner that checks pulls. There
# GRAIN_NEXT_DEPLOY_KEY is sealed to pushes to feature/hud alone
# (`knotless secret set knotless://grain.social/grain GRAIN_NEXT_DEPLOY_KEY
# --runner ci.knotless.dev --ref refs/heads/feature/hud < <key>`). The box
# takes it only for grain-next-deploy's forced command: it builds and puts
# up the next grain.social and does nothing else. Once a deploy starts it
# finishes; a newer one waits for it, so the newest push is the one served.
on:
push:
refs: [refs/heads/feature/hud]
paths: [next/**, deploy/next-deploy.sh, .knotless/workflows/next-deploy.yml]
superseded: finish
image: alpine:3.22
runners: [ci.knotless.dev]
secrets: [GRAIN_NEXT_DEPLOY_KEY]
env:
GRAIN_HOST: root@167.233.237.163
GRAIN_NEXT_URL: https://next.grain.social
steps:
- name: tools
run: |
apk add --no-cache curl git openssh-client >/dev/null
git config --global --add safe.directory "$PWD"
- name: build
timeout: 20
run: deploy/next-deploy.sh build
- name: deploy
timeout: 10
run: |
deploy/next-deploy.sh up
# As visitors reach it, through Cloudflare, Caddy and hud-next: the
# app's own file, which no edge keeps.
for _ in $(seq 30); do
curl -sf -o /dev/null "$GRAIN_NEXT_URL/_app/version.json" && exit 0
sleep 2
done
echo "$GRAIN_NEXT_URL/_app/version.json does not answer" >&2
exit 1
.knotless/workflows/next-image.ymlnew+45−0
@@ -0,0 +1,45 @@
# The next grain.social's image, next/Dockerfile, built from what
# deploy/next-deploy.sh sends grain's box to build it from, next/ alone
# (its npm ci fetching HUD's packages from HUD's registry), so a pull that
# breaks the image fails here and not at feature/hud's deploy. A run's
# container has no docker daemon to ask, so kaniko builds it, in the run's
# container itself, laying the image's files over the container's own: it
# must be the last step. Pushed nowhere.
#
# kaniko ships only as an image, whose entry point is the build itself, not
# something a run's container can idle in, so its executor is taken out of
# that image with crane. The run's container is Debian, as the image's base
# is: its /sbin is already the link to usr/sbin that the base lays down, so
# kaniko need not replace the directory holding docker's /sbin/docker-init,
# which it cannot (alpine's /sbin is a directory).
image: debian:bookworm-slim
runners: [runner.knotless.dev]
on:
push: { refs: [refs/heads/feature/hud] }
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths: [next/**, .knotless/workflows/next-image.yml]
env:
CRANE: v0.22.1
KANIKO: gcr.io/kaniko-project/executor:v1.24.0
steps:
- name: kaniko
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends ca-certificates curl >/dev/null
# crane's releases name arm64 so, not aarch64.
arch=$(uname -m | sed 's/^aarch64$/arm64/')
curl -fsSL "https://github.com/google/go-containerregistry/releases/download/$CRANE/go-containerregistry_Linux_$arch.tar.gz" \
| tar -xz -C /usr/local/bin crane
crane export "$KANIKO" - | tar -x -C / kaniko
/kaniko/executor version
- name: image
timeout: 25
run: |
# Inside the checkout, a mount kaniko leaves alone as it lays the
# image's files over the container's.
ctx=$PWD/.image-context
mkdir -p "$ctx"
cp -a next "$ctx/"
/kaniko/executor --context "dir://$ctx" --dockerfile "$ctx/next/Dockerfile" \
--no-push --snapshot-mode=redo --force
.knotless/workflows/next.ymlnew+63−0
@@ -0,0 +1,63 @@
# The next grain.social, next/: the apps HUD loads (`hud check next`,
# then Grain's own rules, next/check-apps.mjs), svelte-check, then the
# SvelteKit build (adapter-node, as next/Dockerfile builds it), as `just
# next-build` runs them, with HUD's packages from HUD's registry
# (next/.npmrc). Its packages are kept between runs and installed again
# only when next/package-lock.json changes (the npm-ci shared step).
#
# `hud check` is HUD's own loader, as hud-next runs it at startup: the hud
# binary is built from HUD's public repository at the tag of the version
# the app file names (`"hud": ">=0.3.0"`: v0.3.0), the version
# `just hud-version` sets with the packages', and kept in /opt/hud, so it
# is built again only when that version moves; its build (Rust, and HUD's
# pages, which it embeds) is deleted once the binary is out of it.
#
# ios/ is not checked: an iOS app builds only on macOS, with Xcode, and
# these runners are Linux. Build it on a Mac (ios/README.md), or with Xcode
# Cloud (ios/ci_scripts).
image: node:25-slim
runners: [runner.knotless.dev]
# A pre-flight: the merge queue takes a pull into a batch only once this
# has passed at its head, so one that does not build fails no batch.
queue: first
# Pushes to main and to a feature/ branch, which keep the caches for the
# pulls into them, and pulls into either that change the shell or this
# file. A pull changing neither passes at once, noted as skipped.
on:
push: { refs: [refs/heads/main, refs/heads/feature/*] }
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths: [next/**, lexicons/social/grain/**, .knotless/workflows/next.yml]
cache: [next/node_modules, /opt/hud]
steps:
- uses: chadtmiller.com/steps/npm-ci@1
with: { dir: next }
- name: hud
timeout: 45
run: |
set -e
tag=v$(node -p "require('./next/grain.social.json').hud.replace(/^>=/, '')")
if [ "$(cat /opt/hud/VERSION 2>/dev/null)" != "$tag" ]; then
apt-get update -qq
apt-get install -y -qq --no-install-recommends build-essential ca-certificates curl git >/dev/null
export RUSTUP_HOME=/tmp/rustup CARGO_HOME=/tmp/cargo
# The Rust HUD's Dockerfile builds hud-next's image with.
curl -fsSL https://sh.rustup.rs | sh -s -- -y -q --profile minimal --no-modify-path --default-toolchain 1.98.0
git init -q /tmp/hud
git -C /tmp/hud fetch -q --depth 1 https://knotless.dev/chadtmiller.com/hud "refs/tags/$tag"
git -C /tmp/hud checkout -q FETCH_HEAD
(cd /tmp/hud/web && npm ci --no-audit --no-fund && npm run build)
(cd /tmp/hud && /tmp/cargo/bin/cargo build --release --locked -p hud)
# /opt/hud is the cache's mount: emptied, not removed.
mkdir -p /opt/hud && rm -f /opt/hud/hud /opt/hud/COMMIT /opt/hud/VERSION
cp /tmp/hud/target/release/hud /opt/hud/hud
echo "$tag" > /opt/hud/VERSION
rm -rf /tmp/hud /tmp/rustup /tmp/cargo
fi
HUD_WORKSPACE=off /opt/hud/hud check next
- name: views
run: cd next && node check-apps.mjs
- name: svelte-check
run: cd next && npm run check
- name: build
run: cd next && npm run build
android/app/src/debug/res/xml/network_security_config.xmlnew+18−0
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Debug: a HUD server on this machine (`hud serve`, plain http) as the
emulator reaches it, and HUD's harness in front of its own PDS
(https at hud.harness.internal), whose authority (HUD's
.local/tls/ca.pem) is installed as a user certificate, or put in the
system's store of a rooted emulator. -->
<network-security-config>
<base-config>
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">10.0.2.2</domain>
<domain includeSubdomains="false">localhost</domain>
</domain-config>
</network-security-config>
android/app/src/main/java/social/grain/GrainConfig.ktnew+136−0
@@ -0,0 +1,136 @@
package social.grain
import android.content.Context
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontVariation
import androidx.compose.ui.text.font.FontWeight
import kotlinx.serialization.json.JsonElement
import place.hud.kit.data.Call
import place.hud.kit.data.HudJson
import place.hud.kit.data.PushPlan
import place.hud.kit.data.Route
import place.hud.kit.data.SignInPlan
import place.hud.kit.data.TabFirst
import place.hud.kit.data.get
import place.hud.kit.data.items
import place.hud.kit.data.obj
import place.hud.kit.data.str
import place.hud.kit.data.string
import place.hud.kit.support.Glyphs
import place.hud.kit.support.Typefaces
import place.hud.kit.workspace.Palette
import place.hud.kit.workspace.Theme
/**
* The app as next/grain.social.json says it is, as the web shell and the iOS
* app read it: its name, its tabs, each a tool call drawn as the root of its
* own stack, and its look, a palette for light and one for dark. Signed out,
* a tab draws its `guest` call instead: another call, or "call" for the same
* one; a tab without one asks to sign in. Signed in, a tab with `first`
* draws the root the account's data chooses (Home, the first feed pinned:
* `Shell.chosenRoot`).
*/
class GrainConfig(json: JsonElement) {
data class Tab(
val label: String,
val icon: String,
/** The word its root screen is titled with, drawn as the app's logo, in place of `label`. */
val wordmark: String?,
val call: Call,
/** The call signed out; null where it needs an account. */
val guest: Call?,
/** Its URL path at its root, where it has one of its own (Home's `/`). */
val path: String?,
/** Where its root is chosen from the account's data, signed in. */
val first: TabFirst?,
/** How many are new on it, signed in (Notifications' unread count). */
val badge: Badge?,
) {
/** The call it draws, signed in or not, before `first` chooses; null where it needs an account. */
fun root(signedIn: Boolean): Call? = if (signedIn) call else guest
/**
* Whether its root screen has a title: not one's own profile (an
* app's view of an actor, `describe_app`), which heads itself with
* its avatar and name.
*/
val titled: Boolean get() = call.name != "describe_app"
/** Its icon, as the web draws it (HUD's glyphs: feed, compass, notification, people). */
val glyph: ImageVector? get() = Glyphs.vector(icon)
}
/** A tab's count: a call, and the path to the number in its answer (in a query's `response`). */
data class Badge(val call: Call, val count: String)
/** Where the account chose light or dark, signed in: a call, the path to the choice in its answer, and the procedure after which it is asked again. */
data class Scheme(val call: Call, val at: String, val after: String?)
/** What a row of the accounts shows (`frame.account.picture`): the call each account's own profile is read with, and its picture's, name's and handle's paths in the answer. */
data class AccountPicture(val call: Call, val at: String?, val name: String?, val handle: String?)
val domain: String = json.str("domain") ?: "grain.social"
val name: String = json.str("name") ?: domain
val tabs: List<Tab> = json.items("tabs").mapNotNull { tab ->
val label = tab.str("label") ?: return@mapNotNull null
val call = call(tab["call"]) ?: return@mapNotNull null
val guest = if (tab["guest"].string == "call") call else call(tab["guest"])
val badge = call(tab["badge"]["call"])?.let { Badge(it, tab["badge"].str("count") ?: "count") }
Tab(label, tab.str("icon") ?: "", tab.str("wordmark"), call, guest, tab.str("path"), TabFirst.of(tab["first"]), badge)
}
val light: Theme? = theme(json["look"]["light"], dark = false)
val dark: Theme? = theme(json["look"]["dark"], dark = true)
val scheme: Scheme? = call(json["scheme"]["call"])?.let { call ->
json["scheme"].str("at")?.let { Scheme(call, it, json["scheme"].str("after")) }
}
/** Its screens as URL paths: what a tapped notification or a grain.social link opens. */
val routes: List<Route> = Route.all(json)
val push: PushPlan? = PushPlan.of(json["push"])
val signIn: SignInPlan? = SignInPlan.of(json)
val accountPicture: AccountPicture? = json["frame"]["account"]["picture"].let { picture ->
call(picture["call"])?.let { AccountPicture(it, picture.str("at"), picture.str("name"), picture.str("handle")) }
}
/** The wordmark Home is titled with, else the app's name. */
val wordmark: String get() = tabs.firstNotNullOfOrNull { it.wordmark } ?: name
/** The theme for a scheme. */
fun theme(dark: Boolean): Theme? = if (dark) this.dark ?: light else light ?: this.dark
private fun theme(palette: JsonElement?, dark: Boolean): Theme? {
val colors = palette.obj ?: return null
val scheme = if (dark) "dark" else "light"
return Theme(key = "grain-$scheme", uri = null, creator = null, name = name, dark = dark, palette = Palette(colors))
}
companion object {
/** The one bundled with the app, in its assets. */
fun bundled(context: Context): GrainConfig =
GrainConfig(HudJson.parseToJsonElement(context.assets.open("grain.social.json").bufferedReader().use { it.readText() }))
/** A `{name, args}`. */
private fun call(json: JsonElement?): Call? = Call.of(json)
/**
* Grain's faces, as the web shell sets its (`look.fonts`): Plus
* Jakarta Sans for text, Syne at weight 800 for titles, both
* Google Fonts' variable TTFs (OFL), as ios/Grain/Fonts has them.
*/
val typefaces: Typefaces by lazy {
fun sans(weight: Int) = Font(
R.font.plus_jakarta_sans, FontWeight(weight),
variationSettings = FontVariation.Settings(FontVariation.weight(weight)),
)
Typefaces(
body = FontFamily(sans(400), sans(500), sans(600), sans(700)),
display = display,
)
}
/** Syne ExtraBold: the variable Syne at weight 800. */
val display: FontFamily by lazy {
FontFamily(Font(R.font.syne, FontWeight.ExtraBold, variationSettings = FontVariation.Settings(FontVariation.weight(800))))
}
}
}
android/app/src/main/java/social/grain/Level.ktnew+265−0
@@ -0,0 +1,265 @@
package social.grain
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.serialization.json.JsonObject
import place.hud.kit.data.Call
import place.hud.kit.data.Drawn
import place.hud.kit.data.HudClient
import place.hud.kit.data.HudError
import place.hud.kit.data.LastTree
import place.hud.kit.data.Skeleton
import place.hud.kit.data.Viewer
import place.hud.kit.data.get
import place.hud.kit.tree.barTitle
import place.hud.kit.tree.liftBar
import place.hud.kit.view.ViewContext
import java.util.concurrent.atomic.AtomicLong
/**
* One level of a tab's stack, as the iOS app's: the call it draws (a tab
* chosen in it swaps another in), what it answered (grown by each page
* more), or until then its tree as the account last drew it (`LastTree`),
* and whether it needed an account it was not made as. Its view context
* lives as long as it does, so what a person did to its parts (a like, a
* text opened in full) stays as they go back to it. Main thread only.
*/
@Stable
class Level(call: Call) {
/** Who it is among the levels, as its screen's saved state is kept by. */
val id: String = "level-${ids.incrementAndGet()}"
var call: Call by mutableStateOf(call)
private set
/** What its call answered; while a swapped-in call is on its way, what the call before answered (`drawnCall`). */
var drawn: Drawn? by mutableStateOf(null)
private set
/** The call whose answer is drawn. */
var drawnCall: Call? = null
private set
/** How many times what is drawn changed: what a screen wires its context afresh by. */
var answers: Int by mutableIntStateOf(0)
private set
/** Its call has been out longer than `Skeleton.DELAY_MS`. */
var slow: Boolean by mutableStateOf(false)
private set
/** The tree it draws is being read afresh: a tree as last drawn, or a level shown again. */
var refreshing: Boolean by mutableStateOf(false)
private set
/** Why reading what it draws afresh failed the last time, what is drawn left as it was; null once it answers. */
var refreshError: String? by mutableStateOf(null)
private set
var loadingMore: Boolean by mutableStateOf(false)
private set
var moreError: String? by mutableStateOf(null)
private set
/** The account the latest result was made for; null for no one. */
var viewer: Viewer? by mutableStateOf(null)
private set
var needsSignIn: Boolean by mutableStateOf(false)
private set
/** What its tree is drawn with: wired afresh with each answer. */
val context = ViewContext()
/** The posts this level has told its feed were seen. */
val told = HashSet<String>()
/** How many items the first page of what is drawn holds: those past them came a page more at a time. */
private var firstPage = 0
/** The calls a load is out for, each with the loads of it asked for meanwhile, which wait for its answer. */
private val loading = HashMap<Call, MutableList<CompletableDeferred<Unit>>>()
/** The call a tab's root draws being chosen still, from the account's data (Home's, the first feed pinned): its loads wait for it. */
var choosing: Deferred<Call>? = null
private fun draw(answer: Drawn, of: Call?) {
drawnCall = of
drawn = answer
answers += 1
}
/** Whether it draws the answer of a call before its own, while that is on its way. */
val swapping: Boolean get() = drawn != null && drawnCall != call
/** Draw `call` in its place (a tab chosen in it), once `load` brings its answer: until then, what it drew stays. */
fun swap(to: Call) {
call = to
slow = false
refreshing = false
refreshError = null
moreError = null
}
/** Draw its call's tree as `account` (null, no one) last drew it, where one is kept, until its call answers afresh. */
fun recall(account: String?) {
val kept = LastTree.recall(call, account) ?: return
val tree = Drawn.Tree(kept.ui)
viewer = kept.viewer
needsSignIn = false
firstPage = tree.pageCount ?: 0
draw(tree, call)
}
/** Its screen's title, as its tree's lifted `Bar` names it; null while it loads, or where its view names none. */
val title: String?
get() {
val ui = (drawn as? Drawn.Tree)?.ui ?: return null
val root = ui["root"] ?: return null
return liftBar(root).second?.let(::barTitle)
}
/**
* Call it afresh, its answer drawn only while it still draws that call
* (no tab chosen since), its tree kept as its screen's last
* (`LastTree`) and its shape as its skeleton; past `Skeleton.DELAY_MS`
* it is `slow`. Where none of its own is drawn, its tree as last drawn
* is, where one is kept. A tree of its call drawn is `refreshing` until
* the answer comes, and stays where the call fails. A load already out
* for its call is waited for. A tab's root whose call is being chosen
* waits for it first and draws what it chose.
*/
suspend fun load(client: HudClient) {
choosing?.let { choice ->
val chosen = choice.await()
choosing = null
if (chosen != call) swap(chosen)
}
val asked = call
loading[asked]?.let { waiting ->
val done = CompletableDeferred<Unit>()
waiting += done
done.await()
return
}
val account = client.session?.did
if (drawnCall != asked) recall(account)
val revalidating = drawnCall == asked && drawn is Drawn.Tree
loading[asked] = mutableListOf()
refreshing = revalidating
coroutineScope {
val timer = launch {
delay(Skeleton.DELAY_MS)
if (call == asked) slow = true
}
try {
val sent = System.currentTimeMillis()
val result = client.call(asked)
if (call != asked) return@coroutineScope
val fresh = Drawn.of(result)
if (revalidating && fresh is Drawn.Error) {
refreshError = fresh.message
return@coroutineScope
}
viewer = if (result.isError) null else result.viewer
needsSignIn = false
refreshError = null
show(fresh, asked, account, sent)
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
if (call != asked) return@coroutineScope
needsSignIn = e is HudError.SignIn
val message = e.message ?: "Couldn't reach the server."
if (revalidating && !needsSignIn) {
refreshError = message
return@coroutineScope
}
if (needsSignIn) viewer = null
show(Drawn.Error(message), asked, account, System.currentTimeMillis())
} finally {
timer.cancel()
// Those waiting for it go on, whatever call it draws by now.
loading.remove(asked)?.forEach { it.complete(Unit) }
if (call == asked) {
slow = false
refreshing = false
}
}
}
}
/** Read it again, its answer drawn in place once it came; a failure thrown in the server's words, what is drawn left as it was. */
suspend fun reload(client: HudClient) {
val asked = call
val sent = System.currentTimeMillis()
val result = client.call(asked)
val fresh = Drawn.of(result)
if (fresh is Drawn.Error) throw HudError.Tool(fresh.message)
if (call != asked) return
viewer = result.viewer
needsSignIn = false
refreshError = null
show(fresh, asked, client.session?.did, sent)
}
/**
* Draw `call`'s answer as `account` asked it (at `sent`). A tree is kept
* as its screen's last, and its shape as its skeleton. In place of a
* tree of the same call, the pages loaded past its first stay after the
* fresh first page, so the list stays as long and where it was scrolled.
*/
private fun show(answer: Drawn, call: Call, account: String?, sent: Long) {
var shown = answer
if (answer is Drawn.Tree) {
Skeleton.remember(call, answer.ui)
LastTree.remember(call, account, answer.ui, viewer, sent)
val first = answer.pageCount ?: 0
val before = drawn
if (drawnCall == call && before != null) shown = before.refreshed(answer, firstPage)
firstPage = first
}
draw(shown, call)
}
/** A page more, its tree's `next`; dropped where another call's answer is drawn by the time it comes. */
suspend fun loadMore(client: HudClient) {
val before = drawn ?: return
val next = before.nextPage ?: return
if (loadingMore) return
val of = drawnCall
loadingMore = true
moreError = null
try {
val page = Drawn.of(client.call(next))
if (drawnCall != of) return
val grown = drawn?.appending(page)
when {
page is Drawn.Error -> moreError = page.message
grown != null -> draw(grown, of)
else -> moreError = "The next page is not of this list."
}
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
if (drawnCall == of) moreError = e.message ?: "Couldn't load more."
} finally {
loadingMore = false
}
}
/** Its tree's `ui`, where a tree is drawn. */
val ui: JsonObject? get() = (drawn as? Drawn.Tree)?.ui
private companion object {
val ids = AtomicLong()
}
}
android/app/src/main/java/social/grain/LevelScreen.ktnew+435−0
435 lines changed: not loaded until asked for.
android/app/src/main/java/social/grain/MainActivity.ktnew+126−0
@@ -0,0 +1,126 @@
package social.grain
import android.Manifest
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.launch
import place.hud.kit.data.Skeleton
/**
* Grain: next/grain.social.json's tabs along the foot, each a stack of
* HUD's server-resolved views drawn by HUD's Android kit, its tool calls
* made on the HUD server's /mcp, signed in or as a guest. A debug build
* started with `--es server <url>` calls that server from then on (an empty
* one goes back to the build's). A grain.social link (or grain://profile/…)
* opens as its route.
*/
class MainActivity : ComponentActivity() {
private lateinit var shell: Shell
private lateinit var gate: UpdateGate
/** The answer push's leave to notify waits for, while the person is asked. */
private var answer: CompletableDeferred<Boolean>? = null
private val notify = registerForActivityResult(ActivityResultContracts.RequestPermission()) { given ->
answer?.complete(given)
answer = null
}
/** Asks for `POST_NOTIFICATIONS` over this activity, for push (`FcmDevice`). */
private val ask: suspend () -> Boolean = {
val waiting = CompletableDeferred<Boolean>().also { answer = it }
notify.launch(Manifest.permission.POST_NOTIFICATIONS)
waiting.await()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
Grain.device(this).ask = ask
shell = Grain.shell(this)
gate = Grain.gate(this)
shell.attach(this)
if (savedInstanceState == null) handle(intent)
setContent {
val dark = shell.preferredDark ?: isSystemInDarkTheme()
val view = LocalView.current
// The bars' icons legible on the scheme drawn, which the account may choose apart from the device's.
SideEffect {
WindowCompat.getInsetsController(window, view).apply {
isAppearanceLightStatusBars = !dark && (shell.stories == null || shell.stories?.alone == true) && !shell.askingSignIn
isAppearanceLightNavigationBars = !dark
}
}
GrainApp(shell, gate)
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handle(intent)
}
override fun onResume() {
super.onResume()
shell.attach(this)
lifecycleScope.launch { shell.refreshUnread() }
lifecycleScope.launch { gate.check() }
}
override fun onDestroy() {
super.onDestroy()
shell.attach(null)
Grain.device(this).let { if (it.ask === ask) it.ask = null }
answer?.complete(false)
}
/** A server named (a debug build's only: `Shell.useServer`), a tapped notification's fields (`GrainMessagingService`), and a link to open as its route. */
private fun handle(intent: Intent) {
if (BuildConfig.DEBUG) intent.getStringExtra("server")?.let(shell::useServer)
intent.getBundleExtra(GrainMessagingService.EXTRA_PUSH)?.let { fields ->
shell.push?.tapped(fields.keySet().mapNotNull { key -> fields.getString(key)?.let { key to it } }.toMap())
}
val uri = intent.data ?: return
if (intent.action != Intent.ACTION_VIEW) return
path(uri)?.let(shell::openPath)
}
/** The path a link opens: a grain.social page's, or grain://profile/…'s as /profile/…. */
private fun path(uri: Uri): String? {
val query = uri.encodedQuery?.let { "?$it" } ?: ""
return when {
uri.scheme == "https" && (uri.host == shell.config.domain || uri.host == "www.${shell.config.domain}") -> (uri.encodedPath ?: "/") + query
uri.scheme == "grain" && uri.host == "profile" -> "/profile" + (uri.encodedPath ?: "") + query
else -> null
}
}
}
/** The app's one shell and update gate, for as long as its process lives, whatever activity is on show. */
object Grain {
private var shell: Shell? = null
private var gate: UpdateGate? = null
private var device: FcmDevice? = null
fun shell(context: Context): Shell = shell ?: run {
val app = context.applicationContext
Skeleton.use(app.getSharedPreferences("hud-skeletons", Context.MODE_PRIVATE))
Shell(app, GrainConfig.bundled(app), device(app)).also { shell = it }
}
fun gate(context: Context): UpdateGate = gate ?: UpdateGate(context).also { gate = it }
/** What push asks of the device: leave to notify, through the activity on show, and FCM's token. */
fun device(context: Context): FcmDevice = device ?: FcmDevice(context).also { device = it }
}
android/app/src/main/java/social/grain/Push.ktnew+133−0
@@ -0,0 +1,133 @@
package social.grain
import android.Manifest
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import com.google.firebase.FirebaseApp
import com.google.firebase.messaging.FirebaseMessaging
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import place.hud.kit.data.Push
import kotlin.coroutines.resume
/**
* What HUD's `Push` asks of this device: leave to notify, asked once
* (Android 13 on) through the activity on show (`ask`, set by
* `MainActivity`), and FCM's token, where the build has a Firebase config
* (a release built with `google-services.json`); none, no token.
*/
class FcmDevice(context: Context) : Push.Device {
private val app = context.applicationContext
private val prefs = app.getSharedPreferences("grain", Context.MODE_PRIVATE)
/** Asks the person for `POST_NOTIFICATIONS` and answers whether they gave it; null while no activity is on show. */
var ask: (suspend () -> Boolean)? = null
override suspend fun allowed(): Boolean {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return true
if (ContextCompat.checkSelfPermission(app, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) return true
if (prefs.getBoolean(ASKED, false)) return false
val ask = ask ?: return false
prefs.edit().putBoolean(ASKED, true).apply()
return ask()
}
override suspend fun token(): String? {
if (FirebaseApp.getApps(app).isEmpty()) {
Log.i(TAG, "No Firebase config in this build: no push")
return null
}
return suspendCancellableCoroutine { done ->
FirebaseMessaging.getInstance().token
.addOnSuccessListener { done.resume(it) }
.addOnFailureListener {
Log.w(TAG, "FCM gave no token: ${it.message}")
done.resume(null)
}
}
}
companion object {
private const val TAG = "push"
private const val ASKED = "push.asked"
}
}
/**
* FCM's messages for this device: grain-serve's are data only, every field
* a string, `title` and `body` beside the notification's own (`type`, and a
* `uri` or `did`), drawn here as a notification whose tap hands those
* fields to `MainActivity` (`EXTRA_PUSH`), which opens the path the app
* file's `push.open` maps them to. A token FCM rotates is registered as the
* account signed in.
*/
class GrainMessagingService : FirebaseMessagingService() {
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
override fun onNewToken(token: String) {
val push = Grain.shell(this).push ?: return
scope.launch { push.registered(token) }
}
override fun onMessageReceived(message: RemoteMessage) {
val data = message.data
val title = message.notification?.title ?: data["title"] ?: return
val body = message.notification?.body ?: data["body"].orEmpty()
ensureChannel(this)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED
) return
val fields = Bundle().apply { for ((key, value) in data) if (key != "title" && key != "body") putString(key, value) }
// One notification, and one tap, per subject: two about different galleries don't share a PendingIntent.
val id = (data["uri"] ?: data["did"] ?: title).hashCode()
val tap = PendingIntent.getActivity(
this,
id,
Intent(this, MainActivity::class.java).putExtra(EXTRA_PUSH, fields),
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
)
NotificationManagerCompat.from(this).notify(id, notification(this, title, body, tap))
}
companion object {
/** The extra a tapped notification's fields come to `MainActivity` in, a Bundle of strings. */
const val EXTRA_PUSH = "social.grain.push"
const val CHANNEL_ID = "social_activity"
/** grain-android's notification: its glyph tinted, the text whole when expanded, gone once tapped. */
fun notification(context: Context, title: String, body: String, tap: PendingIntent): Notification =
NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setColor(ContextCompat.getColor(context, R.color.notification_accent))
.setContentTitle(title)
.setContentText(body)
.setStyle(NotificationCompat.BigTextStyle().bigText(body))
.setAutoCancel(true)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(tap)
.build()
/** grain-android's channel, made where it is not (the one FCM posts to as well, the manifest's default). */
fun ensureChannel(context: Context) {
val channel = NotificationChannel(CHANNEL_ID, context.getString(R.string.notification_channel_social), NotificationManager.IMPORTANCE_DEFAULT)
.apply { description = context.getString(R.string.notification_channel_social_description) }
context.getSystemService(NotificationManager::class.java)?.createNotificationChannel(channel)
}
}
}
android/app/src/main/java/social/grain/Shell.ktnew+658−0
658 lines changed: not loaded until asked for.
android/app/src/main/java/social/grain/ShellScreen.ktnew+220−0
@@ -0,0 +1,220 @@
package social.grain
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
import androidx.compose.material3.Badge
import androidx.compose.material3.BadgedBox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.key
import androidx.compose.runtime.saveable.SaveableStateHolder
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import kotlinx.coroutines.delay
import place.hud.kit.support.HudColors
import place.hud.kit.support.HudThemed
import place.hud.kit.tree.LocalStackRoot
/**
* The app: in the scheme the account chose (light or dark), else the
* device's, in Grain's look and faces; the tabs drawn anew each time they
* start afresh (another account), as the web loads its page anew. Below
* the minimum version grain.social asks for, only "Update Grain".
*/
@Composable
fun GrainApp(shell: Shell, gate: UpdateGate) {
val dark = shell.preferredDark ?: isSystemInDarkTheme()
HudThemed(shell.config.theme(dark), GrainConfig.typefaces) {
if (gate.blocked != null) {
UpdateScreen(gate)
} else {
key(shell.starts) { ShellScreen(shell) }
}
}
}
/**
* The tab bar, each tab its own stack; over them the stories, a sheet, and
* signing in. The notifications tab is badged with how many came since
* they were last seen, asked at launch, as the app comes to the front
* (`MainActivity`), and every minute.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ShellScreen(shell: Shell) {
val saved = rememberSaveableStateHolder()
LaunchedEffect(Unit) {
while (true) {
delay(60_000)
shell.refreshUnread()
}
}
Box(Modifier.fillMaxSize().background(HudColors.tileSurface)) {
Scaffold(
bottomBar = { TabBar(shell) },
containerColor = HudColors.tileSurface,
contentWindowInsets = WindowInsets(0.dp),
) { padding ->
Box(Modifier.padding(padding)) {
val tab = shell.selected
key(tab) { TabStack(shell, tab, saved) }
}
}
BackHandler(enabled = shell.paths[shell.selected].isNotEmpty() && shell.stories == null && !shell.askingSignIn) { shell.back() }
shell.stories?.let { stories -> key(stories) { StoryPager(stories, shell) } }
if (shell.askingSignIn) SignInScreen(shell)
}
shell.sheet?.let { sheet -> key(sheet) { SheetScreen(shell, sheet) } }
}
/** The tabs along the foot, as next/grain.social.json names them, each its icon as the web draws it. */
@Composable
private fun TabBar(shell: Shell) {
NavigationBar(containerColor = HudColors.tileSurface) {
shell.config.tabs.forEachIndexed { i, tab ->
NavigationBarItem(
selected = i == shell.selected,
onClick = { shell.choose(i) },
icon = {
BadgedBox(badge = {
if (i == shell.notificationsTab && shell.unread > 0) Badge { Text(if (shell.unread > 99) "99+" else "${shell.unread}") }
}) {
val glyph = tab.glyph
if (glyph != null) Icon(glyph, contentDescription = tab.label, Modifier.size(24.dp)) else Icon(Icons.Filled.Home, tab.label)
}
},
label = { Text(tab.label) },
colors = NavigationBarItemDefaults.colors(
selectedIconColor = HudColors.accent,
selectedTextColor = HudColors.accent,
indicatorColor = HudColors.accentSoft,
unselectedIconColor = HudColors.muted,
unselectedTextColor = HudColors.muted,
),
)
}
}
}
/**
* One tab's stack: its root, titled by the tab (a wordmark, Home's "grain",
* in the display face; one's own profile heads itself, untitled), and what
* opened over it, each titled by its view's `Bar`, with a way back. Each
* level's saved state (where it was scrolled) is kept while it is on the
* stack, so going back finds it where it was.
*/
@Composable
private fun TabStack(shell: Shell, tab: Int, saved: SaveableStateHolder) {
val plan = shell.config.tabs[tab]
val path = shell.paths[tab]
val root = shell.roots[tab]
val top = path.lastOrNull() ?: root
fun depth(level: Level?): Int = if (level == null || level === root) 0 else path.indexOf(level).let { if (it < 0) Int.MAX_VALUE else it + 1 }
AnimatedContent(
targetState = top,
transitionSpec = {
if (depth(targetState) > depth(initialState)) {
slideInHorizontally { it } togetherWith slideOutHorizontally { -it / 4 } + fadeOut()
} else {
slideInHorizontally { -it / 4 } + fadeIn() togetherWith slideOutHorizontally { it }
}
},
label = "stack",
) { level ->
saved.SaveableStateProvider(level?.id ?: "sign-in-$tab") {
when {
level == null -> SignInTab(shell, plan)
level === root -> LevelScreen(
level, shell, Wiring.tab(shell, level, tab),
title = if (plan.titled) plan.wordmark ?: plan.label else null, large = true, back = null,
)
// Pushed over the tab's root: no feeds strip, whose tabs swap the screen in place.
else -> CompositionLocalProvider(LocalStackRoot provides false) {
LevelScreen(level, shell, Wiring.tab(shell, level, tab), title = level.title, large = false, back = { shell.back() })
}
}
}
}
}
/** A tab that needs an account, signed out. */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun SignInTab(shell: Shell, plan: GrainConfig.Tab) {
Column(Modifier.fillMaxSize().background(HudColors.tileSurface)) {
TopAppBar(
title = { Text(plan.label, style = TextStyle(fontFamily = GrainConfig.display, fontSize = 30.sp)) },
colors = TopAppBarDefaults.topAppBarColors(containerColor = HudColors.tileSurface, titleContentColor = HudColors.text),
)
Column(Modifier.fillMaxWidth().verticalScroll(rememberScrollState())) {
SignInAsk(shell, "Sign in to see your ${plan.label.lowercase()}")
}
}
}
/**
* A call shown as a sheet over what is open, as Grain's story comments:
* full height, in the app's look (over the stories, dark); what opens from
* it opens on the tab.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun SheetScreen(shell: Shell, sheet: SheetLevel) {
val state = rememberModalBottomSheetState(skipPartiallyExpanded = true)
val theme = if (sheet.overStories) shell.config.dark else shell.config.theme(shell.preferredDark ?: isSystemInDarkTheme())
HudThemed(theme, GrainConfig.typefaces) {
ModalBottomSheet(
onDismissRequest = { shell.sheet = null },
sheetState = state,
containerColor = HudColors.tileSurface,
) {
// Over a tab, not a tab's root: no feeds strip, whose tabs swap the screen in place.
CompositionLocalProvider(LocalStackRoot provides false) {
val level = sheet.level
val shown = rememberShown(level, shell, Wiring.sheet(shell, level, sheet.tab))
Column(Modifier.fillMaxSize()) {
level.title?.let { title ->
Text(
title, style = TextStyle(fontFamily = GrainConfig.display, fontSize = 18.sp), color = HudColors.text,
modifier = Modifier.padding(start = 16.dp, bottom = 8.dp),
)
}
LevelBody(level, shell, shown, Modifier.weight(1f))
}
}
}
}
}
android/app/src/main/java/social/grain/SignInScreen.ktnew+292−0
android/app/src/main/java/social/grain/StoryPager.ktnew+203−0
android/app/src/main/java/social/grain/UpdateGate.ktnew+119−0
android/app/src/main/res/drawable/ic_launcher_monochrome.xmlnew+27−0
android/app/src/main/res/drawable/ic_notification.xmlnew+24−0
android/app/src/main/res/drawable-xhdpi/login_bg.jpgnew+0−0
A binary file, not shown.
android/app/src/main/res/drawable-xxhdpi/login_bg.jpgnew+0−0
A binary file, not shown.
android/app/src/main/res/font/plus_jakarta_sans.ttfnew+0−0
A binary file, not shown.
android/app/src/main/res/font/syne.ttfnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xmlnew+18−0
android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xmlnew+18−0
android/app/src/main/res/mipmap-hdpi/ic_launcher.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-hdpi/ic_launcher_background.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-hdpi/ic_launcher_round.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-mdpi/ic_launcher.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-mdpi/ic_launcher_background.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-mdpi/ic_launcher_round.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xhdpi/ic_launcher.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.pngnew+0−0
A binary file, not shown.
android/app/src/main/res/values/colors.xmlnew+7−0
android/app/src/main/res/values/strings.xmlnew+7−0
android/app/src/main/res/values/themes.xmlnew+10−0
android/app/src/main/res/values-night/colors.xmlnew+5−0
android/app/src/main/res/values-night/themes.xmlnew+9−0
android/app/src/main/res/xml/data_extraction_rules.xmlnew+13−0
android/app/src/main/res/xml/network_security_config.xmlnew+3−0
android/app/src/main/AndroidManifest.xmlnew+83−0
android/app/build.gradle.ktsnew+110−0
android/app/proguard-rules.pronew+1−0
android/gradle/wrapper/gradle-wrapper.jarnew+0−0
A binary file, not shown.
android/gradle/wrapper/gradle-wrapper.propertiesnew+8−0
android/gradle/libs.versions.tomlnew+33−0
android/.gitignorenew+6−0
android/build.gradle.ktsnew+7−0
android/gradle.propertiesnew+6−0
android/gradlewnew+234−0
android/gradlew.batnew+89−0
android/README.mdnew+111−0
android/settings.gradle.ktsnew+30−0
deploy/next-deploy.shnew+64−0
ios/ci_scripts/ci_post_clone.shnew+20−0
ios/Grain/Assets.xcassets/AppIcon.appiconset/29.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/40.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/58.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/60.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/80.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/87.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/120.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/152.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/167.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/180.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/1024.pngnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/AppIcon.appiconset/Contents.jsonnew+104−0
ios/Grain/Assets.xcassets/login-bg.imageset/Contents.jsonnew+22−0
ios/Grain/Assets.xcassets/login-bg.imageset/login-bg.jpgnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/login-bg.imageset/login-bg@2x.jpgnew+0−0
A binary file, not shown.
ios/Grain/Assets.xcassets/Contents.jsonnew+6−0
ios/Grain/Fonts/PlusJakartaSans-OFL.txtnew+93−0
ios/Grain/Fonts/PlusJakartaSans.ttfnew+0−0
A binary file, not shown.
ios/Grain/Fonts/Syne-OFL.txtnew+93−0
ios/Grain/Fonts/Syne.ttfnew+0−0
A binary file, not shown.
ios/Grain/Config.swiftnew+173−0
ios/Grain/GrainApp.swiftnew+149−0
ios/Grain/LevelScreen.swiftnew+347−0
ios/Grain/Shell.swiftnew+784−0
784 lines changed: not loaded until asked for.
ios/Grain/SignInSheet.swiftnew+365−0
ios/Grain/StoryPager.swiftnew+412−0
412 lines changed: not loaded until asked for.
ios/GrainUITests/GrainUITests.swiftnew+791−0
791 lines changed: not loaded until asked for.
ios/GrainUITests/LastTreeTests.swiftnew+108−0
ios/GrainUITests/LocationsTests.swiftnew+118−0
ios/GrainUITests/SignInTests.swiftnew+105−0
ios/HUD/.swiftpm/configuration/registries.jsonnew+10−0
ios/HUD/Sources/HUD/HUD.swiftnew+2−0
ios/HUD/Package.swiftnew+16−0
ios/.gitignorenew+3−0
ios/Package.resolvednew+13−0
ios/project.ymlnew+105−0
ios/README.mdnew+90−0
lexicons/social/grain/authFull.jsonnew+109−0
next/lexicons/social/grain/actor/defs.jsonnew+195−0
next/lexicons/social/grain/actor/getFavorites.jsonnew+33−0
next/lexicons/social/grain/actor/getPreferences.jsonnew+20−0
next/lexicons/social/grain/actor/getProfile.jsonnew+31−0
next/lexicons/social/grain/actor/getSuggestedFollows.jsonnew+30−0
next/lexicons/social/grain/actor/profile.jsonnew+34−0
next/lexicons/social/grain/actor/putPreferences.jsonnew+24−0
next/lexicons/social/grain/actor/searchActors.jsonnew+33−0
next/lexicons/social/grain/actor/searchActorsTypeahead.jsonnew+30−0
next/lexicons/social/grain/actor/setPreference.jsonnew+38−0
next/lexicons/social/grain/admin/actOnReview.jsonnew+33−0
next/lexicons/social/grain/admin/addRepos.jsonnew+33−0
next/lexicons/social/grain/admin/applyLabel.jsonnew+29−0
next/lexicons/social/grain/admin/defs.jsonnew+163−0
next/lexicons/social/grain/admin/getInfo.jsonnew+29−0
next/lexicons/social/grain/admin/getRepo.jsonnew+20−0
next/lexicons/social/grain/admin/getReport.jsonnew+24−0
next/lexicons/social/grain/admin/getReviewQueue.jsonnew+46−0
next/lexicons/social/grain/admin/getReviewStats.jsonnew+32−0
next/lexicons/social/grain/admin/getReviewSubject.jsonnew+50−0
next/lexicons/social/grain/admin/listLabelDefinitions.jsonnew+23−0
next/lexicons/social/grain/admin/listReports.jsonnew+38−0
next/lexicons/social/grain/admin/listRepos.jsonnew+34−0
next/lexicons/social/grain/admin/negateLabel.jsonnew+29−0
next/lexicons/social/grain/admin/removeRepos.jsonnew+33−0
next/lexicons/social/grain/admin/resolveReport.jsonnew+26−0
next/lexicons/social/grain/admin/resyncRepos.jsonnew+32−0
next/lexicons/social/grain/admin/searchRecords.jsonnew+32−0
next/lexicons/social/grain/admin/startScan.jsonnew+43−0
next/lexicons/social/grain/comment/comment.jsonnew+43−0
next/lexicons/social/grain/comment/defs.jsonnew+61−0
next/lexicons/social/grain/comment/getThread.jsonnew+38−0
next/lexicons/social/grain/favorite/favorite.jsonnew+25−0
next/lexicons/social/grain/feed/defs.jsonnew+22−0
next/lexicons/social/grain/feed/describeFeeds.jsonnew+28−0
next/lexicons/social/grain/feed/getFeed.jsonnew+47−0
next/lexicons/social/grain/gallery/defs.jsonnew+179−0
next/lexicons/social/grain/gallery/deleteGallery.jsonnew+33−0
next/lexicons/social/grain/gallery/gallery.jsonnew+33−0
next/lexicons/social/grain/gallery/getCameras.jsonnew+22−0
next/lexicons/social/grain/gallery/getCrossPost.jsonnew+40−0
next/lexicons/social/grain/gallery/getFavorites.jsonnew+33−0
next/lexicons/social/grain/gallery/getGallery.jsonnew+33−0
next/lexicons/social/grain/gallery/getLocations.jsonnew+31−0
next/lexicons/social/grain/gallery/item.jsonnew+33−0
next/lexicons/social/grain/gallery/searchGalleries.jsonnew+33−0
next/lexicons/social/grain/graph/block.jsonnew+25−0
next/lexicons/social/grain/graph/defs.jsonnew+66−0
next/lexicons/social/grain/graph/follow.jsonnew+25−0
next/lexicons/social/grain/graph/getBlocks.jsonnew+30−0
next/lexicons/social/grain/graph/getFollowers.jsonnew+33−0
next/lexicons/social/grain/graph/getFollowing.jsonnew+33−0
next/lexicons/social/grain/graph/getKnownFollowers.jsonnew+30−0
next/lexicons/social/grain/graph/getMutes.jsonnew+30−0
next/lexicons/social/grain/graph/muteActor.jsonnew+30−0
next/lexicons/social/grain/graph/unmuteActor.jsonnew+30−0
next/lexicons/social/grain/group/createComment.jsonnew+41−0
next/lexicons/social/grain/group/createGallery.jsonnew+57−0
next/lexicons/social/grain/group/createGroup.jsonnew+54−0
next/lexicons/social/grain/group/decline.jsonnew+29−0
next/lexicons/social/grain/group/defs.jsonnew+289−0
next/lexicons/social/grain/group/deleteComment.jsonnew+28−0
next/lexicons/social/grain/group/deleteGallery.jsonnew+38−0
next/lexicons/social/grain/group/getGallery.jsonnew+52−0
next/lexicons/social/grain/group/getGroup.jsonnew+19−0
next/lexicons/social/grain/group/getGroupHost.jsonnew+24−0
next/lexicons/social/grain/group/getSubmissions.jsonnew+33−0
next/lexicons/social/grain/group/item.jsonnew+31−0
next/lexicons/social/grain/group/joinGroup.jsonnew+31−0
next/lexicons/social/grain/group/leaveGroup.jsonnew+22−0
next/lexicons/social/grain/group/listFeed.jsonnew+37−0
next/lexicons/social/grain/group/listGalleries.jsonnew+35−0
next/lexicons/social/grain/group/listGroups.jsonnew+32−0
next/lexicons/social/grain/group/putFavorite.jsonnew+40−0
next/lexicons/social/grain/group/submission.jsonnew+31−0
next/lexicons/social/grain/moderation/defs.jsonnew+14−0
next/lexicons/social/grain/moderation/describeLabels.jsonnew+28−0
next/lexicons/social/grain/notification/defs.jsonnew+45−0
next/lexicons/social/grain/notification/getUnreadCount.jsonnew+18−0
next/lexicons/social/grain/notification/listNotifications.jsonnew+36−0
next/lexicons/social/grain/notification/registerPush.jsonnew+35−0
next/lexicons/social/grain/notification/unregisterPush.jsonnew+35−0
next/lexicons/social/grain/notification/updateSeen.jsonnew+22−0
next/lexicons/social/grain/photo/defs.jsonnew+68−0
next/lexicons/social/grain/photo/exif.jsonnew+29−0
next/lexicons/social/grain/photo/photo.jsonnew+31−0
next/lexicons/social/grain/repo/applyWrites.jsonnew+102−0
next/lexicons/social/grain/repo/createRecord.jsonnew+43−0
next/lexicons/social/grain/repo/defs.jsonnew+15−0
next/lexicons/social/grain/repo/deleteRecord.jsonnew+39−0
next/lexicons/social/grain/repo/putRecord.jsonnew+44−0
next/lexicons/social/grain/repo/uploadBlob.jsonnew+25−0
next/lexicons/social/grain/server/defs.jsonnew+17−0
next/lexicons/social/grain/server/deleteAccount.jsonnew+64−0
next/lexicons/social/grain/server/getSitemap.jsonnew+35−0
next/lexicons/social/grain/server/getSpaceSupport.jsonnew+39−0
next/lexicons/social/grain/story/defs.jsonnew+73−0
next/lexicons/social/grain/story/getArchive.jsonnew+33−0
next/lexicons/social/grain/story/getAuthors.jsonnew+23−0
next/lexicons/social/grain/story/getStories.jsonnew+28−0
next/lexicons/social/grain/story/getStory.jsonnew+22−0
next/lexicons/social/grain/story/markViewed.jsonnew+30−0
next/lexicons/social/grain/story/story.jsonnew+31−0
next/lexicons/social/grain/sync/indexRecords.jsonnew+52−0
next/lexicons/social/grain/unspecced/addSpaceMember.jsonnew+49−0
next/lexicons/social/grain/unspecced/createGroup.jsonnew+38−0
next/lexicons/social/grain/unspecced/createPoolComment.jsonnew+64−0
next/lexicons/social/grain/unspecced/createPoolGallery.jsonnew+66−0
next/lexicons/social/grain/unspecced/createPrivateGallery.jsonnew+93−0
next/lexicons/social/grain/unspecced/deleteAccount.jsonnew+17−0
next/lexicons/social/grain/unspecced/deleteGallery.jsonnew+27−0
next/lexicons/social/grain/unspecced/deletePoolComment.jsonnew+25−0
next/lexicons/social/grain/unspecced/deletePoolGallery.jsonnew+38−0
next/lexicons/social/grain/unspecced/getActorFavorites.jsonnew+33−0
next/lexicons/social/grain/unspecced/getActorProfile.jsonnew+25−0
next/lexicons/social/grain/unspecced/getBlocks.jsonnew+41−0
next/lexicons/social/grain/unspecced/getCameras.jsonnew+46−0
next/lexicons/social/grain/unspecced/getCommentThread.jsonnew+38−0
next/lexicons/social/grain/unspecced/getFollowers.jsonnew+52−0
next/lexicons/social/grain/unspecced/getFollowing.jsonnew+52−0
next/lexicons/social/grain/unspecced/getGallery.jsonnew+34−0
next/lexicons/social/grain/unspecced/getGalleryFavorites.jsonnew+49−0
next/lexicons/social/grain/unspecced/getGroup.jsonnew+27−0
next/lexicons/social/grain/unspecced/getGroupHost.jsonnew+21−0
next/lexicons/social/grain/unspecced/getGroupSubmissions.jsonnew+48−0
next/lexicons/social/grain/unspecced/getKnownFollowers.jsonnew+45−0
next/lexicons/social/grain/unspecced/getLocations.jsonnew+66−0
next/lexicons/social/grain/unspecced/getMutes.jsonnew+40−0
next/lexicons/social/grain/unspecced/getNotifications.jsonnew+66−0
next/lexicons/social/grain/unspecced/getPoolGallery.jsonnew+144−0
next/lexicons/social/grain/unspecced/getPrivateGallery.jsonnew+67−0
next/lexicons/social/grain/unspecced/getSitemap.jsonnew+59−0
next/lexicons/social/grain/unspecced/getSpaceMembers.jsonnew+46−0
next/lexicons/social/grain/unspecced/getSpaceSupport.jsonnew+45−0
next/lexicons/social/grain/unspecced/getStories.jsonnew+33−0
next/lexicons/social/grain/unspecced/getStory.jsonnew+25−0
next/lexicons/social/grain/unspecced/getStoryArchive.jsonnew+33−0
next/lexicons/social/grain/unspecced/getStoryAuthors.jsonnew+44−0
next/lexicons/social/grain/unspecced/getSuggestedFollows.jsonnew+45−0
next/lexicons/social/grain/unspecced/joinGroup.jsonnew+40−0
next/lexicons/social/grain/unspecced/leaveGroup.jsonnew+30−0
next/lexicons/social/grain/unspecced/listGroups.jsonnew+47−0
next/lexicons/social/grain/unspecced/listPoolFeed.jsonnew+117−0
next/lexicons/social/grain/unspecced/listPoolGalleries.jsonnew+109−0
next/lexicons/social/grain/unspecced/listPrivateGalleries.jsonnew+39−0
next/lexicons/social/grain/unspecced/listSharedGalleries.jsonnew+41−0
next/lexicons/social/grain/unspecced/markStoriesViewed.jsonnew+33−0
next/lexicons/social/grain/unspecced/putPoolFavorite.jsonnew+40−0
next/lexicons/social/grain/unspecced/searchActorsTypeahead.jsonnew+39−0
next/lexicons/social/grain/unspecced/searchGalleries.jsonnew+33−0
next/lexicons/social/grain/unspecced/searchProfiles.jsonnew+47−0
next/lexicons/social/grain/authFull.jsonnew+109−0
next/lexicons/social/grain/basePermissions.jsonnew+29−0
next/lexicons/social/grain/defs.jsonnew+15−0
next/lexicons/social/grain/group.jsonnew+19−0
next/lexicons/social/grain/privateGallery.jsonnew+13−0
next/pages/child-safety.mdnew+51−0
next/pages/community-guidelines.mdnew+39−0
next/pages/copyright.mdnew+21−0
next/pages/privacy.mdnew+41−0
next/pages/terms.mdnew+41−0
next/src/lib/server/hud.tsnew+23−0
next/src/lib/app.tsnew+21−0
next/src/lib/AppPage.sveltenew+60−0
next/src/routes/[...path]/+page.server.tsnew+9−0
next/src/routes/[...path]/+page.sveltenew+7−0
next/src/routes/api/mcp/+server.tsnew+4−0
next/src/routes/api/upload/+server.tsnew+2−0
next/src/routes/auth/callback/+server.tsnew+2−0
next/src/routes/auth/signin/+page.server.tsnew+14−0
next/src/routes/auth/signin/+page.sveltenew+10−0
next/src/routes/auth/signout/+server.tsnew+2−0
next/src/routes/auth/use/+server.tsnew+2−0
next/src/routes/client-metadata.json/+server.tsnew+5−0
next/src/routes/favicon.ico/+server.tsnew+4−0
next/src/routes/favicon.svg/+server.tsnew+4−0
next/src/routes/robots.txt/+server.tsnew+22−0
next/src/routes/sitemap.xml/+server.tsnew+59−0
next/src/routes/+layout.server.tsnew+24−0
next/src/routes/+layout.sveltenew+8−0
next/src/app.d.tsnew+21−0
next/src/app.htmlnew+21−0
next/src/env.tsnew+29−0
next/src/hooks.server.tsnew+48−0
next/static/favicon.pngnew+0−0
A binary file, not shown.
next/static/icon-192.pngnew+0−0
A binary file, not shown.
next/static/icon-512.pngnew+0−0
A binary file, not shown.
next/static/manifest.jsonnew+14−0
next/views/grain-app.jsonnew+1002−0
1002 lines changed: not loaded until asked for.
next/views/grain-blocks.jsonnew+137−0
next/views/grain-cameras.jsonnew+75−0
next/views/grain-comments.jsonnew+407−0
407 lines changed: not loaded until asked for.
next/views/grain-explore.jsonnew+281−0
next/views/grain-feed.jsonnew+1650−0
1650 lines changed: not loaded until asked for.
next/views/grain-followers.jsonnew+133−0
next/views/grain-following.jsonnew+133−0
next/views/grain-known-followers.jsonnew+125−0
next/views/grain-mutes.jsonnew+141−0
next/views/grain-notifications.jsonnew+288−0
next/views/grain-search-people.jsonnew+186−0
next/views/grain-search.jsonnew+136−0
next/views/grain-settings.jsonnew+2778−0
A large diff, not shown.
next/views/grain-stories.jsonnew+413−0
413 lines changed: not loaded until asked for.
next/views/grain-story-archive.jsonnew+287−0
next/.npmrcnew+3−0
next/check-apps.mjsnew+108−0
next/Dockerfilenew+39−0
next/Dockerfile.dockerignorenew+7−0
next/grain.social.jsonnew+519−0
519 lines changed: not loaded until asked for.
next/package-lock.jsonnew+1662−0
1662 lines changed: not loaded until asked for.
next/package.jsonnew+30−0
next/serve.jsnew+133−0
next/tsconfig.jsonnew+8−0
next/vite.config.tsnew+47−0
.dockerignore+4−0
.gitignore+1−0
AGENTS.md+121−0
Justfile+60−0
vite.config.ts+4−2