Track shards separately, upgrade deps

This commit is contained in:
Jon Staab
2025-10-13 13:35:02 -07:00
parent 0cc25913c0
commit 44555215cf
19 changed files with 1109 additions and 1616 deletions
+55 -42
View File
@@ -15,50 +15,50 @@
}, },
"devDependencies": { "devDependencies": {
"@capacitor/assets": "^3.0.5", "@capacitor/assets": "^3.0.5",
"@eslint/js": "^9.26.0", "@eslint/js": "^9.37.0",
"@sentry/cli": "^2.40.0", "@sentry/cli": "^2.56.1",
"@sveltejs/kit": "^2.5.27", "@sveltejs/kit": "^2.46.5",
"@sveltejs/vite-plugin-svelte": "^4.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.4",
"@types/eslint": "^9.6.0", "@types/eslint": "^9.6.1",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.21",
"classnames": "^2.5.1", "classnames": "^2.5.1",
"eslint": "^9.0.0", "eslint": "^9.37.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.2",
"eslint-plugin-svelte": "^2.45.1", "eslint-plugin-svelte": "^2.46.1",
"globals": "^15.0.0", "globals": "^15.15.0",
"postcss": "^8.4.40", "postcss": "^8.5.6",
"prettier": "^3.1.1", "prettier": "^3.6.2",
"prettier-plugin-svelte": "^3.2.6", "prettier-plugin-svelte": "^3.4.0",
"svelte": "^5.0.0", "svelte": "^5.39.12",
"svelte-check": "^4.0.0", "svelte-check": "^4.3.3",
"tailwindcss": "^3.4.7", "tailwindcss": "^3.4.18",
"typescript": "^5.5.0", "typescript": "^5.9.3",
"typescript-eslint": "^8.0.0", "typescript-eslint": "^8.46.1",
"vite": "^5.4.4" "vite": "^5.4.20"
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@capacitor-community/safe-area": "7.0.0-alpha.1", "@capacitor-community/safe-area": "7.0.0-alpha.1",
"@capacitor/android": "^7.0.0", "@capacitor/android": "^7.4.3",
"@capacitor/app": "^7.0.0", "@capacitor/app": "^7.1.0",
"@capacitor/cli": "^7.0.0", "@capacitor/cli": "^7.4.3",
"@capacitor/core": "^7.0.1", "@capacitor/core": "^7.4.3",
"@capacitor/filesystem": "^7.0.0", "@capacitor/filesystem": "^7.1.4",
"@capacitor/ios": "^7.0.0", "@capacitor/ios": "^7.4.3",
"@capacitor/keyboard": "^7.0.0", "@capacitor/keyboard": "^7.0.3",
"@capacitor/preferences": "^7.0.2", "@capacitor/preferences": "^7.0.2",
"@capacitor/push-notifications": "^7.0.1", "@capacitor/push-notifications": "^7.0.3",
"@capawesome/capacitor-android-dark-mode-support": "^7.0.0", "@capawesome/capacitor-android-dark-mode-support": "^7.0.0",
"@capawesome/capacitor-badge": "^7.0.1", "@capawesome/capacitor-badge": "^7.0.1",
"@getalby/sdk": "^5.1.0", "@getalby/sdk": "^5.1.2",
"@poppanator/sveltekit-svg": "^4.2.1", "@poppanator/sveltekit-svg": "^4.2.1",
"@sentry/browser": "^8.35.0", "@sentry/browser": "^8.55.0",
"@sveltejs/adapter-static": "^3.0.4", "@sveltejs/adapter-static": "^3.0.10",
"@tiptap/core": "^2.12.0", "@tiptap/core": "^2.26.3",
"@types/qrcode": "^1.5.5", "@types/qrcode": "^1.5.5",
"@types/throttle-debounce": "^5.0.2", "@types/throttle-debounce": "^5.0.2",
"@vite-pwa/assets-generator": "^0.2.6", "@vite-pwa/assets-generator": "^0.2.6",
"@vite-pwa/sveltekit": "^0.6.6", "@vite-pwa/sveltekit": "^0.6.8",
"@welshman/app": "^0.5.2", "@welshman/app": "^0.5.2",
"@welshman/content": "^0.5.2", "@welshman/content": "^0.5.2",
"@welshman/editor": "^0.5.2", "@welshman/editor": "^0.5.2",
@@ -71,16 +71,16 @@
"@welshman/store": "^0.5.2", "@welshman/store": "^0.5.2",
"@welshman/util": "^0.5.2", "@welshman/util": "^0.5.2",
"compressorjs": "^1.2.1", "compressorjs": "^1.2.1",
"daisyui": "^4.12.10", "daisyui": "^4.12.24",
"date-picker-svelte": "^2.13.0", "date-picker-svelte": "^2.16.0",
"dotenv": "^16.4.5", "dotenv": "^16.6.1",
"emoji-picker-element": "^1.22.8", "emoji-picker-element": "^1.27.0",
"fuse.js": "^7.0.0", "fuse.js": "^7.1.0",
"husky": "^9.1.6", "husky": "^9.1.7",
"idb": "^8.0.0", "idb": "^8.0.3",
"nostr-signer-capacitor-plugin": "^0.0.4", "nostr-signer-capacitor-plugin": "^0.0.4",
"nostr-tools": "^2.14.2", "nostr-tools": "^2.17.0",
"prettier-plugin-tailwindcss": "^0.6.5", "prettier-plugin-tailwindcss": "^0.6.14",
"qr-scanner": "^1.4.2", "qr-scanner": "^1.4.2",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"throttle-debounce": "^5.0.2", "throttle-debounce": "^5.0.2",
@@ -93,6 +93,19 @@
], ],
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [
"sharp" "sharp"
] ],
"overrides": {
"@welshman/app": "link:../welshman/packages/app",
"@welshman/content": "link:../welshman/packages/content",
"@welshman/editor": "link:../welshman/packages/editor",
"@welshman/feeds": "link:../welshman/packages/feeds",
"@welshman/lib": "link:../welshman/packages/lib",
"@welshman/net": "link:../welshman/packages/net",
"@welshman/relay": "link:../welshman/packages/relay",
"@welshman/router": "link:../welshman/packages/router",
"@welshman/signer": "link:../welshman/packages/signer",
"@welshman/store": "link:../welshman/packages/store",
"@welshman/util": "link:../welshman/packages/util"
}
} }
} }
+1004 -1534
View File
File diff suppressed because it is too large Load Diff
@@ -56,7 +56,7 @@
const ciphertext = new Uint8Array(await response.arrayBuffer()) const ciphertext = new Uint8Array(await response.arrayBuffer())
const decryptedData = await decryptFile({ciphertext, key, nonce, algorithm}) const decryptedData = await decryptFile({ciphertext, key, nonce, algorithm})
src = URL.createObjectURL(new Blob([decryptedData])) src = URL.createObjectURL(new Blob([new Uint8Array(decryptedData)]))
} }
} else { } else {
src = url src = url
+1 -1
View File
@@ -744,7 +744,7 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
["encryption-algorithm", algorithm], ["encryption-algorithm", algorithm],
) )
file = new File([new Blob([ciphertext])], name, { file = new File([new Uint8Array(ciphertext)], name, {
type: "application/octet-stream", type: "application/octet-stream",
}) })
} }
+1 -1
View File
@@ -64,7 +64,7 @@ export const getPrimaryNavItemIndex = ($page: Page) => {
case "discover": case "discover":
return urls.length + 2 return urls.length + 2
case "spaces": { case "spaces": {
const routeUrl = decodeRelay($page.params.relay) const routeUrl = decodeRelay($page.params.relay || "")
return urls.findIndex(url => url === routeUrl) + 1 return urls.findIndex(url => url === routeUrl) + 1
} }
+1 -1
View File
@@ -13,7 +13,7 @@
<div data-component="PageBar" class="cw top-sai fixed z-feature p-2"> <div data-component="PageBar" class="cw top-sai fixed z-feature p-2">
<div <div
class="flex min-h-12 items-center justify-between gap-4 rounded-xl rounded-xl bg-base-100 px-4 shadow-xl"> class="flex min-h-12 items-center justify-between gap-4 rounded-xl bg-base-100 px-4 shadow-xl">
<div class="ellipsize flex items-center gap-4 whitespace-nowrap"> <div class="ellipsize flex items-center gap-4 whitespace-nowrap">
{@render props.icon?.()} {@render props.icon?.()}
{@render props.title?.()} {@render props.title?.()}
+25 -23
View File
@@ -1,4 +1,4 @@
import {flatten, identity, groupBy} from "@welshman/lib" import {flatten, noop, identity, groupBy} from "@welshman/lib"
import {type StorageProvider} from "@welshman/store" import {type StorageProvider} from "@welshman/store"
import {Preferences} from "@capacitor/preferences" import {Preferences} from "@capacitor/preferences"
import {Encoding, Filesystem, Directory} from "@capacitor/filesystem" import {Encoding, Filesystem, Directory} from "@capacitor/filesystem"
@@ -38,7 +38,7 @@ export type CollectionOptions<T> = {
} }
export class Collection<T> { export class Collection<T> {
p = Promise.resolve() #promises = new Map<string, Promise<any>>()
constructor(readonly options: CollectionOptions<T>) {} constructor(readonly options: CollectionOptions<T>) {}
@@ -58,36 +58,38 @@ export class Collection<T> {
) )
} }
#then = async (f: () => Promise<void>) => { #then = <R>(shard: string, f: () => Promise<R>) => {
this.p = this.p.then(f).catch(e => { const oldPromise = this.#promises.get(shard) || Promise.resolve()
console.error(e) const newPromise = oldPromise.then(f)
})
await this.p this.#promises.set(shard, newPromise)
return newPromise
} }
#path = (shard: string) => `collection_${this.options.table}_${shard}.json` #path = (shard: string) => `collection_${this.options.table}_${shard}.json`
getShard = async (shard: string): Promise<T[]> => { getShard = (shard: string): Promise<T[]> =>
try { this.#then(shard, async () => {
const file = await Filesystem.readFile({ try {
path: this.#path(shard), const file = await Filesystem.readFile({
directory: Directory.Data, path: this.#path(shard),
encoding: Encoding.UTF8, directory: Directory.Data,
}) encoding: Encoding.UTF8,
})
// Speed things up by parsing only once // Speed things up by parsing only once
return JSON.parse("[" + file.data.toString().split("\n").filter(identity).join(",") + "]") return JSON.parse("[" + file.data.toString().split("\n").filter(identity).join(",") + "]")
} catch (err) { } catch (err) {
// file doesn't exist, or isn't valid json // file doesn't exist, or isn't valid json
return [] return []
} }
} })
get = async (): Promise<T[]> => flatten(await Promise.all(this.options.shards.map(this.getShard))) get = async (): Promise<T[]> => flatten(await Promise.all(this.options.shards.map(this.getShard)))
setShard = (shard: string, items: T[]) => setShard = (shard: string, items: T[]) =>
this.#then(async () => { this.#then(shard, async () => {
await Filesystem.writeFile({ await Filesystem.writeFile({
path: this.#path(shard), path: this.#path(shard),
directory: Directory.Data, directory: Directory.Data,
@@ -104,7 +106,7 @@ export class Collection<T> {
) )
addToShard = (shard: string, items: T[]) => addToShard = (shard: string, items: T[]) =>
this.#then(async () => { this.#then(shard, async () => {
await Filesystem.appendFile({ await Filesystem.appendFile({
path: this.#path(shard), path: this.#path(shard),
directory: Directory.Data, directory: Directory.Data,
+2 -1
View File
@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import {onMount} from "svelte" import {onMount} from "svelte"
import * as nip19 from "nostr-tools/nip19" import * as nip19 from "nostr-tools/nip19"
import type {MakeNonOptional} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util" import type {TrustedEvent} from "@welshman/util"
import {Address, getIdFilters} from "@welshman/util" import {Address, getIdFilters} from "@welshman/util"
import {LOCAL_RELAY_URL} from "@welshman/relay" import {LOCAL_RELAY_URL} from "@welshman/relay"
@@ -10,7 +11,7 @@
import Spinner from "@lib/components/Spinner.svelte" import Spinner from "@lib/components/Spinner.svelte"
import {goToEvent} from "@app/util/routes" import {goToEvent} from "@app/util/routes"
const {bech32} = $page.params const {bech32} = $page.params as MakeNonOptional<typeof $page.params>
const attemptToNavigate = async () => { const attemptToNavigate = async () => {
const {type, data} = nip19.decode(bech32) as any const {type, data} = nip19.decode(bech32) as any
+4 -1
View File
@@ -1,8 +1,11 @@
<script lang="ts"> <script lang="ts">
import {page} from "$app/stores" import {page} from "$app/stores"
import type {MakeNonOptional} from '@welshman/lib'
import Chat from "@app/components/Chat.svelte" import Chat from "@app/components/Chat.svelte"
import {notifications, setChecked} from "@app/util/notifications" import {notifications, setChecked} from "@app/util/notifications"
const {chat} = $page.params as MakeNonOptional<typeof $page.params>
// We have to watch this one, since on mobile the badge will be visible when active // We have to watch this one, since on mobile the badge will be visible when active
$effect(() => { $effect(() => {
if ($notifications.has($page.url.pathname)) { if ($notifications.has($page.url.pathname)) {
@@ -11,4 +14,4 @@
}) })
</script> </script>
<Chat id={$page.params.chat} /> <Chat id={chat} />
+1 -1
View File
@@ -31,7 +31,7 @@
const {children}: Props = $props() const {children}: Props = $props()
const url = decodeRelay($page.params.relay) const url = decodeRelay($page.params.relay!)
const rooms = Array.from($userRoomsByUrl.get(url) || []) const rooms = Array.from($userRoomsByUrl.get(url) || [])
+1 -1
View File
@@ -26,7 +26,7 @@
import {makeChatPath} from "@app/util/routes" import {makeChatPath} from "@app/util/routes"
import {pushModal} from "@app/util/modal" import {pushModal} from "@app/util/modal"
const url = decodeRelay($page.params.relay) const url = decodeRelay($page.params.relay!)
const relay = deriveRelay(url) const relay = deriveRelay(url)
const joinSpace = () => pushModal(SpaceJoin, {url}) const joinSpace = () => pushModal(SpaceJoin, {url})
@@ -5,6 +5,7 @@
import {page} from "$app/stores" import {page} from "$app/stores"
import type {Readable} from "svelte/store" import type {Readable} from "svelte/store"
import {now, formatTimestampAsDate} from "@welshman/lib" import {now, formatTimestampAsDate} from "@welshman/lib"
import type {MakeNonOptional} from "@welshman/lib"
import {request} from "@welshman/net" import {request} from "@welshman/net"
import type {TrustedEvent, EventContent} from "@welshman/util" import type {TrustedEvent, EventContent} from "@welshman/util"
import { import {
@@ -57,10 +58,10 @@
import {popKey} from "@lib/implicit" import {popKey} from "@lib/implicit"
import {pushToast} from "@app/util/toast" import {pushToast} from "@app/util/toast"
const {room} = $page.params const {room, relay} = $page.params as MakeNonOptional<typeof $page.params>
const mounted = now() const mounted = now()
const lastChecked = $checked[$page.url.pathname] const lastChecked = $checked[$page.url.pathname]
const url = decodeRelay($page.params.relay) const url = decodeRelay(relay)
const channel = deriveChannel(url, room) const channel = deriveChannel(url, room)
const filter = {kinds: [MESSAGE], "#h": [room]} const filter = {kinds: [MESSAGE], "#h": [room]}
const isFavorite = $derived($userRoomsByUrl.get(url)?.has(room)) const isFavorite = $derived($userRoomsByUrl.get(url)?.has(room))
@@ -23,7 +23,7 @@
import {makeCalendarFeed} from "@app/core/requests" import {makeCalendarFeed} from "@app/core/requests"
import {setChecked} from "@app/util/notifications" import {setChecked} from "@app/util/notifications"
const url = decodeRelay($page.params.relay) const url = decodeRelay($page.params.relay!)
const makeEvent = () => pushModal(CalendarEventCreate, {url}) const makeEvent = () => pushModal(CalendarEventCreate, {url})
@@ -2,6 +2,7 @@
import {onMount} from "svelte" import {onMount} from "svelte"
import {page} from "$app/stores" import {page} from "$app/stores"
import {sortBy, sleep} from "@welshman/lib" import {sortBy, sleep} from "@welshman/lib"
import type {MakeNonOptional} from "@welshman/lib"
import {COMMENT, getTagValue} from "@welshman/util" import {COMMENT, getTagValue} from "@welshman/util"
import {request} from "@welshman/net" import {request} from "@welshman/net"
import {repository} from "@welshman/app" import {repository} from "@welshman/app"
@@ -25,7 +26,7 @@
import {deriveEvent, decodeRelay} from "@app/core/state" import {deriveEvent, decodeRelay} from "@app/core/state"
import {setChecked} from "@app/util/notifications" import {setChecked} from "@app/util/notifications"
const {relay, id} = $page.params const {relay, id} = $page.params as MakeNonOptional<typeof $page.params>
const url = decodeRelay(relay) const url = decodeRelay(relay)
const event = deriveEvent(id) const event = deriveEvent(id)
const filters = [{kinds: [COMMENT], "#E": [id]}] const filters = [{kinds: [COMMENT], "#E": [id]}]
+1 -1
View File
@@ -36,7 +36,7 @@
const mounted = now() const mounted = now()
const lastChecked = $checked[$page.url.pathname] const lastChecked = $checked[$page.url.pathname]
const url = decodeRelay($page.params.relay) const url = decodeRelay($page.params.relay!)
const filter = {kinds: [MESSAGE]} const filter = {kinds: [MESSAGE]}
const shouldProtect = canEnforceNip70(url) const shouldProtect = canEnforceNip70(url)
+1 -1
View File
@@ -20,7 +20,7 @@
import {makeFeed} from "@app/core/requests" import {makeFeed} from "@app/core/requests"
import {pushModal} from "@app/util/modal" import {pushModal} from "@app/util/modal"
const url = decodeRelay($page.params.relay) const url = decodeRelay($page.params.relay!)
const mutedPubkeys = getPubkeyTagValues(getListTags($userMutes)) const mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
const goals: TrustedEvent[] = $state([]) const goals: TrustedEvent[] = $state([])
const comments: TrustedEvent[] = $state([]) const comments: TrustedEvent[] = $state([])
@@ -2,6 +2,7 @@
import {onMount} from "svelte" import {onMount} from "svelte"
import {page} from "$app/stores" import {page} from "$app/stores"
import {sortBy, sleep} from "@welshman/lib" import {sortBy, sleep} from "@welshman/lib"
import type {MakeNonOptional} from "@welshman/lib"
import {COMMENT, getTagValue} from "@welshman/util" import {COMMENT, getTagValue} from "@welshman/util"
import {repository} from "@welshman/app" import {repository} from "@welshman/app"
import {request} from "@welshman/net" import {request} from "@welshman/net"
@@ -24,7 +25,7 @@
import {deriveEvent, decodeRelay} from "@app/core/state" import {deriveEvent, decodeRelay} from "@app/core/state"
import {setChecked} from "@app/util/notifications" import {setChecked} from "@app/util/notifications"
const {relay, id} = $page.params const {relay, id} = $page.params as MakeNonOptional<typeof $page.params>
const url = decodeRelay(relay) const url = decodeRelay(relay)
const event = deriveEvent(id) const event = deriveEvent(id)
const filters = [{kinds: [COMMENT], "#E": [id]}] const filters = [{kinds: [COMMENT], "#E": [id]}]
@@ -21,7 +21,7 @@
import {makeFeed} from "@app/core/requests" import {makeFeed} from "@app/core/requests"
import {pushModal} from "@app/util/modal" import {pushModal} from "@app/util/modal"
const url = decodeRelay($page.params.relay) const url = decodeRelay($page.params.relay!)
const mutedPubkeys = getPubkeyTagValues(getListTags($userMutes)) const mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
const threads: TrustedEvent[] = $state([]) const threads: TrustedEvent[] = $state([])
const comments: TrustedEvent[] = $state([]) const comments: TrustedEvent[] = $state([])
@@ -2,6 +2,7 @@
import {onMount} from "svelte" import {onMount} from "svelte"
import {page} from "$app/stores" import {page} from "$app/stores"
import {sortBy, sleep} from "@welshman/lib" import {sortBy, sleep} from "@welshman/lib"
import type {MakeNonOptional} from "@welshman/lib"
import {COMMENT, getTagValue} from "@welshman/util" import {COMMENT, getTagValue} from "@welshman/util"
import {repository} from "@welshman/app" import {repository} from "@welshman/app"
import {request} from "@welshman/net" import {request} from "@welshman/net"
@@ -23,7 +24,7 @@
import {deriveEvent, decodeRelay} from "@app/core/state" import {deriveEvent, decodeRelay} from "@app/core/state"
import {setChecked} from "@app/util/notifications" import {setChecked} from "@app/util/notifications"
const {relay, id} = $page.params const {relay, id} = $page.params as MakeNonOptional<typeof $page.params>
const url = decodeRelay(relay) const url = decodeRelay(relay)
const event = deriveEvent(id) const event = deriveEvent(id)
const filters = [{kinds: [COMMENT], "#E": [id]}] const filters = [{kinds: [COMMENT], "#E": [id]}]