Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
},
"globals": {
"CONFIG": "readonly",
"NodeJS": "readonly"
"NodeJS": "readonly",
"globalThis": "readonly"
}
}
2 changes: 1 addition & 1 deletion config/nestr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"appNameCapitalized": "Nestr",
"hostname": "nestr.iris.to",
"nip05Domain": "iris.to",
"navLogo": "/img/icon128.png",
"icon": "/img/icon128.png",
"navLogo": "/nestr-logo-no-name.png",
"defaultTheme": "dark",
"navItems": [
"home",
Expand Down
50 changes: 32 additions & 18 deletions custom.d.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
/// <reference types="vite/client" />

declare const CONFIG: {
appName: string
appNameCapitalized: string
appTitle: string
hostname: string
nip05Domain: string
icon: string
navLogo: string
defaultTheme: string
navItems: string[]
aboutText: string
repository: string
features: {
analytics: boolean
showSubscriptionSettings: boolean
// Add any custom type declarations here

// Nostr extension types
declare global {
interface Window {
nostr?: {
getPublicKey(): Promise<string>
signEvent(event: Record<string, unknown>): Promise<Record<string, unknown>>
nip04?: {
encrypt(pubkey: string, plaintext: string): Promise<string>
decrypt(pubkey: string, ciphertext: string): Promise<string>
}
nip44?: {
encrypt(pubkey: string, plaintext: string): Promise<string>
decrypt(pubkey: string, ciphertext: string): Promise<string>
}
}
}
defaultSettings: {
notificationServer: string
irisApiUrl: string
}

export {}

// Add missing module declarations
declare module "tseep" {
export class EventEmitter {
emit(event: string, ...args: unknown[]): boolean
on(event: string, listener: (...args: unknown[]) => void): this
off(event: string, listener: (...args: unknown[]) => void): this
}
}

declare const CONFIG: {
appName: string
[key: string]: unknown
}

interface Performance {
memory?: {
jsHeapSizeLimit: number
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"scripts": {
"dev": "vite",
"start": "vite",
"build": "tsx ./scripts/updateSocialGraph.ts && tsc && vite build --mode production",
"build:dev": "tsx ./scripts/updateSocialGraph.ts && tsc && vite build --mode development",
"build": "tsc && vite build --mode production",
"build:dev": "tsc && vite build --mode development",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --fix",
"preview": "vite preview",
"pretest": "npx playwright install --with-deps chromium",
Expand Down Expand Up @@ -58,9 +58,12 @@
"@emoji-mart/react": "^1.1.1",
"@getalby/bitcoin-connect-react": "^3.9.0",
"@noble/hashes": "^1.8.0",
"@nostr-dev-kit/ndk": "^2.14.32",
"@nostr-dev-kit/ndk-cache-dexie": "^2.6.33",
"@remixicon/react": "^4.6.0",
"add": "^2.0.6",
"applesauce-core": "^2.3.0",
"applesauce-react": "^2.1.0",
"applesauce-relay": "^2.3.0",
"applesauce-signers": "^2.0.0",
"blurhash": "^2.0.5",
"classnames": "^2.5.1",
"dexie": "^4.0.11",
Expand All @@ -83,7 +86,9 @@
"react-router": "^7.7.1",
"react-string-replace": "^1.1.1",
"react-swipeable": "^7.0.2",
"tseep": "^1.3.1",
"typescript-lru-cache": "^2.0.0",
"yarn": "^1.22.22",
"zustand": "^5.0.6"
},
"devDependencies": {
Expand Down
79 changes: 43 additions & 36 deletions src/debug/DebugApp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useEffect, useState, useRef} from "react"
import {DebugSession} from "./DebugSession"
import {NostrEvent} from "nostr-tools"

interface SystemInfo {
appVersion: string
Expand Down Expand Up @@ -112,60 +113,66 @@ const DebugApp = () => {
setSessionLink(linkWithKey)

// Subscribe to test value changes
const unsubscribeTest = debugSession.subscribe("testInput", (value) => {
const unsubscribeTest = debugSession.subscribe("testInput", (value: unknown) => {
if (typeof value === "string") {
setTestValue(value)
}
})

// Subscribe to subscriptions data
const unsubscribeSubscriptions = debugSession.subscribe("subscriptions", (value) => {
setSubscriptions(value as Record<string, SubscriptionData>)
})

// Subscribe to heartbeat data to check if Iris browser is online
const unsubscribeData = debugSession.subscribe("data", (value, event) => {
const eventTime = event.created_at // Event timestamp in seconds
if (eventTime) {
lastHeartbeatTime.current = eventTime // Store in seconds
const now = Math.floor(Date.now() / 1000) // Current time in seconds
const isRecent = now - eventTime < 10 // Less than 10 seconds old
setIsBrowserOnline(isRecent)
const unsubscribeSubscriptions = debugSession.subscribe(
"subscriptions",
(value: unknown) => {
setSubscriptions(value as Record<string, SubscriptionData>)
}
)

// Extract system info from heartbeat
const data = value as {
systemInfo?: SystemInfo
ndkInfo?: NdkInfo
userAgent?: string
url?: string
}
if (data && data.systemInfo) {
setSystemInfo(data.systemInfo)
}
if (data && data.ndkInfo) {
setNdkInfo(data.ndkInfo)
}
if (data && data.userAgent) {
setUserAgent(data.userAgent)
}
if (data && data.url) {
setCurrentUrl(data.url)
// Subscribe to heartbeat data to check if Iris browser is online
const unsubscribeData = debugSession.subscribe(
"data",
(value: unknown, event: NostrEvent | undefined) => {
const eventTime = event?.created_at // Event timestamp in seconds
if (eventTime) {
lastHeartbeatTime.current = eventTime // Store in seconds
const now = Math.floor(Date.now() / 1000) // Current time in seconds
const isRecent = now - eventTime < 10 // Less than 10 seconds old
setIsBrowserOnline(isRecent)
}

// Extract system info from heartbeat
const data = value as {
systemInfo?: SystemInfo
ndkInfo?: NdkInfo
userAgent?: string
url?: string
}
if (data && data.systemInfo) {
setSystemInfo(data.systemInfo)
}
if (data && data.ndkInfo) {
setNdkInfo(data.ndkInfo)
}
if (data && data.userAgent) {
setUserAgent(data.userAgent)
}
if (data && data.url) {
setCurrentUrl(data.url)
}
}
})
)

// Subscribe to MediaFeed debug data
const unsubscribeMediaFeedDebug = debugSession.subscribe(
"mediaFeed_debug",
(value) => {
(value: unknown) => {
setMediaFeedDebug(value as MediaFeedDebug)
}
)

// Subscribe to MediaFeed performance data
const unsubscribeMediaFeedPerformance = debugSession.subscribe(
"mediaFeed_performance",
(value) => {
(value: unknown) => {
setMediaFeedPerformance((prev) => {
const newEntry = value as MediaFeedPerformance
// Keep only last 20 performance entries to avoid memory buildup
Expand All @@ -178,7 +185,7 @@ const DebugApp = () => {
// Subscribe to MediaFeed memory data
const unsubscribeMediaFeedMemory = debugSession.subscribe(
"mediaFeed_memory",
(value) => {
(value: unknown) => {
setMediaFeedMemory((prev) => {
const newEntry = value as MediaFeedMemory
// Keep only last 20 memory entries to avoid memory buildup
Expand All @@ -190,7 +197,7 @@ const DebugApp = () => {

// Monitor connection status periodically
const checkConnection = () => {
setIsConnected(debugSession.isConnectedToRelay(TEMP_IRIS_RELAY))
setIsConnected(debugSession.isConnectedToRelay())
}

// Check heartbeat freshness periodically
Expand Down
Loading
Loading