Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52918265ea | |||
| a1af7ce25f | |||
| 9f83f1e1b7 | |||
| 075964a449 | |||
| fa2b40cbb6 | |||
| 3225b4e652 |
10 changed files with 245 additions and 53 deletions
|
|
@ -10,18 +10,101 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repo
|
- name: Check out repo
|
||||||
uses: https://data.forgejo.org/actions/checkout@v4
|
uses: https://data.forgejo.org/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Install Packages
|
||||||
|
run: apt-get update && apt-get install -y sudo curl jq
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: https://github.com/cachix/install-nix-action@v30
|
||||||
|
|
||||||
|
- name: Install Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Setup Android Keystore
|
||||||
|
env:
|
||||||
|
KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||||
|
KEYSTORE_PROPERTIES: ${{ secrets.ANDROID_KEYSTORE_PROPERTIES }}
|
||||||
|
run: |
|
||||||
|
bun -e "require('fs').writeFileSync('keystore.jks', Buffer.from(process.env.KEYSTORE_BASE64.replace(/\s+/g, ''), 'base64'))"
|
||||||
|
bun -e "const content = process.env.KEYSTORE_PROPERTIES.replace(/\\\\n/g, '\n').replace(/\\r/g, '').split('\n').map(l => l.trim()).filter(l => l).join('\n'); require('fs').writeFileSync('keystore.properties', content)"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: bun run build:web
|
run: bun run build:apps
|
||||||
|
|
||||||
- name: Install rsync
|
- name: Install rsync
|
||||||
run: apt-get update && apt-get install -y rsync
|
run: apt-get update && apt-get install -y rsync
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
run: rsync -a --delete apps/web/dist/ /var/lib/www/tensamin-web-dev/
|
run: rsync -a --delete apps/web/dist/ /var/lib/www/tensamin-web-dev/
|
||||||
|
|
||||||
|
- name: Read version and hash
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION="$(node -p "require('./package.json').version")"
|
||||||
|
SHORT_SHA="$(git rev-parse --short HEAD)"
|
||||||
|
echo "version=$VERSION" >> "$FORGEJO_OUTPUT"
|
||||||
|
echo "short_sha=$SHORT_SHA" >> "$FORGEJO_OUTPUT"
|
||||||
|
echo "tag=${VERSION}-dev-${SHORT_SHA}" >> "$FORGEJO_OUTPUT"
|
||||||
|
echo "title=${VERSION}-dev-${SHORT_SHA}" >> "$FORGEJO_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create pre-release and upload files
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ forgejo.token }}
|
||||||
|
API: ${{ forgejo.api_url }}
|
||||||
|
REPO: ${{ forgejo.repository }}
|
||||||
|
SHA: ${{ forgejo.sha }}
|
||||||
|
TAG: ${{ steps.version.outputs.tag }}
|
||||||
|
TITLE: ${{ steps.version.outputs.title }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
test -d releases
|
||||||
|
find releases -type f | grep -q .
|
||||||
|
|
||||||
|
LATEST_PROD_TAG="$(git tag --list 'v*' --sort=-v:refname | head -n 1 || true)"
|
||||||
|
if [ -n "$LATEST_PROD_TAG" ]; then
|
||||||
|
LOG="$(git log "$LATEST_PROD_TAG"..HEAD --pretty=format:'- %s')"
|
||||||
|
SERVER_URL="$(echo "$API" | sed 's|/api/v1.*||')"
|
||||||
|
COMPARE_URL="${SERVER_URL}/${REPO}/compare/${LATEST_PROD_TAG}...${TAG}"
|
||||||
|
BODY="$(printf '%s\n\n[View changes](%s)' "$LOG" "$COMPARE_URL")"
|
||||||
|
else
|
||||||
|
BODY="$(git log --pretty=format:'- %s')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTTP_STATUS=$(curl -s -w "%{http_code}" -o release_out.json -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG")
|
||||||
|
|
||||||
|
if [ "$HTTP_STATUS" = "200" ]; then
|
||||||
|
echo "Release $TAG already exists."
|
||||||
|
RELEASE_ID="$(jq -r .id release_out.json)"
|
||||||
|
else
|
||||||
|
echo "Creating new pre-release for $TAG"
|
||||||
|
RELEASE_JSON="$(curl -f -sS -X POST "$API/repos/$REPO/releases" \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$(jq -n \
|
||||||
|
--arg tag "$TAG" \
|
||||||
|
--arg name "$TITLE" \
|
||||||
|
--arg body "$BODY" \
|
||||||
|
--arg target "$SHA" \
|
||||||
|
'{
|
||||||
|
tag_name: $tag,
|
||||||
|
name: $name,
|
||||||
|
body: $body,
|
||||||
|
target_commitish: $target,
|
||||||
|
draft: false,
|
||||||
|
prerelease: true
|
||||||
|
}')")"
|
||||||
|
RELEASE_ID="$(echo "$RELEASE_JSON" | jq -r .id)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
find releases -type f -print0 | while IFS= read -r -d '' file; do
|
||||||
|
name="$(basename "$file")"
|
||||||
|
curl -fsS -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$name" \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-F "attachment=@$file"
|
||||||
|
done
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
VERSION="$(node -p "require('./package.json').version")"
|
VERSION="$(node -p "require('./package.json').version")"
|
||||||
echo "version=$VERSION" >> "$FORGEJO_OUTPUT"
|
echo "version=$VERSION" >> "$FORGEJO_OUTPUT"
|
||||||
echo "tag=v$VERSION" >> "$FORGEJO_OUTPUT"
|
echo "tag=${VERSION}-prod" >> "$FORGEJO_OUTPUT"
|
||||||
|
|
||||||
- name: Create release and upload files
|
- name: Create release and upload files
|
||||||
env:
|
env:
|
||||||
|
|
@ -54,39 +54,40 @@ jobs:
|
||||||
REPO: ${{ forgejo.repository }}
|
REPO: ${{ forgejo.repository }}
|
||||||
SHA: ${{ forgejo.sha }}
|
SHA: ${{ forgejo.sha }}
|
||||||
TAG: ${{ steps.version.outputs.tag }}
|
TAG: ${{ steps.version.outputs.tag }}
|
||||||
VERSION: ${{ steps.version.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
test -d releases
|
test -d releases
|
||||||
find releases -type f | grep -q .
|
find releases -type f | grep -q .
|
||||||
|
|
||||||
|
COMMIT_MSG="$(git log -1 --pretty=%B | sed 's/$/ /')"
|
||||||
|
|
||||||
HTTP_STATUS=$(curl -s -w "%{http_code}" -o release_out.json -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG")
|
HTTP_STATUS=$(curl -s -w "%{http_code}" -o release_out.json -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG")
|
||||||
|
|
||||||
if [ "$HTTP_STATUS" = "200" ]; then
|
if [ "$HTTP_STATUS" = "200" ]; then
|
||||||
echo "Release $TAG already exists."
|
echo "Release $TAG already exists."
|
||||||
RELEASE_ID="$(jq -r .id release_out.json)"
|
exit 0
|
||||||
else
|
|
||||||
echo "Creating new release for $TAG"
|
|
||||||
RELEASE_JSON="$(curl -f -sS -X POST "$API/repos/$REPO/releases" \
|
|
||||||
-H "Authorization: token $TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$(jq -n \
|
|
||||||
--arg tag "$TAG" \
|
|
||||||
--arg name "$TAG" \
|
|
||||||
--arg body "Release $VERSION" \
|
|
||||||
--arg target "$SHA" \
|
|
||||||
'{
|
|
||||||
tag_name: $tag,
|
|
||||||
name: $name,
|
|
||||||
body: $body,
|
|
||||||
target_commitish: $target,
|
|
||||||
draft: false,
|
|
||||||
prerelease: false
|
|
||||||
}')")"
|
|
||||||
RELEASE_ID="$(echo "$RELEASE_JSON" | jq -r .id)"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Creating new release for $TAG"
|
||||||
|
RELEASE_JSON="$(curl -f -sS -X POST "$API/repos/$REPO/releases" \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$(jq -n \
|
||||||
|
--arg tag "$TAG" \
|
||||||
|
--arg name "$TAG" \
|
||||||
|
--arg body "$COMMIT_MSG" \
|
||||||
|
--arg target "$SHA" \
|
||||||
|
'{
|
||||||
|
tag_name: $tag,
|
||||||
|
name: $name,
|
||||||
|
body: $body,
|
||||||
|
target_commitish: $target,
|
||||||
|
draft: false,
|
||||||
|
prerelease: false
|
||||||
|
}')")"
|
||||||
|
RELEASE_ID="$(echo "$RELEASE_JSON" | jq -r .id)"
|
||||||
|
|
||||||
find releases -type f -print0 | while IFS= read -r -d '' file; do
|
find releases -type f -print0 | while IFS= read -r -d '' file; do
|
||||||
name="$(basename "$file")"
|
name="$(basename "$file")"
|
||||||
curl -fsS -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$name" \
|
curl -fsS -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$name" \
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const fetchedUser = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
username: z.string().min(1).max(15),
|
username: z.string().min(1).max(255),
|
||||||
private_key: z.string().min(1).max(92),
|
private_key: z.string().min(1).max(92),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -35,6 +35,7 @@ const formSchema = z.object({
|
||||||
function parseTuFileContent(rawFileContent: string): {
|
function parseTuFileContent(rawFileContent: string): {
|
||||||
userId: number;
|
userId: number;
|
||||||
privateKey: string;
|
privateKey: string;
|
||||||
|
domain: string | null;
|
||||||
} {
|
} {
|
||||||
if (rawFileContent.trim().length === 0) {
|
if (rawFileContent.trim().length === 0) {
|
||||||
throw new Error("File is empty");
|
throw new Error("File is empty");
|
||||||
|
|
@ -42,21 +43,44 @@ function parseTuFileContent(rawFileContent: string): {
|
||||||
throw new Error("Invalid file");
|
throw new Error("Invalid file");
|
||||||
} else if (rawFileContent.split("::").length !== 2) {
|
} else if (rawFileContent.split("::").length !== 2) {
|
||||||
throw new Error("Invalid file");
|
throw new Error("Invalid file");
|
||||||
} else if (rawFileContent.split("::")[0].length === 0) {
|
}
|
||||||
|
|
||||||
|
const left = rawFileContent.split("::")[0];
|
||||||
|
const right = rawFileContent.split("::")[1];
|
||||||
|
|
||||||
|
if (left.length === 0) {
|
||||||
throw new Error("Invalid file");
|
throw new Error("Invalid file");
|
||||||
} else if (rawFileContent.split("::")[1].length === 0) {
|
} else if (right.length === 0) {
|
||||||
throw new Error("Invalid file");
|
throw new Error("Invalid file");
|
||||||
} else if (isNaN(Number(rawFileContent.split("::")[0]))) {
|
} else if (isNaN(Number(left)) && !left.includes("@")) {
|
||||||
throw new Error("Invalid file");
|
throw new Error("Invalid file");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [userIdString, privateKey] = rawFileContent.split("::");
|
const [userIdString, privateKey] = rawFileContent.split("::");
|
||||||
const userId = Number(userIdString);
|
const userId = isNaN(Number(userIdString))
|
||||||
|
? Number(userIdString.split("@")[0])
|
||||||
|
: Number(userIdString);
|
||||||
|
|
||||||
|
const rawDomain = userIdString.includes("@")
|
||||||
|
? userIdString.split("@")[1]
|
||||||
|
: null;
|
||||||
|
const domain = rawDomain
|
||||||
|
? rawDomain.includes(":")
|
||||||
|
? rawDomain
|
||||||
|
: rawDomain + ":1984"
|
||||||
|
: null;
|
||||||
|
|
||||||
if (!userId || !privateKey) {
|
if (!userId || !privateKey) {
|
||||||
throw new Error("Invalid file");
|
throw new Error("Invalid file");
|
||||||
}
|
}
|
||||||
|
|
||||||
return { userId, privateKey };
|
console.log({
|
||||||
|
domain,
|
||||||
|
rawDomain,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
return { userId, privateKey, domain };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -86,6 +110,9 @@ export default function Form() {
|
||||||
await save("session_id", Date.now());
|
await save("session_id", Date.now());
|
||||||
await save("user_id", parsed.userId);
|
await save("user_id", parsed.userId);
|
||||||
await save("private_key", parsed.privateKey);
|
await save("private_key", parsed.privateKey);
|
||||||
|
if (parsed.domain) {
|
||||||
|
await save("ttp_url", `https://${parsed.domain}/`);
|
||||||
|
}
|
||||||
|
|
||||||
location.href = "/";
|
location.href = "/";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -114,9 +141,22 @@ export default function Form() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const inputUsername = inputParse.data.username;
|
||||||
|
const actualUsername = inputUsername.includes("@")
|
||||||
|
? inputUsername.split("@")[0]
|
||||||
|
: inputUsername;
|
||||||
|
const rawDomain = inputUsername.includes("@")
|
||||||
|
? inputUsername.split("@")[1]
|
||||||
|
: null;
|
||||||
|
const domain = rawDomain
|
||||||
|
? rawDomain.includes(":")
|
||||||
|
? rawDomain
|
||||||
|
: rawDomain + ":1984"
|
||||||
|
: null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://omega.tensamin.net/api/get/id/${inputParse.data.username}`,
|
`https://omega.tensamin.net/api/get/id/${actualUsername}`,
|
||||||
);
|
);
|
||||||
const rawData = await response.arrayBuffer();
|
const rawData = await response.arrayBuffer();
|
||||||
|
|
||||||
|
|
@ -137,6 +177,9 @@ export default function Form() {
|
||||||
await save("session_id", Date.now());
|
await save("session_id", Date.now());
|
||||||
await save("user_id", user.user_id);
|
await save("user_id", user.user_id);
|
||||||
await save("private_key", inputParse.data.private_key);
|
await save("private_key", inputParse.data.private_key);
|
||||||
|
if (domain) {
|
||||||
|
await save("ttp_url", `https://${domain}/`);
|
||||||
|
}
|
||||||
|
|
||||||
location.href = "/";
|
location.href = "/";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -154,7 +197,7 @@ export default function Form() {
|
||||||
{isTauriEnv ? (
|
{isTauriEnv ? (
|
||||||
<>
|
<>
|
||||||
<QrCodeScanner
|
<QrCodeScanner
|
||||||
onData={(data) => {
|
onData={async (data) => {
|
||||||
if (!data.startsWith("tensamin://tu::")) {
|
if (!data.startsWith("tensamin://tu::")) {
|
||||||
toast("error", "Invalid QR code");
|
toast("error", "Invalid QR code");
|
||||||
return;
|
return;
|
||||||
|
|
@ -162,10 +205,14 @@ export default function Form() {
|
||||||
const decoded = data.replace("tensamin://tu::", "");
|
const decoded = data.replace("tensamin://tu::", "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { userId, privateKey } = parseTuFileContent(decoded);
|
const { userId, privateKey, domain } =
|
||||||
save("session_id", Date.now());
|
parseTuFileContent(decoded);
|
||||||
save("user_id", userId);
|
await save("session_id", Date.now());
|
||||||
save("private_key", privateKey);
|
await save("user_id", userId);
|
||||||
|
await save("private_key", privateKey);
|
||||||
|
if (domain) {
|
||||||
|
await save("ttp_url", `https://${domain}/`);
|
||||||
|
}
|
||||||
location.href = "/";
|
location.href = "/";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log(0, "login", "red", error);
|
log(0, "login", "red", error);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
Sidebar as SidebarRoot,
|
Sidebar as SidebarRoot,
|
||||||
SidebarContent,
|
SidebarContent,
|
||||||
SidebarFooter,
|
SidebarFooter,
|
||||||
|
useSidebar,
|
||||||
} from "@tensamin/ui";
|
} from "@tensamin/ui";
|
||||||
import { isTauri } from "@tauri-apps/api/core";
|
import { isTauri } from "@tauri-apps/api/core";
|
||||||
import { useIsMobile } from "@tensamin/ui";
|
import { useIsMobile } from "@tensamin/ui";
|
||||||
|
|
@ -13,17 +14,21 @@ import { MobileNavbar } from "./navbar";
|
||||||
|
|
||||||
import SidebarBox from "@tensamin/call/sidebarBox";
|
import SidebarBox from "@tensamin/call/sidebarBox";
|
||||||
import { useShowMobileNavbar } from "@/routes/app/layout";
|
import { useShowMobileNavbar } from "@/routes/app/layout";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the conversation sidebar with account summary and conversation list.
|
* Renders the conversation sidebar with account summary and conversation list.
|
||||||
|
* On mobile the sidebar is always kept in the DOM and hidden via CSS
|
||||||
|
* (opacity + translateX) instead of being unmounted. This keeps the DOM and
|
||||||
|
* React state alive while the drawer is closed, allowing the sidebar to open
|
||||||
|
* instantly on subsequent toggles.
|
||||||
* @returns Sidebar JSX.
|
* @returns Sidebar JSX.
|
||||||
*/
|
*/
|
||||||
export default function Sidebar() {
|
export default function Sidebar() {
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const showMobileNavbar = useShowMobileNavbar();
|
const showMobileNavbar = useShowMobileNavbar();
|
||||||
|
const { openMobile, setOpenMobile } = useSidebar();
|
||||||
|
|
||||||
return (
|
const content = (
|
||||||
<SidebarRoot className="border-0!">
|
<>
|
||||||
<SidebarContent
|
<SidebarContent
|
||||||
className={
|
className={
|
||||||
isTauri() && isMobile ? "pt-[env(safe-area-inset-top)]" : "pt-2"
|
isTauri() && isMobile ? "pt-[env(safe-area-inset-top)]" : "pt-2"
|
||||||
|
|
@ -52,6 +57,34 @@ export default function Sidebar() {
|
||||||
<SidebarBox />
|
<SidebarBox />
|
||||||
</SidebarFooter>
|
</SidebarFooter>
|
||||||
)}
|
)}
|
||||||
</SidebarRoot>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isMobile) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{openMobile && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-40 bg-black/10"
|
||||||
|
onClick={() => setOpenMobile(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
data-sidebar="sidebar"
|
||||||
|
data-slot="sidebar"
|
||||||
|
data-mobile="true"
|
||||||
|
className="fixed inset-y-0 left-0 z-50 w-screen bg-sidebar p-0 text-sidebar-foreground transition-[transform,opacity] duration-150 ease-linear"
|
||||||
|
style={{
|
||||||
|
transform: openMobile ? "translateX(0)" : "translateX(-100%)",
|
||||||
|
opacity: openMobile ? 1 : 0,
|
||||||
|
pointerEvents: openMobile ? "auto" : "none",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="flex h-full w-full flex-col">{content}</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <SidebarRoot className="border-0!">{content}</SidebarRoot>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Button } from "@tensamin/ui";
|
import { Button, ClearStorageButton } from "@tensamin/ui";
|
||||||
|
|
||||||
import options from "@tensamin/shared/settings";
|
import options from "@tensamin/shared/settings";
|
||||||
import { cn, useIsMobile } from "@tensamin/ui";
|
import { cn, useIsMobile } from "@tensamin/ui";
|
||||||
|
|
@ -69,6 +69,9 @@ export function SettingsSidebar() {
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
<div className="mt-auto">
|
||||||
|
<ClearStorageButton className="w-full" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
bun.lock
4
bun.lock
|
|
@ -259,7 +259,7 @@
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.17.tar.gz",
|
"@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.17.tar.gz",
|
||||||
"@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.31.tar.gz",
|
"@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.34.tar.gz",
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
"@antfu/ni": ["@antfu/ni@25.0.0", "", { "dependencies": { "ansis": "^4.0.0", "fzf": "^0.5.2", "package-manager-detector": "^1.3.0", "tinyexec": "^1.0.1" }, "bin": { "na": "bin/na.mjs", "ni": "bin/ni.mjs", "nr": "bin/nr.mjs", "nci": "bin/nci.mjs", "nlx": "bin/nlx.mjs", "nun": "bin/nun.mjs", "nup": "bin/nup.mjs" } }, "sha512-9q/yCljni37pkMr4sPrI3G4jqdIk074+iukc5aFJl7kmDCCsiJrbZ6zKxnES1Gwg+i9RcDZwvktl23puGslmvA=="],
|
"@antfu/ni": ["@antfu/ni@25.0.0", "", { "dependencies": { "ansis": "^4.0.0", "fzf": "^0.5.2", "package-manager-detector": "^1.3.0", "tinyexec": "^1.0.1" }, "bin": { "na": "bin/na.mjs", "ni": "bin/ni.mjs", "nr": "bin/nr.mjs", "nci": "bin/nci.mjs", "nlx": "bin/nlx.mjs", "nun": "bin/nun.mjs", "nup": "bin/nup.mjs" } }, "sha512-9q/yCljni37pkMr4sPrI3G4jqdIk074+iukc5aFJl7kmDCCsiJrbZ6zKxnES1Gwg+i9RcDZwvktl23puGslmvA=="],
|
||||||
|
|
@ -700,7 +700,7 @@
|
||||||
|
|
||||||
"@tensamin/ttp-core": ["@tensamin/ttp-core@https://git.methanium.net/tensamin/ttp/archive/0.0.17.tar.gz", { "dependencies": { "@eslint/js": "^10.0.1", "@typescript-eslint/parser": "^8.59.1", "@webtransport-bun/webtransport": "^0.3.0", "globals": "^17.5.0", "typescript": "^6.0.3", "typescript-eslint": "^8.59.1", "zod": "^4.4.1" } }, "sha512-smyx+04hSnWM1oyWJfJrRWmxu7OInwyHeIlaD1h3tUrkrSxiKWHl1qCmxVO1bC+cDwyUXhJ5HUnNCbx1aWx7Dg=="],
|
"@tensamin/ttp-core": ["@tensamin/ttp-core@https://git.methanium.net/tensamin/ttp/archive/0.0.17.tar.gz", { "dependencies": { "@eslint/js": "^10.0.1", "@typescript-eslint/parser": "^8.59.1", "@webtransport-bun/webtransport": "^0.3.0", "globals": "^17.5.0", "typescript": "^6.0.3", "typescript-eslint": "^8.59.1", "zod": "^4.4.1" } }, "sha512-smyx+04hSnWM1oyWJfJrRWmxu7OInwyHeIlaD1h3tUrkrSxiKWHl1qCmxVO1bC+cDwyUXhJ5HUnNCbx1aWx7Dg=="],
|
||||||
|
|
||||||
"@tensamin/ui": ["@tensamin/ui@https://git.methanium.net/tensamin/ui/archive/0.0.31.tar.gz", { "dependencies": { "@base-ui/react": "^1.3.0", "@fontsource-variable/inter": "^5.2.6", "@tauri-apps/api": "^2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", "date-fns": "^4.1.0", "embla-carousel-react": "^8.6.0", "input-otp": "^1.4.2", "lucide-react": "^1.8.0", "next-themes": "^0.4.6", "react-day-picker": "^9.14.0", "react-resizable-panels": "^4.10.0", "recharts": "3.8.0", "shadcn": "^3.5.0", "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "tw-animate-css": "^1.3.0", "vaul": "^1.1.2" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-I2FhsDtR5ElHwCasf6CfFCiyr5T2Cp9MQ2uAhcMnoNZ0tsK0mJhs+Rz9nUDmysydNyqOj8j/uC0CYXnnG1pCxQ=="],
|
"@tensamin/ui": ["@tensamin/ui@https://git.methanium.net/tensamin/ui/archive/0.0.34.tar.gz", { "dependencies": { "@base-ui/react": "^1.3.0", "@fontsource-variable/inter": "^5.2.6", "@tauri-apps/api": "^2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", "date-fns": "^4.1.0", "embla-carousel-react": "^8.6.0", "input-otp": "^1.4.2", "lucide-react": "^1.8.0", "next-themes": "^0.4.6", "react-day-picker": "^9.14.0", "react-resizable-panels": "^4.10.0", "recharts": "3.8.0", "shadcn": "^3.5.0", "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "tw-animate-css": "^1.3.0", "vaul": "^1.1.2" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-hp7rV0a0gfD/rNw9et+PqM1PPkgFC6/Z7eYfza6NIp/m+a8/r5Um+S/8tzBDCgZmQC9Y1sJsjesH7mXZz6Jmuw=="],
|
||||||
|
|
||||||
"@tensamin/user": ["@tensamin/user@workspace:packages/user"],
|
"@tensamin/user": ["@tensamin/user@workspace:packages/user"],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
"jsonc-parser": "^3.3.1"
|
"jsonc-parser": "^3.3.1"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.31.tar.gz",
|
"@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.34.tar.gz",
|
||||||
"@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.17.tar.gz"
|
"@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.17.tar.gz"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,7 @@ export interface Storage extends SettingsStorageDefaults {
|
||||||
legal_docs: z.infer<typeof legalDocsSchema>;
|
legal_docs: z.infer<typeof legalDocsSchema>;
|
||||||
cached_contacts: Contacts;
|
cached_contacts: Contacts;
|
||||||
cached_communities: Communities;
|
cached_communities: Communities;
|
||||||
|
ttp_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const storageDefaults: Storage = {
|
export const storageDefaults: Storage = {
|
||||||
|
|
@ -276,4 +277,5 @@ export const storageDefaults: Storage = {
|
||||||
},
|
},
|
||||||
cached_contacts: [],
|
cached_contacts: [],
|
||||||
cached_communities: [],
|
cached_communities: [],
|
||||||
|
ttp_url: "https://tensamin.net:959",
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import {
|
||||||
RECONNECT_RESET,
|
RECONNECT_RESET,
|
||||||
RECONNECT_TRIES,
|
RECONNECT_TRIES,
|
||||||
RETRY_INTERVAL,
|
RETRY_INTERVAL,
|
||||||
TRANSPORT_URL,
|
|
||||||
} from "./values";
|
} from "./values";
|
||||||
import {
|
import {
|
||||||
type Calls,
|
type Calls,
|
||||||
|
|
@ -193,6 +192,14 @@ export function Provider(props: {
|
||||||
> | null>(null);
|
> | null>(null);
|
||||||
const identificationStartedRef = useRef(false);
|
const identificationStartedRef = useRef(false);
|
||||||
|
|
||||||
|
// Load ttp url
|
||||||
|
const [ttpUrl, setTtpUrl] = useState<string | null>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
load("ttp_url").then((url) => {
|
||||||
|
setTtpUrl(url);
|
||||||
|
});
|
||||||
|
}, [load]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends typed protocol messages through the active transport client.
|
* Sends typed protocol messages through the active transport client.
|
||||||
* @param type Protocol message type.
|
* @param type Protocol message type.
|
||||||
|
|
@ -266,6 +273,10 @@ export function Provider(props: {
|
||||||
}, [connected, identified, send]);
|
}, [connected, identified, send]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!ttpUrl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
let reconnectResetTimer: ReturnType<typeof setTimeout> | null = null;
|
let reconnectResetTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
|
@ -343,7 +354,7 @@ export function Provider(props: {
|
||||||
|
|
||||||
const transportClient = !props.blockConnection
|
const transportClient = !props.blockConnection
|
||||||
? createTransportClient(schemas, {
|
? createTransportClient(schemas, {
|
||||||
url: TRANSPORT_URL,
|
url: ttpUrl,
|
||||||
onReadyStateChange: (state) => {
|
onReadyStateChange: (state) => {
|
||||||
currentReadyState = state;
|
currentReadyState = state;
|
||||||
setReadyState(state);
|
setReadyState(state);
|
||||||
|
|
@ -392,8 +403,12 @@ export function Provider(props: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ttpUrl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await transportClient?.connect(TRANSPORT_URL);
|
await transportClient?.connect(ttpUrl);
|
||||||
} catch (connectError) {
|
} catch (connectError) {
|
||||||
if (disposed) {
|
if (disposed) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -460,7 +475,7 @@ export function Provider(props: {
|
||||||
setIdentifying(false);
|
setIdentifying(false);
|
||||||
identificationStartedRef.current = false;
|
identificationStartedRef.current = false;
|
||||||
};
|
};
|
||||||
}, [props.blockConnection]);
|
}, [props.blockConnection, ttpUrl]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
|
|
@ -603,14 +618,19 @@ export function Provider(props: {
|
||||||
}, [connected, decrypt, getSharedSecret, load, send]);
|
}, [connected, decrypt, getSharedSecret, load, send]);
|
||||||
|
|
||||||
const progress = useMemo(() => {
|
const progress = useMemo(() => {
|
||||||
|
if (!ttpUrl) return 10;
|
||||||
if (readyState === READY_STATE.CONNECTING) return 30;
|
if (readyState === READY_STATE.CONNECTING) return 30;
|
||||||
if (!connected) return 45;
|
if (!connected) return 45;
|
||||||
if (identifying) return 75;
|
if (identifying) return 75;
|
||||||
if (!identified) return 90;
|
if (!identified) return 90;
|
||||||
return 100;
|
return 100;
|
||||||
}, [connected, identified, identifying, readyState]);
|
}, [connected, identified, identifying, readyState, ttpUrl]);
|
||||||
|
|
||||||
const loadingTitle = useMemo(() => {
|
const loadingTitle = useMemo(() => {
|
||||||
|
if (!ttpUrl) {
|
||||||
|
return "Looking up configuration";
|
||||||
|
}
|
||||||
|
|
||||||
if (readyState === READY_STATE.CONNECTING || !connected) {
|
if (readyState === READY_STATE.CONNECTING || !connected) {
|
||||||
return "Connecting to Tensamin";
|
return "Connecting to Tensamin";
|
||||||
}
|
}
|
||||||
|
|
@ -620,9 +640,13 @@ export function Provider(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Loading";
|
return "Loading";
|
||||||
}, [connected, identified, identifying, readyState]);
|
}, [connected, identified, identifying, readyState, ttpUrl]);
|
||||||
|
|
||||||
const loadingDescription = useMemo(() => {
|
const loadingDescription = useMemo(() => {
|
||||||
|
if (!ttpUrl) {
|
||||||
|
return "Loading connection details";
|
||||||
|
}
|
||||||
|
|
||||||
if (readyState === READY_STATE.CONNECTING || !connected) {
|
if (readyState === READY_STATE.CONNECTING || !connected) {
|
||||||
return "Establishing transport channel";
|
return "Establishing transport channel";
|
||||||
}
|
}
|
||||||
|
|
@ -632,13 +656,13 @@ export function Provider(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}, [connected, identified, identifying, readyState]);
|
}, [connected, identified, identifying, readyState, ttpUrl]);
|
||||||
|
|
||||||
if (error !== "" && errorDescription !== "") {
|
if (error !== "" && errorDescription !== "") {
|
||||||
return <ErrorScreen error={error} description={errorDescription} />;
|
return <ErrorScreen error={error} description={errorDescription} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connected || !identified) {
|
if (!connected || !identified || !ttpUrl) {
|
||||||
return (
|
return (
|
||||||
<Loading
|
<Loading
|
||||||
progress={progress}
|
progress={progress}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,5 @@ export const RESPONSE_TIMEOUT = 15_000;
|
||||||
export const RETRY_COUNT = 10;
|
export const RETRY_COUNT = 10;
|
||||||
export const RETRY_INTERVAL = 3_000;
|
export const RETRY_INTERVAL = 3_000;
|
||||||
export const PING_INTERVAL = 3_000;
|
export const PING_INTERVAL = 3_000;
|
||||||
export const TRANSPORT_URL = "https://tensamin.net:959";
|
|
||||||
export const RECONNECT_TRIES = 3;
|
export const RECONNECT_TRIES = 3;
|
||||||
export const RECONNECT_RESET = 6;
|
export const RECONNECT_RESET = 6;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue