Compare commits

..
55 changed files with 1231 additions and 1081 deletions

No files matched your search

+1 -1
View File
@@ -284,7 +284,7 @@ export function useNewProviderOAuth() {
redirectUri: window.location.origin + '/oauth/newprovider', redirectUri: window.location.origin + '/oauth/newprovider',
usePKCE: false, // Set to true if provider supports PKCE usePKCE: false, // Set to true if provider supports PKCE
getUserInfo: async (accessToken: string, corsProxy: string) => { getUserInfo: async (accessToken: string, corsProxy: string) => {
const userUrl = proxyUrl(corsProxy, 'https://api.provider.com/user'); const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.provider.com/user' });
const userResponse = await fetch(userUrl, { const userResponse = await fetch(userUrl, {
headers: { headers: {
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,
+9
View File
@@ -0,0 +1,9 @@
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"nostr": {
"type": "local",
"command": ["npx", "-y", "@nostrbook/mcp@latest"]
}
}
}
+354 -54
View File
@@ -20,6 +20,7 @@
"@mozilla/readability": "^0.6.0", "@mozilla/readability": "^0.6.0",
"@nostrify/nostrify": "^0.48.2", "@nostrify/nostrify": "^0.48.2",
"@nostrify/react": "^0.2.20", "@nostrify/react": "^0.2.20",
"@opensecret/react": "^1.5.4",
"@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-aspect-ratio": "^1.1.0", "@radix-ui/react-aspect-ratio": "^1.1.0",
@@ -195,7 +196,6 @@
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.27.1", "@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.5", "@babel/generator": "^7.28.5",
@@ -1831,7 +1831,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=18" "node": ">=18"
}, },
@@ -1855,7 +1854,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=18" "node": ">=18"
} }
@@ -1877,7 +1875,6 @@
"resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz", "resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz",
"integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==", "integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@dnd-kit/accessibility": "^3.1.1", "@dnd-kit/accessibility": "^3.1.1",
"@dnd-kit/utilities": "^3.2.2", "@dnd-kit/utilities": "^3.2.2",
@@ -2816,9 +2813,9 @@
"license": "BSD-2-Clause" "license": "BSD-2-Clause"
}, },
"node_modules/@modelcontextprotocol/sdk": { "node_modules/@modelcontextprotocol/sdk": {
"version": "1.25.1", "version": "1.25.2",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.25.1.tgz", "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.25.2.tgz",
"integrity": "sha512-yO28oVFFC7EBoiKdAn+VqRm+plcfv4v0xp6osG/VsCB0NlPZWi87ajbCZZ8f/RvOFLEu7//rSRmuZZ7lMoe3gQ==", "integrity": "sha512-LZFeo4F9M5qOhC/Uc1aQSrBHxMrvxett+9KLHt7OhcExtoiRN9DKgbZffMP/nxjutWDQpfMDfP3nkHI4X9ijww==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@hono/node-server": "^1.19.7", "@hono/node-server": "^1.19.7",
@@ -3024,6 +3021,173 @@
"resolved": "https://registry.npmjs.org/@nostrify/types/-/types-0.36.8.tgz", "resolved": "https://registry.npmjs.org/@nostrify/types/-/types-0.36.8.tgz",
"integrity": "sha512-tmpz5pkU8oXu7+V1qxvAzuoo8s5x4Gvo7h+JRm+JAW6x/2VZ8aQoA54yhn89qZ9agciMJhVdhqCm1PlK55w17A==" "integrity": "sha512-tmpz5pkU8oXu7+V1qxvAzuoo8s5x4Gvo7h+JRm+JAW6x/2VZ8aQoA54yhn89qZ9agciMJhVdhqCm1PlK55w17A=="
}, },
"node_modules/@opensecret/react": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/@opensecret/react/-/react-1.5.4.tgz",
"integrity": "sha512-nIrb1NfKIJ1G8IK+b8OnjXvPgc/C3GkLVbZVF9HCh6WBDV2yimg8B7Eo6Pqu5mUtiFrQslFL9UbeDj4Py0mbGA==",
"license": "MIT",
"dependencies": {
"@peculiar/x509": "^1.12.2",
"@stablelib/base64": "^2.0.0",
"@stablelib/chacha20poly1305": "^2.0.0",
"@stablelib/random": "^2.0.0",
"cbor2": "^1.7.0",
"tweetnacl": "^1.0.3",
"zod": "^3.23.8"
},
"peerDependencies": {
"react": "^18.0.0 || ^19.0.0",
"react-dom": "^18.0.0 || ^19.0.0"
}
},
"node_modules/@peculiar/asn1-cms": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.6.0.tgz",
"integrity": "sha512-2uZqP+ggSncESeUF/9Su8rWqGclEfEiz1SyU02WX5fUONFfkjzS2Z/F1Li0ofSmf4JqYXIOdCAZqIXAIBAT1OA==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"@peculiar/asn1-x509-attr": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-csr": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.6.0.tgz",
"integrity": "sha512-BeWIu5VpTIhfRysfEp73SGbwjjoLL/JWXhJ/9mo4vXnz3tRGm+NGm3KNcRzQ9VMVqwYS2RHlolz21svzRXIHPQ==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-ecc": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.6.0.tgz",
"integrity": "sha512-FF3LMGq6SfAOwUG2sKpPXblibn6XnEIKa+SryvUl5Pik+WR9rmRA3OCiwz8R3lVXnYnyRkSZsSLdml8H3UiOcw==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-pfx": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.6.0.tgz",
"integrity": "sha512-rtUvtf+tyKGgokHHmZzeUojRZJYPxoD/jaN1+VAB4kKR7tXrnDCA/RAWXAIhMJJC+7W27IIRGe9djvxKgsldCQ==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-cms": "^2.6.0",
"@peculiar/asn1-pkcs8": "^2.6.0",
"@peculiar/asn1-rsa": "^2.6.0",
"@peculiar/asn1-schema": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-pkcs8": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.6.0.tgz",
"integrity": "sha512-KyQ4D8G/NrS7Fw3XCJrngxmjwO/3htnA0lL9gDICvEQ+GJ+EPFqldcJQTwPIdvx98Tua+WjkdKHSC0/Km7T+lA==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-pkcs9": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.6.0.tgz",
"integrity": "sha512-b78OQ6OciW0aqZxdzliXGYHASeCvvw5caqidbpQRYW2mBtXIX2WhofNXTEe7NyxTb0P6J62kAAWLwn0HuMF1Fw==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-cms": "^2.6.0",
"@peculiar/asn1-pfx": "^2.6.0",
"@peculiar/asn1-pkcs8": "^2.6.0",
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"@peculiar/asn1-x509-attr": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-rsa": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.6.0.tgz",
"integrity": "sha512-Nu4C19tsrTsCp9fDrH+sdcOKoVfdfoQQ7S3VqjJU6vedR7tY3RLkQ5oguOIB3zFW33USDUuYZnPEQYySlgha4w==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-schema": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.6.0.tgz",
"integrity": "sha512-xNLYLBFTBKkCzEZIw842BxytQQATQv+lDTCEMZ8C196iJcJJMBUZxrhSTxLaohMyKK8QlzRNTRkUmanucnDSqg==",
"license": "MIT",
"dependencies": {
"asn1js": "^3.0.6",
"pvtsutils": "^1.3.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-x509": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.6.0.tgz",
"integrity": "sha512-uzYbPEpoQiBoTq0/+jZtpM6Gq6zADBx+JNFP3yqRgziWBxQ/Dt/HcuvRfm9zJTPdRcBqPNdaRHTVwpyiq6iNMA==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"asn1js": "^3.0.6",
"pvtsutils": "^1.3.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/asn1-x509-attr": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.6.0.tgz",
"integrity": "sha512-MuIAXFX3/dc8gmoZBkwJWxUWOSvG4MMDntXhrOZpJVMkYX+MYc/rUAU2uJOved9iJEoiUx7//3D8oG83a78UJA==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"asn1js": "^3.0.6",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/x509": {
"version": "1.14.3",
"resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-1.14.3.tgz",
"integrity": "sha512-C2Xj8FZ0uHWeCXXqX5B4/gVFQmtSkiuOolzAgutjTfseNOHT3pUjljDZsTSxXFGgio54bCzVFqmEOUrIVk8RDA==",
"license": "MIT",
"dependencies": {
"@peculiar/asn1-cms": "^2.6.0",
"@peculiar/asn1-csr": "^2.6.0",
"@peculiar/asn1-ecc": "^2.6.0",
"@peculiar/asn1-pkcs9": "^2.6.0",
"@peculiar/asn1-rsa": "^2.6.0",
"@peculiar/asn1-schema": "^2.6.0",
"@peculiar/asn1-x509": "^2.6.0",
"pvtsutils": "^1.3.6",
"reflect-metadata": "^0.2.2",
"tslib": "^2.8.1",
"tsyringe": "^4.10.0"
},
"engines": {
"node": ">=20.0.0"
}
},
"node_modules/@pkgjs/parseargs": { "node_modules/@pkgjs/parseargs": {
"version": "0.11.0", "version": "0.11.0",
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
@@ -4389,9 +4553,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@remix-run/router": { "node_modules/@remix-run/router": {
"version": "1.23.0", "version": "1.23.2",
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.0.tgz", "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.2.tgz",
"integrity": "sha512-O3rHJzAQKamUz1fvE0Qaw0xSFqsA/yafi2iqeE0pvdFtCO1viYx8QL6f3Ln/aCCTLxs68SLf0KPM9eSeM8yBnA==", "integrity": "sha512-Ic6m2U/rMjTkhERIa/0ZtXJP17QUi2CbWE7cqx4J58M8aA3QTfW+2UlQ4psvTX9IO1RfNVhK3pcpdjej7L+t2w==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"
@@ -5039,6 +5203,89 @@
"node": ">=18.0.0" "node": ">=18.0.0"
} }
}, },
"node_modules/@stablelib/aead": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@stablelib/aead/-/aead-2.0.0.tgz",
"integrity": "sha512-U/RMANRxbT/ahIpYsPSiFwDFNjADHdnCFfmo09MO1ai2XmerPAOPtMl0qmX7XVvygnACC6ijKDyHBoT2rGyElg==",
"license": "MIT"
},
"node_modules/@stablelib/base64": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-2.0.1.tgz",
"integrity": "sha512-P2z89A7N1ETt6RxgpVdDT2xlg8cnm3n6td0lY9gyK7EiWK3wdq388yFX/hLknkCC0we05OZAD1rfxlQJUbl5VQ==",
"license": "MIT"
},
"node_modules/@stablelib/binary": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-2.0.1.tgz",
"integrity": "sha512-U9iAO8lXgEDONsA0zPPSgcf3HUBNAqHiJmSHgZz62OvC3Hi2Bhc5kTnQ3S1/L+sthDTHtCMhcEiklmIly6uQ3w==",
"license": "MIT",
"dependencies": {
"@stablelib/int": "^2.0.1"
}
},
"node_modules/@stablelib/chacha": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/chacha/-/chacha-2.0.1.tgz",
"integrity": "sha512-lS1FqtNqofxe2vLkRsLli2m3x/XanUyAYRphLhdHumKeIsLbjbCXdCq3Pf/eWiO7G3QlSG5ViqnoVjktzfLWMg==",
"license": "MIT",
"dependencies": {
"@stablelib/binary": "^2.0.1",
"@stablelib/wipe": "^2.0.1"
}
},
"node_modules/@stablelib/chacha20poly1305": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/chacha20poly1305/-/chacha20poly1305-2.0.1.tgz",
"integrity": "sha512-kOoBsXbDPVRlelzXl+5WViycgM19lD7lF3Bc3KWI+DzId0Stc2HlxAfSc+Xpn3RgqSCl1ZNTXr33LegqBhBBaw==",
"license": "MIT",
"dependencies": {
"@stablelib/aead": "^2.0.0",
"@stablelib/binary": "^2.0.1",
"@stablelib/chacha": "^2.0.1",
"@stablelib/constant-time": "^2.0.1",
"@stablelib/poly1305": "^2.0.1",
"@stablelib/wipe": "^2.0.1"
}
},
"node_modules/@stablelib/constant-time": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/constant-time/-/constant-time-2.0.1.tgz",
"integrity": "sha512-0NWPogffRm+UWBH0+iM5otZmNrVe5OHFIvyoNIVankMAYOQzMwcdVALOVPrB5Ho0dST+Oc3H8/hPh65Z8R/uew==",
"license": "MIT"
},
"node_modules/@stablelib/int": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/int/-/int-2.0.1.tgz",
"integrity": "sha512-Ht63fQp3wz/F8U4AlXEPb7hfJOIILs8Lq55jgtD7KueWtyjhVuzcsGLSTAWtZs3XJDZYdF1WcSKn+kBtbzupww==",
"license": "MIT"
},
"node_modules/@stablelib/poly1305": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/poly1305/-/poly1305-2.0.1.tgz",
"integrity": "sha512-D8xfZcL/5zeVARJ9I2fZOUCnZvsJx8G4JDQvD+ecsnaCildPtqZDwqqjtOc4cfHAdScrMjOzUVsssjXUTBw3YQ==",
"license": "MIT",
"dependencies": {
"@stablelib/constant-time": "^2.0.1",
"@stablelib/wipe": "^2.0.1"
}
},
"node_modules/@stablelib/random": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/random/-/random-2.0.1.tgz",
"integrity": "sha512-W6GAtXEEs7r+dSbuBsvoFmlyL3gLxle41tQkjKu17dDWtDdjhVUbtRfRCQcCUeczwkgjQxMPopgwYEvxXtHXGw==",
"license": "MIT",
"dependencies": {
"@stablelib/binary": "^2.0.1",
"@stablelib/wipe": "^2.0.1"
}
},
"node_modules/@stablelib/wipe": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-2.0.1.tgz",
"integrity": "sha512-1eU2K9EgOcV4qc9jcP6G72xxZxEm5PfeI5H55l08W95b4oRJaqhmlWRc4xZAm6IVSKhVNxMi66V67hCzzuMTAg==",
"license": "MIT"
},
"node_modules/@std/encoding": { "node_modules/@std/encoding": {
"name": "@jsr/std__encoding", "name": "@jsr/std__encoding",
"version": "1.0.10", "version": "1.0.10",
@@ -5446,7 +5693,8 @@
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
"integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT",
"peer": true
}, },
"node_modules/@types/chrome": { "node_modules/@types/chrome": {
"version": "0.0.74", "version": "0.0.74",
@@ -5658,7 +5906,6 @@
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.20.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.20.tgz",
"integrity": "sha512-IPaCZN7PShZK/3t6Q87pfTkRm6oLTd4vztyoj+cbHUF1g3FfVb2tFIL79uCRKEfv16AhqDMBywP2VW3KIZUvcg==", "integrity": "sha512-IPaCZN7PShZK/3t6Q87pfTkRm6oLTd4vztyoj+cbHUF1g3FfVb2tFIL79uCRKEfv16AhqDMBywP2VW3KIZUvcg==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/prop-types": "*", "@types/prop-types": "*",
"csstype": "^3.0.2" "csstype": "^3.0.2"
@@ -5670,7 +5917,6 @@
"integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==", "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"peerDependencies": { "peerDependencies": {
"@types/react": "^18.0.0" "@types/react": "^18.0.0"
} }
@@ -5754,7 +6000,6 @@
"integrity": "sha512-oU/OtYVydhXnumd0BobL9rkJg7wFJ9bFFPmSmB/bf/XWN85hlViji59ko6bSKBXyseT9V8l+CN1nwmlbiN0G7Q==", "integrity": "sha512-oU/OtYVydhXnumd0BobL9rkJg7wFJ9bFFPmSmB/bf/XWN85hlViji59ko6bSKBXyseT9V8l+CN1nwmlbiN0G7Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "8.31.1", "@typescript-eslint/scope-manager": "8.31.1",
"@typescript-eslint/types": "8.31.1", "@typescript-eslint/types": "8.31.1",
@@ -6114,7 +6359,6 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
}, },
@@ -6324,6 +6568,20 @@
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/asn1js": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.7.tgz",
"integrity": "sha512-uLvq6KJu04qoQM6gvBfKFjlh6Gl0vOKQuR5cJMDHQkmwfMOQeN3F3SHCv9SNYSL+CRoHvOGFfllDlVz03GQjvQ==",
"license": "BSD-3-Clause",
"dependencies": {
"pvtsutils": "^1.3.6",
"pvutils": "^1.1.3",
"tslib": "^2.8.1"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/assertion-error": { "node_modules/assertion-error": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
@@ -6629,7 +6887,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"baseline-browser-mapping": "^2.8.19", "baseline-browser-mapping": "^2.8.19",
"caniuse-lite": "^1.0.30001751", "caniuse-lite": "^1.0.30001751",
@@ -6790,6 +7047,15 @@
], ],
"license": "CC-BY-4.0" "license": "CC-BY-4.0"
}, },
"node_modules/cbor2": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/cbor2/-/cbor2-1.12.0.tgz",
"integrity": "sha512-3Cco8XQhi27DogSp9Ri6LYNZLi/TBY/JVnDe+mj06NkBjW/ZYOtekaEU4wZ4xcRMNrFkDv8KNtOAqHyDfz3lYg==",
"license": "MIT",
"engines": {
"node": ">=18.7"
}
},
"node_modules/ccount": { "node_modules/ccount": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
@@ -6859,7 +7125,6 @@
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"anymatch": "~3.1.2", "anymatch": "~3.1.2",
"braces": "~3.0.2", "braces": "~3.0.2",
@@ -7619,7 +7884,8 @@
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
"integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT",
"peer": true
}, },
"node_modules/dom-helpers": { "node_modules/dom-helpers": {
"version": "5.2.1", "version": "5.2.1",
@@ -7684,8 +7950,7 @@
"version": "8.6.0", "version": "8.6.0",
"resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.6.0.tgz", "resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.6.0.tgz",
"integrity": "sha512-SjWyZBHJPbqxHOzckOfo8lHisEaJWmwd23XppYFYVh10bU66/Pn5tkVkbkCMZVdbUE5eTCI2nD8OyIP4Z+uwkA==", "integrity": "sha512-SjWyZBHJPbqxHOzckOfo8lHisEaJWmwd23XppYFYVh10bU66/Pn5tkVkbkCMZVdbUE5eTCI2nD8OyIP4Z+uwkA==",
"license": "MIT", "license": "MIT"
"peer": true
}, },
"node_modules/embla-carousel-react": { "node_modules/embla-carousel-react": {
"version": "8.6.0", "version": "8.6.0",
@@ -7971,7 +8236,6 @@
"integrity": "sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==", "integrity": "sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.12.1", "@eslint-community/regexpp": "^4.12.1",
@@ -8237,7 +8501,6 @@
"resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz",
"integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"accepts": "^2.0.0", "accepts": "^2.0.0",
"body-parser": "^2.2.0", "body-parser": "^2.2.0",
@@ -9211,9 +9474,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/hono": { "node_modules/hono": {
"version": "4.11.1", "version": "4.11.4",
"resolved": "https://registry.npmjs.org/hono/-/hono-4.11.1.tgz", "resolved": "https://registry.npmjs.org/hono/-/hono-4.11.4.tgz",
"integrity": "sha512-KsFcH0xxHes0J4zaQgWbYwmz3UPOOskdqZmItstUG93+Wk1ePBLkLGwbP9zlmh1BFUiL8Qp+Xfu9P7feJWpGNg==", "integrity": "sha512-U7tt8JsyrxSRKspfhtLET79pU8K+tInj5QZXs1jSugO1Vq5dFj3kmZsRldo29mTBfcjDRVRXrEZ6LS63Cog9ZA==",
"license": "MIT", "license": "MIT",
"peer": true, "peer": true,
"engines": { "engines": {
@@ -9335,7 +9598,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@babel/runtime": "^7.27.6" "@babel/runtime": "^7.27.6"
}, },
@@ -10129,7 +10391,6 @@
"integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==", "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"cssstyle": "^4.2.1", "cssstyle": "^4.2.1",
"data-urls": "^5.0.0", "data-urls": "^5.0.0",
@@ -10514,6 +10775,7 @@
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"lz-string": "bin/bin.js" "lz-string": "bin/bin.js"
} }
@@ -12267,7 +12529,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"nanoid": "^3.3.8", "nanoid": "^3.3.8",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
@@ -12435,6 +12696,7 @@
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"ansi-regex": "^5.0.1", "ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0", "ansi-styles": "^5.0.0",
@@ -12450,6 +12712,7 @@
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=8" "node": ">=8"
} }
@@ -12460,6 +12723,7 @@
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=10" "node": ">=10"
}, },
@@ -12472,7 +12736,8 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT",
"peer": true
}, },
"node_modules/prismjs": { "node_modules/prismjs": {
"version": "1.30.0", "version": "1.30.0",
@@ -12539,6 +12804,24 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/pvtsutils": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz",
"integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==",
"license": "MIT",
"dependencies": {
"tslib": "^2.8.1"
}
},
"node_modules/pvutils": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.5.tgz",
"integrity": "sha512-KTqnxsgGiQ6ZAzZCVlJH5eOjSnvlyEgx1m8bkRJfOhmGRqfo5KLvmAlACQkrjEtOQ4B7wF9TdSLIs9O90MX9xA==",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/qrcode": { "node_modules/qrcode": {
"version": "1.5.4", "version": "1.5.4",
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
@@ -12557,9 +12840,9 @@
} }
}, },
"node_modules/qs": { "node_modules/qs": {
"version": "6.14.0", "version": "6.14.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"side-channel": "^1.1.0" "side-channel": "^1.1.0"
@@ -12646,7 +12929,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0" "loose-envify": "^1.1.0"
}, },
@@ -12673,7 +12955,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"scheduler": "^0.23.2" "scheduler": "^0.23.2"
@@ -12699,7 +12980,6 @@
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.1.tgz", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.1.tgz",
"integrity": "sha512-qWAVokhSpshhcEuQDSANHx3jiAEFzu2HAaaQIzi/r9FNPm1ioAvuJSD4EuZzWd7Al7nTRKcKPnBKO7sRn+zavQ==", "integrity": "sha512-qWAVokhSpshhcEuQDSANHx3jiAEFzu2HAaaQIzi/r9FNPm1ioAvuJSD4EuZzWd7Al7nTRKcKPnBKO7sRn+zavQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"
}, },
@@ -12748,7 +13028,6 @@
"resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz", "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz",
"integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==", "integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/hast": "^3.0.0", "@types/hast": "^3.0.0",
"@types/mdast": "^4.0.0", "@types/mdast": "^4.0.0",
@@ -12829,12 +13108,12 @@
} }
}, },
"node_modules/react-router": { "node_modules/react-router": {
"version": "6.30.0", "version": "6.30.3",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.0.tgz", "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.3.tgz",
"integrity": "sha512-D3X8FyH9nBcTSHGdEKurK7r8OYE1kKFn3d/CF+CoxbSHkxU7o37+Uh7eAHRXr6k2tSExXYO++07PeXJtA/dEhQ==", "integrity": "sha512-XRnlbKMTmktBkjCLE8/XcZFlnHvr2Ltdr1eJX4idL55/9BbORzyZEaIkBFDhFGCEWBBItsVrDxwx3gnisMitdw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@remix-run/router": "1.23.0" "@remix-run/router": "1.23.2"
}, },
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"
@@ -12844,13 +13123,13 @@
} }
}, },
"node_modules/react-router-dom": { "node_modules/react-router-dom": {
"version": "6.30.0", "version": "6.30.3",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.0.tgz", "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.3.tgz",
"integrity": "sha512-x30B78HV5tFk8ex0ITwzC9TTZMua4jGyA9IUlH1JLQYQTFyxr/ZxwOJq7evg1JX1qGVUcvhsmQSKdPncQrjTgA==", "integrity": "sha512-pxPcv1AczD4vso7G4Z3TKcvlxK7g7TNt3/FNGMhfqyntocvYKj+GCatfigGDjbLozC4baguJ0ReCigoDJXb0ag==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@remix-run/router": "1.23.0", "@remix-run/router": "1.23.2",
"react-router": "6.30.0" "react-router": "6.30.3"
}, },
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"
@@ -12994,6 +13273,12 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/reflect-metadata": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz",
"integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==",
"license": "Apache-2.0"
},
"node_modules/reflect.getprototypeof": { "node_modules/reflect.getprototypeof": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
@@ -13291,7 +13576,6 @@
"integrity": "sha512-C5VvvgCCyfyotVITIAv+4efVytl5F7wt+/I2i9q9GZcEXW9BP52YYOXC58igUi+LFZVHukErIIqQSWwv/M3WRw==", "integrity": "sha512-C5VvvgCCyfyotVITIAv+4efVytl5F7wt+/I2i9q9GZcEXW9BP52YYOXC58igUi+LFZVHukErIIqQSWwv/M3WRw==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/estree": "1.0.7" "@types/estree": "1.0.7"
}, },
@@ -14346,7 +14630,6 @@
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.17.tgz", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.17.tgz",
"integrity": "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==", "integrity": "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@alloc/quick-lru": "^5.2.0", "@alloc/quick-lru": "^5.2.0",
"arg": "^5.0.2", "arg": "^5.0.2",
@@ -14550,7 +14833,6 @@
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@@ -14714,6 +14996,24 @@
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD" "license": "0BSD"
}, },
"node_modules/tsyringe": {
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.10.0.tgz",
"integrity": "sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==",
"license": "MIT",
"dependencies": {
"tslib": "^1.9.3"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/tsyringe/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"license": "0BSD"
},
"node_modules/turndown": { "node_modules/turndown": {
"version": "7.2.1", "version": "7.2.1",
"resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.1.tgz", "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.1.tgz",
@@ -14723,6 +15023,12 @@
"@mixmark-io/domino": "^2.2.0" "@mixmark-io/domino": "^2.2.0"
} }
}, },
"node_modules/tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",
"license": "Unlicense"
},
"node_modules/type-check": { "node_modules/type-check": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -14846,7 +15152,6 @@
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"devOptional": true, "devOptional": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@@ -15374,7 +15679,6 @@
"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==", "integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.25.0", "esbuild": "^0.25.0",
"fdir": "^6.4.4", "fdir": "^6.4.4",
@@ -15519,7 +15823,6 @@
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@@ -15991,7 +16294,6 @@
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1", "fast-uri": "^3.0.1",
@@ -16068,7 +16370,6 @@
"integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"rollup": "dist/bin/rollup" "rollup": "dist/bin/rollup"
}, },
@@ -16517,7 +16818,6 @@
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"funding": { "funding": {
"url": "https://github.com/sponsors/colinhacks" "url": "https://github.com/sponsors/colinhacks"
} }
+1
View File
@@ -31,6 +31,7 @@
"@mozilla/readability": "^0.6.0", "@mozilla/readability": "^0.6.0",
"@nostrify/nostrify": "^0.48.2", "@nostrify/nostrify": "^0.48.2",
"@nostrify/react": "^0.2.20", "@nostrify/react": "^0.2.20",
"@opensecret/react": "^1.5.4",
"@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-aspect-ratio": "^1.1.0", "@radix-ui/react-aspect-ratio": "^1.1.0",
Binary file not shown.
-2
View File
@@ -28,7 +28,6 @@ import { DynamicFavicon } from '@/components/DynamicFavicon';
import { OfflineIndicator } from '@/components/OfflineIndicator'; import { OfflineIndicator } from '@/components/OfflineIndicator';
import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt'; import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt';
import { ErrorBoundary } from '@/components/ErrorBoundary'; import { ErrorBoundary } from '@/components/ErrorBoundary';
import { BadgeAwardNotification } from '@/components/BadgeAwardNotification';
import AppRouter from './AppRouter'; import AppRouter from './AppRouter';
@@ -153,7 +152,6 @@ export function App() {
<DynamicFavicon /> <DynamicFavicon />
<OfflineIndicator /> <OfflineIndicator />
<PWAUpdatePrompt /> <PWAUpdatePrompt />
<BadgeAwardNotification />
<Suspense> <Suspense>
<AppRouter /> <AppRouter />
</Suspense> </Suspense>
-2
View File
@@ -14,7 +14,6 @@ import DeploySettings from "./pages/DeploySettings";
import SystemSettings from "./pages/SystemSettings"; import SystemSettings from "./pages/SystemSettings";
import StorageSettings from "./pages/StorageSettings"; import StorageSettings from "./pages/StorageSettings";
import AboutSettings from "./pages/AboutSettings"; import AboutSettings from "./pages/AboutSettings";
import BadgesSettings from "./pages/BadgesSettings";
import GitHubOAuth from "./pages/GitHubOAuth"; import GitHubOAuth from "./pages/GitHubOAuth";
import NetlifyOAuth from "./pages/NetlifyOAuth"; import NetlifyOAuth from "./pages/NetlifyOAuth";
@@ -52,7 +51,6 @@ export function AppRouter() {
<Route path="system" element={<SystemSettings />} /> <Route path="system" element={<SystemSettings />} />
<Route path="storage" element={<StorageSettings />} /> <Route path="storage" element={<StorageSettings />} />
<Route path="about" element={<AboutSettings />} /> <Route path="about" element={<AboutSettings />} />
<Route path="badges" element={<BadgesSettings />} />
</Route> </Route>
<Route path="/project/:projectId" element={<ProjectView />} /> <Route path="/project/:projectId" element={<ProjectView />} />
{/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */} {/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */}
+40 -6
View File
@@ -1041,12 +1041,31 @@ export function AIProviderConfigDialog({
<div className="grid gap-2"> <div className="grid gap-2">
<Label htmlFor="provider-auth">{t('authentication')}</Label> <Label htmlFor="provider-auth">{t('authentication')}</Label>
<Select <Select
value={localProvider.nostr ? 'nostr' : 'api-key'} value={localProvider.nostr ? 'nostr' : localProvider.openSecret ? 'opensecret' : 'api-key'}
onValueChange={(value: 'api-key' | 'nostr') => setLocalProvider({ onValueChange={(value: 'api-key' | 'nostr' | 'opensecret') => {
...localProvider, if (value === 'nostr') {
nostr: value === 'nostr' || undefined, setLocalProvider({
apiKey: value === 'nostr' ? undefined : localProvider.apiKey ...localProvider,
})} nostr: true,
openSecret: undefined,
apiKey: undefined
});
} else if (value === 'opensecret') {
setLocalProvider({
...localProvider,
nostr: undefined,
openSecret: localProvider.openSecret,
apiKey: localProvider.apiKey
});
} else {
setLocalProvider({
...localProvider,
nostr: undefined,
openSecret: undefined,
apiKey: localProvider.apiKey
});
}
}}
> >
<SelectTrigger> <SelectTrigger>
<SelectValue /> <SelectValue />
@@ -1054,10 +1073,25 @@ export function AIProviderConfigDialog({
<SelectContent> <SelectContent>
<SelectItem value="api-key">{t('apiKey')}</SelectItem> <SelectItem value="api-key">{t('apiKey')}</SelectItem>
<SelectItem value="nostr">Nostr</SelectItem> <SelectItem value="nostr">Nostr</SelectItem>
<SelectItem value="opensecret">OpenSecret</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
{localProvider.openSecret && (
<div className="grid gap-2">
<Label htmlFor="provider-opensecret-url">
OpenSecret API URL <span className="text-destructive">*</span>
</Label>
<Input
id="provider-opensecret-url"
placeholder="https://enclave.trymaple.ai"
value={localProvider.openSecret || ''}
onChange={(e) => setLocalProvider({ ...localProvider, openSecret: e.target.value })}
/>
</div>
)}
{!localProvider.nostr && ( {!localProvider.nostr && (
<div className="grid gap-2"> <div className="grid gap-2">
<Label htmlFor="provider-apiKey">{t('apiKey')}</Label> <Label htmlFor="provider-apiKey">{t('apiKey')}</Label>
+26 -3
View File
@@ -50,7 +50,8 @@ export function AddCustomAIProviderDialog({
const [customIdManuallyEdited, setCustomIdManuallyEdited] = useState(false); const [customIdManuallyEdited, setCustomIdManuallyEdited] = useState(false);
const [customBaseURL, setCustomBaseURL] = useState(''); const [customBaseURL, setCustomBaseURL] = useState('');
const [customApiKey, setCustomApiKey] = useState(''); const [customApiKey, setCustomApiKey] = useState('');
const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr'>('api-key'); const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr' | 'opensecret'>('api-key');
const [customOpenSecretUrl, setCustomOpenSecretUrl] = useState('');
const [customProxy, setCustomProxy] = useState(false); const [customProxy, setCustomProxy] = useState(false);
const handleAdd = () => { const handleAdd = () => {
@@ -66,6 +67,11 @@ export function AddCustomAIProviderDialog({
provider.apiKey = customApiKey.trim(); provider.apiKey = customApiKey.trim();
} else if (customAuthMethod === 'nostr') { } else if (customAuthMethod === 'nostr') {
provider.nostr = true; provider.nostr = true;
} else if (customAuthMethod === 'opensecret') {
provider.openSecret = customOpenSecretUrl.trim();
if (customApiKey.trim()) {
provider.apiKey = customApiKey.trim();
}
} }
if (customProxy) { if (customProxy) {
@@ -81,6 +87,7 @@ export function AddCustomAIProviderDialog({
setCustomBaseURL(''); setCustomBaseURL('');
setCustomApiKey(''); setCustomApiKey('');
setCustomAuthMethod('api-key'); setCustomAuthMethod('api-key');
setCustomOpenSecretUrl('');
setCustomProxy(false); setCustomProxy(false);
onOpenChange(false); onOpenChange(false);
@@ -89,6 +96,7 @@ export function AddCustomAIProviderDialog({
const isValid = customProviderName.trim() && const isValid = customProviderName.trim() &&
customProviderId.trim() && customProviderId.trim() &&
customBaseURL.trim() && customBaseURL.trim() &&
(customAuthMethod !== 'opensecret' || customOpenSecretUrl.trim()) &&
!existingIds.includes(customProviderId.trim()); !existingIds.includes(customProviderId.trim());
const idExists = existingIds.includes(customProviderId.trim()); const idExists = existingIds.includes(customProviderId.trim());
@@ -156,7 +164,7 @@ export function AddCustomAIProviderDialog({
<Label htmlFor="custom-auth">{t('authentication')}</Label> <Label htmlFor="custom-auth">{t('authentication')}</Label>
<Select <Select
value={customAuthMethod} value={customAuthMethod}
onValueChange={(value: 'api-key' | 'nostr') => { onValueChange={(value: 'api-key' | 'nostr' | 'opensecret') => {
setCustomAuthMethod(value); setCustomAuthMethod(value);
if (value === 'nostr') { if (value === 'nostr') {
setCustomApiKey(''); // Clear API key when switching to Nostr auth setCustomApiKey(''); // Clear API key when switching to Nostr auth
@@ -169,11 +177,26 @@ export function AddCustomAIProviderDialog({
<SelectContent> <SelectContent>
<SelectItem value="api-key">{t('apiKey')}</SelectItem> <SelectItem value="api-key">{t('apiKey')}</SelectItem>
<SelectItem value="nostr">Nostr</SelectItem> <SelectItem value="nostr">Nostr</SelectItem>
<SelectItem value="opensecret">OpenSecret</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
{customAuthMethod === 'api-key' && ( {customAuthMethod === 'opensecret' && (
<div className="grid gap-2">
<Label htmlFor="custom-opensecret-url">
OpenSecret API URL <span className="text-destructive">*</span>
</Label>
<Input
id="custom-opensecret-url"
placeholder="https://enclave.trymaple.ai"
value={customOpenSecretUrl}
onChange={(e) => setCustomOpenSecretUrl(e.target.value)}
/>
</div>
)}
{(customAuthMethod === 'api-key' || customAuthMethod === 'opensecret') && (
<div className="grid gap-2"> <div className="grid gap-2">
<Label htmlFor="custom-apikey">{t('apiKey')}</Label> <Label htmlFor="custom-apikey">{t('apiKey')}</Label>
<PasswordInput <PasswordInput
-135
View File
@@ -1,135 +0,0 @@
import { useEffect, useRef } from 'react';
import { Dialog, DialogContent, DialogTitle, DialogDescription } from "@/components/ui/dialog";
import { Award } from "lucide-react";
import type { NostrEvent } from '@nostrify/nostrify';
import { useNostr } from '@nostrify/react';
import { useQuery } from '@tanstack/react-query';
import { Skeleton } from "@/components/ui/skeleton";
import { BADGE_ISSUER_PUBKEY } from '@/pages/BadgesSettings';
interface BadgeAwardModalProps {
award?: NostrEvent | null;
badgeDefinition?: NostrEvent | null;
onClose: () => void;
}
export function BadgeAwardModal({ award, badgeDefinition: providedBadgeDefinition, onClose }: BadgeAwardModalProps) {
const { nostr } = useNostr();
const audioRef = useRef<HTMLAudioElement | null>(null);
// If we have a badge definition directly, use it
// Otherwise, extract from award event
let dTag: string | undefined;
if (providedBadgeDefinition) {
dTag = providedBadgeDefinition.tags.find(([t]) => t === "d")?.[1];
} else if (award) {
const aTag = award.tags.find(([t]) => t === "a")?.[1];
if (aTag) {
const [kindStr, pubkey, parsedDTag] = aTag.split(':');
if (kindStr === '30009' && pubkey === BADGE_ISSUER_PUBKEY && parsedDTag) {
dTag = parsedDTag;
}
}
}
// Fetch badge definition if we don't have it directly
const { data: fetchedBadgeDefinition, isLoading } = useQuery({
queryKey: ['badge-definition', BADGE_ISSUER_PUBKEY, dTag],
queryFn: async (c) => {
if (!dTag) return null;
const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
const events = await nostr.query([{
kinds: [30009],
authors: [BADGE_ISSUER_PUBKEY],
"#d": [dTag],
limit: 1,
}], { signal });
return events[0] || null;
},
enabled: !!dTag && !providedBadgeDefinition,
});
const badgeDefinition = providedBadgeDefinition || fetchedBadgeDefinition;
const isModalOpen = !!award || !!providedBadgeDefinition;
// Play sound when badge is awarded (only when award is present, not just viewing badge definition)
useEffect(() => {
if (award && badgeDefinition && isModalOpen && !isLoading) {
// Create audio element if it doesn't exist
if (!audioRef.current) {
audioRef.current = new Audio('/badgeAwarded.mp3');
audioRef.current.volume = 0.5; // Set volume to 50%
}
// Reset to beginning and play the sound
audioRef.current.currentTime = 0;
audioRef.current.play().catch((error) => {
// Silently handle autoplay restrictions
console.debug('Audio playback failed:', error);
});
}
}, [award, badgeDefinition, isModalOpen, isLoading]);
// Return null after all hooks if we don't have a badge definition
if (!badgeDefinition) return null;
const nameTag = badgeDefinition?.tags?.find(([t]) => t === "name")?.[1];
const descriptionTag = badgeDefinition?.tags?.find(([t]) => t === "description")?.[1];
const imageTag = badgeDefinition?.tags?.find(([t]) => t === "image")?.[1];
const thumbTags = badgeDefinition?.tags?.filter(([t]) => t === "thumb") || [];
const badgeName = nameTag || dTag || "Unnamed Badge";
const description = descriptionTag || "";
const imageUrl = imageTag || (thumbTags.length > 0 ? thumbTags[thumbTags.length - 1]?.[1] : null);
return (
<Dialog open={isModalOpen} onOpenChange={(open) => !open && onClose()}>
<DialogContent className="w-[min(90vw,600px)] aspect-square bg-transparent [&>button]:hidden border-0 ring-0 outline-none shadow-none flex items-center justify-center p-[min(4vw,2rem)]">
<DialogTitle className="sr-only">
{award ? `Badge Awarded: ${badgeName}` : badgeName}
</DialogTitle>
<DialogDescription className="sr-only">
{description || `Badge: ${badgeName}`}
</DialogDescription>
<div className="flex flex-col items-center justify-center space-y-[min(4vw,2rem)] w-full h-full">
{isLoading ? (
<>
<Skeleton className="w-[min(60vw,384px)] aspect-square rounded-lg" />
<div className="space-y-2 text-center w-full">
<Skeleton className="h-[clamp(1.5rem,4vw,2rem)] w-[min(80%,16rem)] mx-auto" />
<Skeleton className="h-[clamp(1rem,3vw,1.25rem)] w-[min(90%,20rem)] mx-auto" />
</div>
</>
) : (
<>
{/* Badge image */}
<div className="relative aspect-square w-[min(60vw,384px)] before:absolute before:inset-0 before:rounded-lg before:bg-white/30 before:blur-2xl before:animate-pulse before:-z-10">
{imageUrl ? (
<img
src={imageUrl}
alt={badgeName}
className="h-full w-full rounded-lg object-cover shadow-2xl"
/>
) : (
<Award className="h-full w-full text-primary drop-shadow-lg" />
)}
</div>
{/* Title */}
<div className="text-center space-y-[min(1vw,0.75rem)] w-full px-4">
<p className="text-[clamp(1.25rem,5vw,1.5rem)] font-semibold">{badgeName}</p>
{description && (
<p className="text-[clamp(0.875rem,3vw,1rem)] text-muted-foreground max-w-md mx-auto">
{description}
</p>
)}
</div>
</>
)}
</div>
</DialogContent>
</Dialog>
);
}
-14
View File
@@ -1,14 +0,0 @@
import { useBadgeAwardNotifications } from '@/hooks/useBadgeAwardNotifications';
import { BadgeAwardModal } from './BadgeAwardModal';
/**
* Global badge award notification component.
* Listens for badge awards and displays a modal when a new badge is received.
* This component should be placed at the App level to work globally.
*/
export function BadgeAwardNotification() {
const { newAward, clearNewAward } = useBadgeAwardNotifications();
return <BadgeAwardModal award={newAward} onClose={clearNewAward} />;
}
+2 -2
View File
@@ -33,10 +33,10 @@ export function ExternalFavicon({
const parsedUrl = new URL(url); const parsedUrl = new URL(url);
// Strip `ai.` and `api.` subdomains for a better chance at finding a favicon // Strip `ai.` and `api.` subdomains for a better chance at finding a favicon
parsedUrl.hostname = parsedUrl.hostname.replace(/^(ai\.|api\.)/, ''); parsedUrl.hostname = parsedUrl.hostname.replace(/^(ai\.|api\.|enclave\.)/, '');
// Normalize the URL to ensure it has a protocol // Normalize the URL to ensure it has a protocol
return faviconUrl(config.faviconUrl, parsedUrl); return faviconUrl({ template: config.faviconUrl, url: parsedUrl });
} catch { } catch {
return; return;
} }
+3 -8
View File
@@ -17,8 +17,6 @@ interface SettingsPageLayoutProps {
children: ReactNode; children: ReactNode;
/** Optional className for the content container */ /** Optional className for the content container */
className?: string; className?: string;
/** Optional element to render next to the title */
titleSuffix?: ReactNode;
} }
/** /**
@@ -30,8 +28,7 @@ export function SettingsPageLayout({
titleKey, titleKey,
descriptionKey, descriptionKey,
children, children,
className = 'space-y-6', className,
titleSuffix,
}: SettingsPageLayoutProps) { }: SettingsPageLayoutProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const isMobile = useIsMobile(); const isMobile = useIsMobile();
@@ -51,10 +48,9 @@ export function SettingsPageLayout({
{t('backToSettings')} {t('backToSettings')}
</Button> </Button>
<div className="space-y-2"> <div className="space-y-2">
<h1 className="text-2xl font-bold flex flex-wrap items-center gap-3"> <h1 className="text-2xl font-bold flex items-center gap-3">
<Icon className="h-6 w-6 text-primary" /> <Icon className="h-6 w-6 text-primary" />
{t(titleKey)} {t(titleKey)}
{titleSuffix}
</h1> </h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">
{t(descriptionKey)} {t(descriptionKey)}
@@ -65,10 +61,9 @@ export function SettingsPageLayout({
{!isMobile && ( {!isMobile && (
<div className="space-y-2"> <div className="space-y-2">
<h1 className="text-2xl font-bold flex flex-wrap items-center gap-3"> <h1 className="text-2xl font-bold flex items-center gap-3">
<Icon className="h-6 w-6 text-primary" /> <Icon className="h-6 w-6 text-primary" />
{t(titleKey)} {t(titleKey)}
{titleSuffix}
</h1> </h1>
<p className="text-muted-foreground"> <p className="text-muted-foreground">
{t(descriptionKey)} {t(descriptionKey)}
@@ -0,0 +1,246 @@
import { useEffect, useRef, useState, useCallback } from 'react';
import { MessageSquare, Minus, X } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { ChatPane, type ChatPaneRef } from '@/components/Shakespeare/ChatPane';
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
import { ProjectPreviewConsoleError } from '@/lib/consoleMessages';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { cn } from '@/lib/utils';
interface FloatingChatWidgetProps {
projectId: string;
isMinimized: boolean;
onToggleMinimize: () => void;
onClose: () => void;
onNewChat: () => void;
onFirstInteraction?: () => void;
onLoadingChange?: (isLoading: boolean) => void;
isLoading?: boolean;
isBuildLoading?: boolean;
consoleError?: ProjectPreviewConsoleError | null;
onDismissConsoleError?: () => void;
}
interface ChatSize {
width: number;
height: number;
}
const MIN_WIDTH = 320;
const MIN_HEIGHT = 380;
const MAX_WIDTH = 720;
const MAX_HEIGHT = 900;
const DEFAULT_WIDTH = 420;
const DEFAULT_HEIGHT = 520;
export function FloatingChatWidget({
projectId,
isMinimized,
onToggleMinimize,
onClose,
onNewChat,
onFirstInteraction,
onLoadingChange,
isLoading,
isBuildLoading,
consoleError,
onDismissConsoleError,
}: FloatingChatWidgetProps) {
const chatPaneRef = useRef<ChatPaneRef>(null);
const [size, setSize] = useLocalStorage<ChatSize>('shk:floatingChatSize', {
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
});
const [isResizing, setIsResizing] = useState(false);
const resizeStartRef = useRef<{ x: number; y: number; width: number; height: number } | null>(null);
// Handle keyboard escape to minimize
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape' && !isMinimized) {
onToggleMinimize();
}
};
if (!isMinimized) {
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}
}, [isMinimized, onToggleMinimize]);
// Resize handlers
const startResize = useCallback((e: React.PointerEvent, direction: 'right' | 'bottom' | 'top' | 'bottomLeft' | 'topRight') => {
e.preventDefault();
e.stopPropagation();
const target = e.currentTarget as HTMLElement;
target.setPointerCapture(e.pointerId);
setIsResizing(true);
document.body.style.userSelect = 'none';
resizeStartRef.current = {
x: e.clientX,
y: e.clientY,
width: size.width,
height: size.height,
};
const handlePointerMove = (moveEvent: PointerEvent) => {
if (!resizeStartRef.current) return;
const maxW = Math.min(MAX_WIDTH, window.innerWidth - 16);
const maxH = Math.min(MAX_HEIGHT, window.innerHeight - 16);
let newWidth = resizeStartRef.current.width;
let newHeight = resizeStartRef.current.height;
// Handle horizontal resizing (left edge for bottom-right anchored widget)
if (direction === 'right' || direction === 'bottomLeft' || direction === 'topRight') {
const deltaX = resizeStartRef.current.x - moveEvent.clientX;
newWidth = Math.max(MIN_WIDTH, Math.min(maxW, resizeStartRef.current.width + deltaX));
}
// Handle vertical resizing from bottom (grows downward)
if (direction === 'bottom' || direction === 'bottomLeft') {
const deltaY = resizeStartRef.current.y - moveEvent.clientY;
newHeight = Math.max(MIN_HEIGHT, Math.min(maxH, resizeStartRef.current.height + deltaY));
}
// Handle vertical resizing from top (grows upward, widget anchored at bottom)
if (direction === 'top' || direction === 'topRight') {
const deltaY = moveEvent.clientY - resizeStartRef.current.y;
newHeight = Math.max(MIN_HEIGHT, Math.min(maxH, resizeStartRef.current.height - deltaY));
}
setSize({ width: newWidth, height: newHeight });
};
const handlePointerUp = () => {
setIsResizing(false);
document.body.style.userSelect = '';
resizeStartRef.current = null;
window.removeEventListener('pointermove', handlePointerMove);
window.removeEventListener('pointerup', handlePointerUp);
};
window.addEventListener('pointermove', handlePointerMove);
window.addEventListener('pointerup', handlePointerUp);
}, [size, setSize]);
if (isMinimized) {
return (
<div className="fixed right-4 bottom-4 z-50">
<Button
onClick={onToggleMinimize}
size="icon"
className="h-14 w-14 rounded-full shadow-lg hover:shadow-xl transition-all duration-200"
aria-label="Open chat"
>
<MessageSquare className="h-6 w-6" />
</Button>
</div>
);
}
return (
<div
className={cn(
"fixed right-4 bottom-4 z-50",
"rounded-lg border shadow-2xl bg-background",
"flex flex-col overflow-hidden",
isResizing && "select-none"
)}
style={{
width: `${size.width}px`,
height: `${size.height}px`,
maxWidth: '92vw',
maxHeight: '70vh',
}}
>
{/* Header - Styled like ProjectSidebar */}
<div className="h-12 px-4 border-b flex-shrink-0 flex items-center justify-between bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur">
<div className="flex items-center gap-2">
<ShakespeareLogo className="w-5 h-5" />
<h2 className="text-base font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
Shakespeare
</h2>
</div>
<div className="flex items-center gap-1">
<Button
onClick={onToggleMinimize}
variant="ghost"
size="icon"
className="h-8 w-8"
aria-label="Minimize chat"
>
<Minus className="h-4 w-4" />
</Button>
<Button
onClick={onClose}
variant="ghost"
size="icon"
className="h-8 w-8"
aria-label="Close floating chat"
>
<X className="h-4 w-4" />
</Button>
</div>
</div>
{/* Chat Body */}
<div className="flex-1 min-h-0 overflow-hidden">
<div className="h-full">
<ChatPane
ref={chatPaneRef}
projectId={projectId}
onNewChat={onNewChat}
onFirstInteraction={onFirstInteraction}
onLoadingChange={onLoadingChange}
isLoading={isLoading}
isBuildLoading={isBuildLoading}
consoleError={consoleError}
onDismissConsoleError={onDismissConsoleError}
/>
</div>
</div>
{/* Resize Handles */}
{/* Left edge (appears as "right" from widget perspective, but it's on the left side) */}
<div
className="absolute top-0 left-0 h-full w-2 cursor-ew-resize hover:bg-primary/10 active:bg-primary/20 transition-colors"
onPointerDown={(e) => startResize(e, 'right')}
style={{ touchAction: 'none' }}
/>
{/* Top edge */}
<div
className="absolute top-0 left-0 w-full h-2 cursor-ns-resize hover:bg-primary/10 active:bg-primary/20 transition-colors"
onPointerDown={(e) => startResize(e, 'top')}
style={{ touchAction: 'none' }}
/>
{/* Bottom edge */}
<div
className="absolute bottom-0 left-0 w-full h-2 cursor-ns-resize hover:bg-primary/10 active:bg-primary/20 transition-colors"
onPointerDown={(e) => startResize(e, 'bottom')}
style={{ touchAction: 'none' }}
/>
{/* Bottom-left corner */}
<div
className="absolute bottom-0 left-0 w-4 h-4 cursor-nesw-resize hover:bg-primary/20 active:bg-primary/30 transition-colors"
onPointerDown={(e) => startResize(e, 'bottomLeft')}
style={{ touchAction: 'none' }}
/>
{/* Top-right corner */}
<div
className="absolute top-0 right-0 w-4 h-4 cursor-nesw-resize hover:bg-primary/20 active:bg-primary/30 transition-colors"
onPointerDown={(e) => startResize(e, 'topRight')}
style={{ touchAction: 'none' }}
/>
</div>
);
}
@@ -63,10 +63,10 @@ export function CloudflareDeployForm({
const workersUrl = `${baseURL}/accounts/${accountId}/workers/scripts`; const workersUrl = `${baseURL}/accounts/${accountId}/workers/scripts`;
const [subdomainResponse, workersResponse] = await Promise.all([ const [subdomainResponse, workersResponse] = await Promise.all([
fetch(corsProxy ? proxyUrl(corsProxy, subdomainUrl) : subdomainUrl, { fetch(corsProxy ? proxyUrl({ template: corsProxy, url: subdomainUrl }) : subdomainUrl, {
headers: { 'Authorization': `Bearer ${apiKey}` }, headers: { 'Authorization': `Bearer ${apiKey}` },
}), }),
fetch(corsProxy ? proxyUrl(corsProxy, workersUrl) : workersUrl, { fetch(corsProxy ? proxyUrl({ template: corsProxy, url: workersUrl }) : workersUrl, {
headers: { 'Authorization': `Bearer ${apiKey}` }, headers: { 'Authorization': `Bearer ${apiKey}` },
}), }),
]); ]);
+1 -1
View File
@@ -56,7 +56,7 @@ export function DenoDeployForm({
try { try {
const url = `${baseURL}/organizations/${organizationId}/projects?limit=100`; const url = `${baseURL}/organizations/${organizationId}/projects?limit=100`;
const targetUrl = corsProxy ? proxyUrl(corsProxy, url) : url; const targetUrl = corsProxy ? proxyUrl({ template: corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
headers: { 'Authorization': `Bearer ${apiKey}` }, headers: { 'Authorization': `Bearer ${apiKey}` },
+1 -1
View File
@@ -53,7 +53,7 @@ export function NetlifyDeployForm({
try { try {
const url = `${baseURL}/sites`; const url = `${baseURL}/sites`;
const targetUrl = corsProxy ? proxyUrl(corsProxy, url) : url; const targetUrl = corsProxy ? proxyUrl({ template: corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
headers: { headers: {
+1 -1
View File
@@ -154,7 +154,7 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) {
if (url.protocol === 'nostr:') { if (url.protocol === 'nostr:') {
const nostrUri = await NostrURI.parse(url.href); const nostrUri = await NostrURI.parse(url.href);
return ngitWebUrl(config.ngitWebUrl, nostrUri); return ngitWebUrl({ template: config.ngitWebUrl, nostrURI: nostrUri });
} }
return null; return null;
+1
View File
@@ -7,6 +7,7 @@ export interface AIProvider {
apiKey?: string; apiKey?: string;
nostr?: boolean; nostr?: boolean;
proxy?: boolean; proxy?: boolean;
openSecret?: string;
} }
export interface MCPServer { export interface MCPServer {
-105
View File
@@ -1,105 +0,0 @@
import { useEffect, useRef, useState } from 'react';
import { useNostr } from '@nostrify/react';
import { useCurrentUser } from './useCurrentUser';
import type { NostrEvent } from '@nostrify/nostrify';
import { BADGE_ISSUER_PUBKEY } from '@/pages/BadgesSettings';
export function useBadgeAwardNotifications() {
const { nostr } = useNostr();
const { user } = useCurrentUser();
const [newAward, setNewAward] = useState<NostrEvent | null>(null);
const abortControllerRef = useRef<AbortController | null>(null);
const isMountedRef = useRef(true);
const subscriptionStartTimeRef = useRef<number | null>(null);
useEffect(() => {
isMountedRef.current = true;
return () => {
isMountedRef.current = false;
};
}, []);
useEffect(() => {
if (!user?.pubkey) {
// Clear subscription if user logs out
if (abortControllerRef.current) {
abortControllerRef.current.abort();
abortControllerRef.current = null;
}
return;
}
// Create abort controller for this subscription
const abortController = new AbortController();
abortControllerRef.current = abortController;
// Set the subscription start time to now, so we only get new events
const subscriptionStartTime = Math.floor(Date.now() / 1000);
subscriptionStartTimeRef.current = subscriptionStartTime;
// Set up subscription for new badge awards
const setupSubscription = async () => {
try {
const subscription = nostr.req([{
kinds: [8],
authors: [BADGE_ISSUER_PUBKEY],
"#p": [user.pubkey],
since: subscriptionStartTime, // Only get events from now onwards
}]);
// Process messages from the subscription
// Messages are in format: [type, subscriptionId, event]
for await (const msg of subscription) {
// Check if subscription was aborted or component unmounted
if (abortController.signal.aborted || !isMountedRef.current) {
break;
}
// Handle EVENT messages (msg[0] === 'EVENT')
if (msg[0] === 'EVENT') {
const event = msg[2] as NostrEvent;
// Only show if component is still mounted and not aborted
if (isMountedRef.current && !abortController.signal.aborted) {
setNewAward(event);
}
}
// EOSE (End of Stored Events) - subscription is complete for initial query
// We continue listening for new events, so we don't break here
if (msg[0] === 'EOSE') {
// Initial query complete, now listening for new events
continue;
}
}
} catch (error) {
// Subscription closed or error - this is normal on cleanup
// Ignore errors if we aborted or unmounted
if (abortController.signal.aborted || !isMountedRef.current) {
return;
}
console.error('Error in badge award subscription:', error);
}
};
setupSubscription();
// Cleanup on unmount or user change
return () => {
if (abortControllerRef.current) {
abortControllerRef.current.abort();
abortControllerRef.current = null;
}
};
}, [nostr, user?.pubkey]);
const clearNewAward = () => {
setNewAward(null);
};
return {
newAward,
clearNewAward,
};
}
+1 -1
View File
@@ -30,7 +30,7 @@ export function useGitHubOAuth() {
redirectUri: window.location.origin + '/oauth/github', redirectUri: window.location.origin + '/oauth/github',
usePKCE: true, // GitHub supports PKCE usePKCE: true, // GitHub supports PKCE
getUserInfo: async (accessToken: string, corsProxy: string) => { getUserInfo: async (accessToken: string, corsProxy: string) => {
const userUrl = proxyUrl(corsProxy, 'https://api.github.com/user'); const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.github.com/user' });
const userResponse = await fetch(userUrl, { const userResponse = await fetch(userUrl, {
headers: { headers: {
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,
+1 -1
View File
@@ -30,7 +30,7 @@ export function useNetlifyOAuth() {
redirectUri: window.location.origin + '/oauth/netlify', redirectUri: window.location.origin + '/oauth/netlify',
usePKCE: false, // Netlify doesn't support PKCE usePKCE: false, // Netlify doesn't support PKCE
getUserInfo: async (accessToken: string, corsProxy: string) => { getUserInfo: async (accessToken: string, corsProxy: string) => {
const userUrl = proxyUrl(corsProxy, 'https://api.netlify.com/api/v1/user'); const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.netlify.com/api/v1/user' });
const userResponse = await fetch(userUrl, { const userResponse = await fetch(userUrl, {
headers: { headers: {
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,
+1 -1
View File
@@ -169,7 +169,7 @@ export function useOAuth(config: OAuthConfig) {
} }
// Exchange code for access token // Exchange code for access token
const tokenUrl = proxyUrl(corsProxy, config.tokenUrl); const tokenUrl = proxyUrl({ template: corsProxy, url: config.tokenUrl });
const tokenResponse = await fetch(tokenUrl, { const tokenResponse = await fetch(tokenUrl, {
method: 'POST', method: 'POST',
headers: { headers: {
+1 -1
View File
@@ -34,7 +34,7 @@ export function useVercelOAuth() {
redirectUri: window.location.origin + '/oauth/vercel', redirectUri: window.location.origin + '/oauth/vercel',
usePKCE: false, // Vercel doesn't require PKCE usePKCE: false, // Vercel doesn't require PKCE
getUserInfo: async (accessToken: string, corsProxy: string) => { getUserInfo: async (accessToken: string, corsProxy: string) => {
const userUrl = proxyUrl(corsProxy, 'https://api.vercel.com/v2/user'); const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.vercel.com/v2/user' });
const userResponse = await fetch(userUrl, { const userResponse = await fetch(userUrl, {
headers: { headers: {
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,
+38 -1
View File
@@ -720,13 +720,50 @@ export class SessionManager {
this.emit('finishReasonChanged', projectId, null); this.emit('finishReasonChanged', projectId, null);
} }
/**
* Check if content exceeds size/line limits
*/
private exceedsLimits(content: string): boolean {
const MAX_SIZE_BYTES = 50 * 1024; // 50 KiB
const MAX_LINES = 2000;
const sizeBytes = new Blob([content]).size;
const lineCount = content.split('\n').length;
return sizeBytes > MAX_SIZE_BYTES || lineCount > MAX_LINES;
}
/**
* Save content to tmpDir and return the file path
*/
private async saveToTmpFile(projectId: string, content: string, toolCallId: string): Promise<string> {
const config = this.getConfig();
const timestamp = Date.now();
const filename = `tool-output-${toolCallId}-${timestamp}.txt`;
const filepath = `${config.fsPathTmp}/${filename}`;
await this.fs.writeFile(filepath, content, 'utf8');
return filepath;
}
/** /**
* Helper to add tool messages and update conversation * Helper to add tool messages and update conversation
*/ */
private async addToolMessage(projectId: string, toolCallId: string, content: string): Promise<void> { private async addToolMessage(projectId: string, toolCallId: string, content: string): Promise<void> {
let finalContent = content;
// Check if content exceeds limits
if (this.exceedsLimits(content)) {
// Save full content to tmp file
const filepath = await this.saveToTmpFile(projectId, content, toolCallId);
// Create placeholder message
finalContent = `The tool call succeeded but the output was truncated. Full output saved to: ${filepath}\nUse grep to search it for specific content, or text_editor_view with start_line/end_line to view specific sections.`;
}
const toolMessage: AIMessage = { const toolMessage: AIMessage = {
role: 'tool', role: 'tool',
content, content: finalContent,
tool_call_id: toolCallId tool_call_id: toolCallId
}; };
+50 -9
View File
@@ -12,17 +12,21 @@ import { proxyUrl } from './proxyUrl';
* If the provider has proxy enabled, requests will be proxied through the corsProxy. * If the provider has proxy enabled, requests will be proxied through the corsProxy.
*/ */
export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: string): OpenAI { export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: string): OpenAI {
const baseConfig: ConstructorParameters<typeof OpenAI>[0] = { const openai = new OpenAI({
baseURL: provider.baseURL, baseURL: provider.baseURL,
apiKey: provider.apiKey ?? '', apiKey: provider.apiKey ?? '',
dangerouslyAllowBrowser: true, dangerouslyAllowBrowser: true,
};
const openai = new OpenAI({
...baseConfig,
fetch: async (input, init) => { fetch: async (input, init) => {
let request = new Request(input, init); let request = new Request(input, init);
// OpenSecret auth
// https://docs.opensecret.cloud/docs/maple-ai/
if (provider.openSecret) {
const { createCustomFetch } = await import('@opensecret/react');
return createCustomFetch({ apiKey: provider.apiKey, apiUrl: provider.openSecret })(input, init);
}
// Add OpenRouter headers // Add OpenRouter headers
// https://openrouter.ai/docs/app-attribution // https://openrouter.ai/docs/app-attribution
if (provider.id === 'openrouter') { if (provider.id === 'openrouter') {
@@ -47,7 +51,7 @@ export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: s
// If proxy is enabled and we have a CORS proxy URL, modify the request URL // If proxy is enabled and we have a CORS proxy URL, modify the request URL
if (provider.proxy && corsProxy) { if (provider.proxy && corsProxy) {
request = new Request(proxyUrl(corsProxy, request.url), request); request = new Request(proxyUrl({ template: corsProxy, url: request.url }), request);
} }
return fetch(request); return fetch(request);
@@ -58,14 +62,51 @@ export function createAIClient(provider: AIProvider, user?: NUser, corsProxy?: s
= openai.chat.completions.create.bind(openai.chat.completions); = openai.chat.completions.create.bind(openai.chat.completions);
openai.chat.completions.create = ((...[body, options]: Parameters<typeof createCompletion>) => { openai.chat.completions.create = ((...[body, options]: Parameters<typeof createCompletion>) => {
// OpenRouter usage accounting // OpenRouter-specific hacks
// https://openrouter.ai/docs/use-cases/usage-accounting if (provider.id === "openrouter" || provider.baseURL === "https://openrouter.ai/api/v1") {
if (provider.id === 'openrouter') { // Usage accounting field to get token usage and cost per request
// https://openrouter.ai/docs/use-cases/usage-accounting
(body as { usage?: { include?: boolean } }).usage = { include: true }; (body as { usage?: { include?: boolean } }).usage = { include: true };
// Prompt caching for Claude models
// https://openrouter.ai/docs/guides/best-practices/prompt-caching#anthropic-claude
if (body.model.startsWith("anthropic/")) {
// First normalize the message history to use content blocks
body.messages = structuredClone(body.messages);
body.messages = body.messages.map((m) => {
if (m.role !== "function" && typeof m.content === "string") {
return { ...m, content: [{ type: "text", text: m.content }] };
} else {
return m;
}
});
const systemMessage = body.messages.find((m) => m.role === "system");
const nonSystemMessages = body.messages.filter((m) => m.role !== "system");
const lastTwoMessages = nonSystemMessages.slice(-2);
if (systemMessage) {
addCacheControl(systemMessage);
}
for (const msg of lastTwoMessages) {
addCacheControl(msg);
}
}
} }
return createCompletion(body, options); return createCompletion(body, options);
}) as typeof createCompletion; }) as typeof createCompletion;
return openai; return openai;
} }
/** Mutate msg to add an Anthropic `cache_control` property to its last text block */
function addCacheControl(msg: OpenAI.Chat.Completions.ChatCompletionMessageParam) {
if (Array.isArray(msg.content)) {
const lastTextBlock = msg.content.findLast((b) => b.type === "text");
if (lastTextBlock) {
(lastTextBlock as { cache_control?: { type: "ephemeral" } })
.cache_control = { type: "ephemeral" };
}
}
};
+17
View File
@@ -6,6 +6,7 @@ export interface PresetProvider {
nostr?: boolean; nostr?: boolean;
tosURL?: string; tosURL?: string;
proxy?: boolean; proxy?: boolean;
openSecret?: string;
} }
export const AI_PROVIDER_PRESETS: PresetProvider[] = [ export const AI_PROVIDER_PRESETS: PresetProvider[] = [
@@ -16,6 +17,22 @@ export const AI_PROVIDER_PRESETS: PresetProvider[] = [
tosURL: "https://ai.shakespeare.diy/terms", tosURL: "https://ai.shakespeare.diy/terms",
nostr: true, nostr: true,
}, },
{
id: "opencode",
name: "OpenCode Zen",
baseURL: "https://opencode.ai/zen/v1",
apiKeysURL: "https://opencode.ai/auth",
tosURL: "https://opencode.ai/legal/terms-of-service",
proxy: true,
},
{
id: "maple",
name: "Maple AI",
baseURL: "https://enclave.trymaple.ai/v1",
apiKeysURL: "https://trymaple.ai/",
tosURL: "https://opensecret.cloud/terms",
openSecret: "https://enclave.trymaple.ai",
},
{ {
id: "openrouter", id: "openrouter",
name: "OpenRouter", name: "OpenRouter",
+15
View File
@@ -260,6 +260,19 @@ export function esmPlugin(options: EsmPluginOptions): Plugin {
// not a URL; continue // not a URL; continue
} }
// Check if this is a file: dependency
const allDeps = {
...packageJson.dependencies,
...packageJson.devDependencies,
...packageJson.peerDependencies,
};
const depVersion = allDeps[packageName];
if (depVersion && depVersion.startsWith("file:")) {
// Let fsPlugin handle file: dependencies
return;
}
// Determine importer lock path (breadcrumb) // Determine importer lock path (breadcrumb)
const importerLockPath = getImporterLockPath(args.importer); const importerLockPath = getImporterLockPath(args.importer);
@@ -430,6 +443,8 @@ export function esmPlugin(options: EsmPluginOptions): Plugin {
if (contentType) { if (contentType) {
if (contentType === "application/javascript") { if (contentType === "application/javascript") {
loader = "js"; loader = "js";
} else if (contentType === "application/json") {
loader = "json";
} else if (contentType === "text/css") { } else if (contentType === "text/css") {
loader = "css"; loader = "css";
} else if (contentType === "application/wasm") { } else if (contentType === "application/wasm") {
+95 -9
View File
@@ -10,14 +10,21 @@ interface TsConfig {
}; };
} }
interface PackageJson {
dependencies?: { [key: string]: string };
devDependencies?: { [key: string]: string };
peerDependencies?: { [key: string]: string };
}
interface FsPluginOptions { interface FsPluginOptions {
fs: JSRuntimeFS; fs: JSRuntimeFS;
cwd: string; cwd: string;
tsconfig?: TsConfig; tsconfig?: TsConfig;
packageJson?: PackageJson;
} }
export function fsPlugin(options: FsPluginOptions): Plugin { export function fsPlugin(options: FsPluginOptions): Plugin {
const { fs, cwd, tsconfig } = options; const { fs, cwd, tsconfig, packageJson } = options;
return { return {
name: "fs", name: "fs",
@@ -30,21 +37,65 @@ export function fsPlugin(options: FsPluginOptions): Plugin {
}); });
build.onResolve({ filter: /.*/ }, async (args) => { build.onResolve({ filter: /.*/ }, async (args) => {
// Skip resolving paths from external URLs // Skip resolving paths from external URLs (but not fs: namespace)
if (/^https?:\/\//.test(args.importer)) { if (/^https?:\/\//.test(args.importer)) {
return; return;
} }
let resolved: string; let resolved: string | undefined;
// Handle absolute paths
if (args.path.startsWith("/")) { if (args.path.startsWith("/")) {
resolved = args.path; resolved = args.path;
} else if (args.path.startsWith("@/")) { }
// Handle @/ alias
else if (args.path.startsWith("@/")) {
resolved = join(cwd, "src", args.path.slice(2)); resolved = join(cwd, "src", args.path.slice(2));
} else if (args.importer && (args.path.startsWith("./") || args.path.startsWith("../"))) { }
resolved = join(dirname(args.importer), args.path); // Handle relative paths
} else if (args.importer && tsconfig?.compilerOptions?.baseUrl) { else if (args.importer && (args.path.startsWith("./") || args.path.startsWith("../"))) {
// Remove fs: prefix from importer if present
const importerPath = args.importer.replace(/^fs:/, '');
resolved = join(dirname(importerPath), args.path);
}
// Handle bare imports (e.g., "react", "@scope/package")
else if (args.path.match(/^[^./]/)) {
// Check if this is a file: dependency
const packageName = args.path.startsWith("@")
? args.path.split("/").slice(0, 2).join("/")
: args.path.split("/")[0];
const allDeps = {
...packageJson?.dependencies,
...packageJson?.devDependencies,
...packageJson?.peerDependencies,
};
const depVersion = allDeps[packageName];
if (depVersion && depVersion.startsWith("file:")) {
// Extract the file path (e.g., "file:./path" -> "./path")
const filePath = depVersion.slice(5); // Remove "file:" prefix
const packagePath = join(cwd, filePath);
// Get the subpath within the package (e.g., "package/subdir/file" -> "/subdir/file")
const subpath = args.path.slice(packageName.length);
resolved = join(packagePath, subpath);
} else {
return; // Let esmPlugin handle this
}
}
// Handle tsconfig baseUrl
else if (args.importer && tsconfig?.compilerOptions?.baseUrl) {
resolved = join(cwd, tsconfig.compilerOptions.baseUrl, args.path); resolved = join(cwd, tsconfig.compilerOptions.baseUrl, args.path);
} else { }
// Nothing matched, let other plugins handle it
else {
return;
}
if (!resolved) {
return; return;
} }
@@ -114,8 +165,43 @@ async function tryFileVariants(
return basePath; return basePath;
} }
// If it's a directory, try index files // If it's a directory, try package.json first, then index files
if (stat.isDirectory()) { if (stat.isDirectory()) {
// Try to read package.json for entry point
try {
const packageJsonPath = join(basePath, "package.json");
const packageJsonText = await fs.readFile(packageJsonPath, "utf8");
const packageJson = JSON.parse(packageJsonText);
// Check for various entry point fields
const entryPoint = packageJson.exports?.['.']
|| packageJson.module
|| packageJson.main
|| 'index.js';
// Resolve the entry point
const entryPath = typeof entryPoint === 'string'
? join(basePath, entryPoint)
: join(basePath, 'index.js');
const entryStat = await statSafe(fs, entryPath);
if (entryStat.isFile()) {
return entryPath;
}
// Try with different extensions if the entry point doesn't exist
for (const ext of extensions) {
const entryWithExt = entryPath.replace(/\.[^.]+$/, '') + ext;
const entryExtStat = await statSafe(fs, entryWithExt);
if (entryExtStat.isFile()) {
return entryWithExt;
}
}
} catch {
// package.json doesn't exist or is invalid, fall through to index files
}
// Fall back to trying index files
for (const ext of extensions) { for (const ext of extensions) {
const indexFile = join(basePath, "index" + ext); const indexFile = join(basePath, "index" + ext);
const indexStat = await statSafe(fs, indexFile); const indexStat = await statSafe(fs, indexFile);
+59
View File
@@ -535,4 +535,63 @@ react@^18.0.0:
// Verify tsconfig.json was attempted to be read // Verify tsconfig.json was attempted to be read
expect(mockFS.readFile).toHaveBeenCalledWith('/test/project/tsconfig.json', 'utf8'); expect(mockFS.readFile).toHaveBeenCalledWith('/test/project/tsconfig.json', 'utf8');
}); });
it('should support file: dependencies in package.json', async () => {
const packageJsonWithFileDeps = JSON.stringify({
name: "test-project",
dependencies: {
"@bitchat/capacitor-ble-mesh": "file:./capacitor-bitchat-mesh",
"react": "^18.2.0"
}
});
// Mock required files
vi.mocked(mockFS.readFile)
.mockImplementation(async (path: string) => {
if (path.endsWith('package.json')) {
return packageJsonWithFileDeps;
}
if (path.endsWith('index.html')) {
return '<html><head></head><body><script src="/src/main.tsx"></script></body></html>';
}
if (path.endsWith('package-lock.json')) {
return '{"dependencies": {}}';
}
throw new Error(`File not found: ${path}`);
});
// Mock stat to indicate no public directory
vi.mocked(mockFS.stat)
.mockImplementation(async (path: string) => {
if (path === '/test/project/public') {
throw new Error('Directory not found');
}
return { isDirectory: () => false, isFile: () => true };
});
// Mock additional filesystem operations for buildProject
vi.mocked(mockFS.readdir).mockImplementation(async (path: string) => {
if (path === '/test/project/dist') {
return [];
}
return [];
});
vi.mocked(mockFS.mkdir).mockResolvedValue(undefined);
vi.mocked(mockFS.writeFile).mockResolvedValue(undefined);
const result = await buildProject({
fs: mockFS,
projectPath: '/test/project',
domParser: mockDOMParser,
esmUrl: 'https://esm.shakespeare.diy',
});
// Should successfully build with file: dependencies
expect(result.files['stdin-abc123.js']).toEqual(new Uint8Array([1, 2, 3]));
expect(result.files['index.html']).toBeDefined();
// Verify package.json was read
expect(mockFS.readFile).toHaveBeenCalledWith('/test/project/package.json', 'utf8');
});
}); });
+1 -1
View File
@@ -130,7 +130,7 @@ async function bundle(
assetNames: "[name]-[hash]", assetNames: "[name]-[hash]",
plugins: [ plugins: [
shakespearePlugin({ esmUrl }), shakespearePlugin({ esmUrl }),
fsPlugin({ fs, cwd: projectPath, tsconfig }), fsPlugin({ fs, cwd: projectPath, tsconfig, packageJson }),
esmPlugin({ packageJson, packageLock, target, esmUrl }), esmPlugin({ packageJson, packageLock, target, esmUrl }),
], ],
define: { define: {
+1 -1
View File
@@ -66,7 +66,7 @@ export class CurlCommand implements ShellCommand {
// Proxy the URL through configured CorsProxy // Proxy the URL through configured CorsProxy
const originalUrl = url.toString(); const originalUrl = url.toString();
const proxiedUrl = proxyUrl(this.corsProxy, originalUrl); const proxiedUrl = proxyUrl({ template: this.corsProxy, url: originalUrl });
// Prepare request // Prepare request
const requestInit: RequestInit = { const requestInit: RequestInit = {
+1
View File
@@ -37,6 +37,7 @@ const aiProviderSchema = z.object({
apiKey: z.string().optional(), apiKey: z.string().optional(),
nostr: z.boolean().optional(), nostr: z.boolean().optional(),
proxy: z.boolean().optional(), proxy: z.boolean().optional(),
openSecret: z.string().url().optional(),
}); });
const providerModelSchema = z.string().regex( const providerModelSchema = z.string().regex(
+5 -5
View File
@@ -140,7 +140,7 @@ export class CloudflareAdapter implements DeployAdapter {
private async getWorkersSubdomain(): Promise<string> { private async getWorkersSubdomain(): Promise<string> {
const url = `${this.baseURL}/accounts/${this.accountId}/workers/subdomain`; const url = `${this.baseURL}/accounts/${this.accountId}/workers/subdomain`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'GET', method: 'GET',
@@ -160,7 +160,7 @@ export class CloudflareAdapter implements DeployAdapter {
private async enableWorkersDevSubdomain(scriptName: string): Promise<void> { private async enableWorkersDevSubdomain(scriptName: string): Promise<void> {
const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}/subdomain`; const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}/subdomain`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'POST', method: 'POST',
@@ -185,7 +185,7 @@ export class CloudflareAdapter implements DeployAdapter {
manifest: AssetManifest manifest: AssetManifest
): Promise<InitializeAssetsResponse> { ): Promise<InitializeAssetsResponse> {
const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}/assets-upload-session`; const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}/assets-upload-session`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'POST', method: 'POST',
@@ -211,7 +211,7 @@ export class CloudflareAdapter implements DeployAdapter {
hashToFile: Map<string, { path: string; info: FileInfo }> hashToFile: Map<string, { path: string; info: FileInfo }>
): Promise<UploadResponse> { ): Promise<UploadResponse> {
const url = `${this.baseURL}/accounts/${this.accountId}/workers/assets/upload?base64=true`; const url = `${this.baseURL}/accounts/${this.accountId}/workers/assets/upload?base64=true`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const formData = new FormData(); const formData = new FormData();
@@ -251,7 +251,7 @@ export class CloudflareAdapter implements DeployAdapter {
private async deployWorker(scriptName: string, assetsJwt: string): Promise<WorkerScript> { private async deployWorker(scriptName: string, assetsJwt: string): Promise<WorkerScript> {
const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}`; const url = `${this.baseURL}/accounts/${this.accountId}/workers/scripts/${scriptName}`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
// Create a minimal worker script that serves static assets // Create a minimal worker script that serves static assets
// This is an assets-only worker - Cloudflare will automatically serve the uploaded assets // This is an assets-only worker - Cloudflare will automatically serve the uploaded assets
+3 -3
View File
@@ -96,7 +96,7 @@ export class DenoDeployAdapter implements DeployAdapter {
private async findProject(projectName: string): Promise<Project | null> { private async findProject(projectName: string): Promise<Project | null> {
const url = `${this.baseURL}/organizations/${this.organizationId}/projects?q=${encodeURIComponent(projectName)}`; const url = `${this.baseURL}/organizations/${this.organizationId}/projects?q=${encodeURIComponent(projectName)}`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'GET', method: 'GET',
@@ -116,7 +116,7 @@ export class DenoDeployAdapter implements DeployAdapter {
private async createProject(projectName: string): Promise<Project> { private async createProject(projectName: string): Promise<Project> {
const url = `${this.baseURL}/organizations/${this.organizationId}/projects`; const url = `${this.baseURL}/organizations/${this.organizationId}/projects`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'POST', method: 'POST',
@@ -143,7 +143,7 @@ export class DenoDeployAdapter implements DeployAdapter {
domain: string domain: string
): Promise<Deployment> { ): Promise<Deployment> {
const url = `${this.baseURL}/projects/${projectId}/deployments`; const url = `${this.baseURL}/projects/${projectId}/deployments`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
// Create a minimal server script that serves static files // Create a minimal server script that serves static files
// For static sites, we use a simple file server entry point // For static sites, we use a simple file server entry point
+3 -3
View File
@@ -89,7 +89,7 @@ export class NetlifyAdapter implements DeployAdapter {
private async createSite(name: string): Promise<NetlifySite> { private async createSite(name: string): Promise<NetlifySite> {
const url = `${this.baseURL}/sites`; const url = `${this.baseURL}/sites`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'POST', method: 'POST',
@@ -113,7 +113,7 @@ export class NetlifyAdapter implements DeployAdapter {
private async getSite(siteId: string): Promise<NetlifySite> { private async getSite(siteId: string): Promise<NetlifySite> {
const url = `${this.baseURL}/sites/${siteId}`; const url = `${this.baseURL}/sites/${siteId}`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'GET', method: 'GET',
@@ -132,7 +132,7 @@ export class NetlifyAdapter implements DeployAdapter {
private async triggerDeploy(siteId: string, zipBlob: Blob): Promise<NetlifyBuildResponse> { private async triggerDeploy(siteId: string, zipBlob: Blob): Promise<NetlifyBuildResponse> {
const url = `${this.baseURL}/sites/${siteId}/deploys`; const url = `${this.baseURL}/sites/${siteId}/deploys`;
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url }) : url;
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
method: 'POST', method: 'POST',
+1 -1
View File
@@ -72,7 +72,7 @@ export class ShakespeareAdapter implements DeployAdapter {
// Apply proxy if configured // Apply proxy if configured
if (this.corsProxy) { if (this.corsProxy) {
request = new Request(proxyUrl(this.corsProxy, request.url), request); request = new Request(proxyUrl({ template: this.corsProxy, url: request.url }), request);
} }
// Deploy // Deploy
+1 -1
View File
@@ -68,7 +68,7 @@ export class VercelAdapter implements DeployAdapter {
} }
// Apply proxy if configured // Apply proxy if configured
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, apiUrl) : apiUrl; const targetUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url: apiUrl }) : apiUrl;
// Deploy to Vercel // Deploy to Vercel
const response = await fetch(targetUrl, { const response = await fetch(targetUrl, {
+11 -5
View File
@@ -1,15 +1,21 @@
import UriTemplate from 'uri-templates'; import UriTemplate from 'uri-templates';
export interface FaviconUrlOpts {
template: string;
url: string | URL;
}
/** /**
* Generate a favicon URL from a template and input URL * Generate a favicon URL from a template and input URL
* @param template - URL template with placeholders like {hostname}, {origin}, etc. * @param opts - Options object
* @param url - The URL to extract parts from * @param opts.template - URL template with placeholders like {hostname}, {origin}, etc.
* @param opts.url - The URL to extract parts from
* @returns The hydrated favicon URL * @returns The hydrated favicon URL
*/ */
export function faviconUrl(template: string, url: string | URL): string { export function faviconUrl(opts: FaviconUrlOpts): string {
const u = new URL(url); const u = new URL(opts.url);
return UriTemplate(template).fill({ return UriTemplate(opts.template).fill({
href: u.href, href: u.href,
origin: u.origin, origin: u.origin,
protocol: u.protocol, protocol: u.protocol,
+1 -1
View File
@@ -1115,7 +1115,7 @@ class GitHttp implements HttpClient {
const url = new URL(request.url); const url = new URL(request.url);
const target = this.proxy const target = this.proxy
? proxyUrl(this.proxy, url) ? proxyUrl({ template: this.proxy, url })
: url.href; : url.href;
const init: RequestInit = { const init: RequestInit = {
+6 -6
View File
@@ -9,7 +9,7 @@ describe('ngitWebUrl', () => {
const identifier = 'my-repo'; const identifier = 'my-repo';
const nostrURI = new NostrURI({ pubkey, identifier }); const nostrURI = new NostrURI({ pubkey, identifier });
const result = ngitWebUrl(template, nostrURI); const result = ngitWebUrl({ template, nostrURI });
expect(result).toMatch(/^https:\/\/nostrhub\.io\/naddr1/); expect(result).toMatch(/^https:\/\/nostrhub\.io\/naddr1/);
}); });
@@ -20,7 +20,7 @@ describe('ngitWebUrl', () => {
const identifier = 'my-repo'; const identifier = 'my-repo';
const nostrURI = new NostrURI({ pubkey, identifier }); const nostrURI = new NostrURI({ pubkey, identifier });
const result = ngitWebUrl(template, nostrURI); const result = ngitWebUrl({ template, nostrURI });
expect(result).toMatch(/^https:\/\/example\.com\/npub1/); expect(result).toMatch(/^https:\/\/example\.com\/npub1/);
}); });
@@ -31,7 +31,7 @@ describe('ngitWebUrl', () => {
const identifier = 'my-repo'; const identifier = 'my-repo';
const nostrURI = new NostrURI({ pubkey, identifier }); const nostrURI = new NostrURI({ pubkey, identifier });
const result = ngitWebUrl(template, nostrURI); const result = ngitWebUrl({ template, nostrURI });
expect(result).toBe(`https://example.com/${pubkey}`); expect(result).toBe(`https://example.com/${pubkey}`);
}); });
@@ -42,7 +42,7 @@ describe('ngitWebUrl', () => {
const identifier = 'my-repo'; const identifier = 'my-repo';
const nostrURI = new NostrURI({ pubkey, identifier }); const nostrURI = new NostrURI({ pubkey, identifier });
const result = ngitWebUrl(template, nostrURI); const result = ngitWebUrl({ template, nostrURI });
expect(result).toBe('https://example.com/my-repo'); expect(result).toBe('https://example.com/my-repo');
}); });
@@ -53,7 +53,7 @@ describe('ngitWebUrl', () => {
const identifier = 'my-repo'; const identifier = 'my-repo';
const nostrURI = new NostrURI({ pubkey, identifier }); const nostrURI = new NostrURI({ pubkey, identifier });
const result = ngitWebUrl(template, nostrURI); const result = ngitWebUrl({ template, nostrURI });
expect(result).toMatch(/^https:\/\/example\.com\/npub1[^/]+\/my-repo$/); expect(result).toMatch(/^https:\/\/example\.com\/npub1[^/]+\/my-repo$/);
}); });
@@ -65,7 +65,7 @@ describe('ngitWebUrl', () => {
const relay = 'wss://relay.example.com/'; const relay = 'wss://relay.example.com/';
const nostrURI = new NostrURI({ pubkey, identifier, relay }); const nostrURI = new NostrURI({ pubkey, identifier, relay });
const result = ngitWebUrl(template, nostrURI); const result = ngitWebUrl({ template, nostrURI });
// The naddr should be longer when it includes relay information // The naddr should be longer when it includes relay information
expect(result).toMatch(/^https:\/\/nostrhub\.io\/naddr1/); expect(result).toMatch(/^https:\/\/nostrhub\.io\/naddr1/);
+14 -8
View File
@@ -2,20 +2,26 @@ import UriTemplate from 'uri-templates';
import { nip19 } from 'nostr-tools'; import { nip19 } from 'nostr-tools';
import { NostrURI } from './NostrURI'; import { NostrURI } from './NostrURI';
export interface NgitWebUrlOpts {
template: string;
nostrURI: NostrURI;
}
/** /**
* Generate a Nostr Git web URL from a template and Nostr URI * Generate a Nostr Git web URL from a template and Nostr URI
* @param template - URL template with placeholders like {naddr}, {npub}, {pubkey}, {identifier} * @param opts - Options object
* @param nostrURI - The Nostr URI containing pubkey, identifier, and optional relay * @param opts.template - URL template with placeholders like {naddr}, {npub}, {pubkey}, {identifier}
* @param opts.nostrURI - The Nostr URI containing pubkey, identifier, and optional relay
* @returns The hydrated web URL * @returns The hydrated web URL
*/ */
export function ngitWebUrl(template: string, nostrURI: NostrURI): string { export function ngitWebUrl(opts: NgitWebUrlOpts): string {
const naddr = nostrURI.toNaddr(); const naddr = opts.nostrURI.toNaddr();
const npub = nip19.npubEncode(nostrURI.pubkey); const npub = nip19.npubEncode(opts.nostrURI.pubkey);
return UriTemplate(template).fill({ return UriTemplate(opts.template).fill({
naddr, naddr,
npub, npub,
pubkey: nostrURI.pubkey, pubkey: opts.nostrURI.pubkey,
identifier: nostrURI.identifier, identifier: opts.nostrURI.identifier,
}); });
} }
+8 -3
View File
@@ -1,8 +1,13 @@
import UriTemplate from 'uri-templates'; import UriTemplate from 'uri-templates';
export function proxyUrl(template: string, url: string | URL): string { export interface ProxyUrlOpts {
const u = new URL(url); template: string;
return UriTemplate(template).fill({ url: string | URL;
}
export function proxyUrl(opts: ProxyUrlOpts): string {
const u = new URL(opts.url);
return UriTemplate(opts.template).fill({
href: u.href, href: u.href,
origin: u.origin, origin: u.origin,
protocol: u.protocol, protocol: u.protocol,
+1 -7
View File
@@ -1,4 +1,4 @@
import { Bot, GitBranch, Database, Wifi, Settings2, Info, Settings, Rocket, Award } from 'lucide-react'; import { Bot, GitBranch, Database, Wifi, Settings2, Info, Settings, Rocket } from 'lucide-react';
export interface SettingsItem { export interface SettingsItem {
id: string; id: string;
@@ -29,12 +29,6 @@ export const getSettingsCategories = (t: (key: string) => string): SettingsCateg
title: t('preferences'), title: t('preferences'),
href: '/settings/preferences', href: '/settings/preferences',
}, },
{
id: 'badges',
icon: Award,
title: t('badges'),
href: '/settings/badges',
},
], ],
}, },
{ {
+1 -1
View File
@@ -137,7 +137,7 @@ export class GenerateImageTool implements Tool<GenerateImageParams> {
} }
} else if (firstImage.url) { } else if (firstImage.url) {
// Fetch the image from the URL // Fetch the image from the URL
const imageUrl = this.corsProxy ? proxyUrl(this.corsProxy, firstImage.url) : firstImage.url; const imageUrl = this.corsProxy ? proxyUrl({ template: this.corsProxy, url: firstImage.url }) : firstImage.url;
const imageResponse = await fetch(imageUrl); const imageResponse = await fetch(imageUrl);
if (!imageResponse.ok) { if (!imageResponse.ok) {
+1 -7
View File
@@ -561,11 +561,5 @@
"failedToDuplicateProject": "Failed to duplicate project", "failedToDuplicateProject": "Failed to duplicate project",
"newProjectName": "New Project Name", "newProjectName": "New Project Name",
"duplicateProjectDescription": "Create a copy of this project with a new name", "duplicateProjectDescription": "Create a copy of this project with a new name",
"resume": "Resume", "resume": "Resume"
"badges": "Badges",
"badgesDescription": "View and manage your earned badges and achievements",
"noBadgesFound": "No badges found",
"tokenProgress": "Tokens",
"imageProgress": "Images",
"nextBadgeAt": "Next badge at {{milestone}}"
} }
+1 -7
View File
@@ -477,11 +477,5 @@
"failedToDuplicateProject": "An kasa kwafin aikin", "failedToDuplicateProject": "An kasa kwafin aikin",
"newProjectName": "Sunan Sabon Aikin", "newProjectName": "Sunan Sabon Aikin",
"duplicateProjectDescription": "Ƙirƙiri kwafin wannan aikin da sabon suna", "duplicateProjectDescription": "Ƙirƙiri kwafin wannan aikin da sabon suna",
"resume": "Ci gaba", "resume": "Ci gaba"
"badges": "Tambari",
"badgesDescription": "Duba da sarrafa tambarin da kuka samu da nasarorin",
"noBadgesFound": "Ba a sami tambari ba",
"tokenProgress": "Tokens",
"imageProgress": "Hotuna",
"nextBadgeAt": "Tambari na gaba a {{milestone}}"
} }
+1 -7
View File
@@ -474,11 +474,5 @@
"failedToDuplicateProject": "Ọ dara ada imepụta ọrụ", "failedToDuplicateProject": "Ọ dara ada imepụta ọrụ",
"newProjectName": "Aha Ọrụ Ọhụrụ", "newProjectName": "Aha Ọrụ Ọhụrụ",
"duplicateProjectDescription": "Mepụta oyiri nke ọrụ a na aha ọhụrụ", "duplicateProjectDescription": "Mepụta oyiri nke ọrụ a na aha ọhụrụ",
"resume": "Gaa n'ihu", "resume": "Gaa n'ihu"
"badges": "Baajị",
"badgesDescription": "Lelee ma jikwaa baajị na mmeri gị",
"noBadgesFound": "Achọtaghị baajị",
"tokenProgress": "Tokens",
"imageProgress": "Foto",
"nextBadgeAt": "Baajị ọzọ na {{milestone}}"
} }
+1 -7
View File
@@ -486,11 +486,5 @@
"failedToDuplicateProject": "Falha ao duplicar projeto", "failedToDuplicateProject": "Falha ao duplicar projeto",
"newProjectName": "Nome do Novo Projeto", "newProjectName": "Nome do Novo Projeto",
"duplicateProjectDescription": "Criar uma cópia deste projeto com um novo nome", "duplicateProjectDescription": "Criar uma cópia deste projeto com um novo nome",
"resume": "Retomar", "resume": "Retomar"
"badges": "Distintivos",
"badgesDescription": "Visualizar e gerenciar seus distintivos e conquistas",
"noBadgesFound": "Nenhum distintivo encontrado",
"tokenProgress": "Tokens",
"imageProgress": "Imagens",
"nextBadgeAt": "Próximo distintivo em {{milestone}}"
} }
+1 -7
View File
@@ -474,11 +474,5 @@
"failedToDuplicateProject": "O kuna lati ṣe ẹda iṣẹ akanṣe", "failedToDuplicateProject": "O kuna lati ṣe ẹda iṣẹ akanṣe",
"newProjectName": "Orukọ Iṣẹ Akanṣe Tuntun", "newProjectName": "Orukọ Iṣẹ Akanṣe Tuntun",
"duplicateProjectDescription": "Ṣẹda ẹda ti iṣẹ akanṣe yii pẹlu orukọ tuntun", "duplicateProjectDescription": "Ṣẹda ẹda ti iṣẹ akanṣe yii pẹlu orukọ tuntun",
"resume": "Tẹsiwaju", "resume": "Tẹsiwaju"
"badges": "Àmì-ẹ̀yẹ",
"badgesDescription": "Wo ati ṣakoso àmì-ẹ̀yẹ àti àwọn àṣeyọrí rẹ",
"noBadgesFound": "Ko ri àmì-ẹ̀yẹ",
"tokenProgress": "Àwọn tókẹ̀n",
"imageProgress": "Àwọn àwòrán",
"nextBadgeAt": "Àmì-ẹ̀yẹ tó kàn ní {{milestone}}"
} }
+1 -7
View File
@@ -486,11 +486,5 @@
"failedToDuplicateProject": "复制项目失败", "failedToDuplicateProject": "复制项目失败",
"newProjectName": "新项目名称", "newProjectName": "新项目名称",
"duplicateProjectDescription": "使用新名称创建此项目的副本", "duplicateProjectDescription": "使用新名称创建此项目的副本",
"resume": "继续", "resume": "继续"
"badges": "徽章",
"badgesDescription": "查看和管理您获得的徽章和成就",
"noBadgesFound": "未找到徽章",
"tokenProgress": "代币",
"imageProgress": "图片",
"nextBadgeAt": "下一个徽章需要 {{milestone}}"
} }
+3
View File
@@ -118,6 +118,9 @@ export function AISettings() {
if (typeof preset.proxy === 'boolean') { if (typeof preset.proxy === 'boolean') {
newProvider.proxy = preset.proxy; newProvider.proxy = preset.proxy;
} }
if (preset.openSecret) {
newProvider.openSecret = preset.openSecret;
}
setProvider(newProvider); setProvider(newProvider);
}; };
-535
View File
@@ -1,535 +0,0 @@
import { Award, Lock } from "lucide-react";
import { useTranslation } from 'react-i18next';
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Progress } from "@/components/ui/progress";
import { Badge } from "@/components/ui/badge";
import { useNostr } from '@nostrify/react';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { Skeleton } from "@/components/ui/skeleton";
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useAISettings } from '@/hooks/useAISettings';
import { useAppContext } from '@/hooks/useAppContext';
import { BadgeAwardModal } from '@/components/BadgeAwardModal';
import { cn } from '@/lib/utils';
import { useState, useMemo } from 'react';
import type { NostrEvent } from '@nostrify/nostrify';
import { createAIClient } from '@/lib/ai-client';
import { nip19 } from 'nostr-tools';
export const BADGE_ISSUER_NPUB = "npub1e0u5dfurw3dmd0n5lul873c5g3p89et6x372sa35spajcxjh4f6svcvahk";
export const BADGE_ISSUER_PUBKEY = nip19.decode(BADGE_ISSUER_NPUB).data as string;
// Badge sync response from the server
interface BadgeSyncResponse {
object: 'badge_sync';
synced: string[];
stats: {
generation_count: number;
total_tokens: number;
image_count: number;
has_lightning_payment: boolean;
giftcards_sent: number;
max_giftcard_amount: number;
};
milestones?: {
tokenMilestones: Array<{ threshold: number; type: 'generation' | 'tokens'; creditReward?: number }>;
imageMilestones: Array<{ count: number; creditReward?: number }>;
giftcardMilestones: Array<{ threshold: number; type: 'count' | 'amount'; creditReward?: number }>;
};
}
function formatNumber(num: number): string {
if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(1)}B`;
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
return num.toString();
}
interface TokenMilestone {
threshold: number;
type: 'generation' | 'tokens';
creditReward?: number;
}
interface TokenProgressResult {
progress: number;
current: number;
next: number;
type: 'generation' | 'tokens';
}
function getTokenMilestoneProgress(
generationCount: number,
totalTokens: number,
milestones: TokenMilestone[]
): TokenProgressResult | null {
// Find the first uncompleted milestone
for (let i = 0; i < milestones.length; i++) {
const milestone = milestones[i];
const currentValue = milestone.type === 'generation' ? generationCount : totalTokens;
if (currentValue < milestone.threshold) {
// This is the next milestone to achieve
const prevMilestone = i > 0 ? milestones[i - 1] : null;
const prevThreshold = prevMilestone
? (prevMilestone.type === milestone.type ? prevMilestone.threshold : 0)
: 0;
const range = milestone.threshold - prevThreshold;
const progressInRange = currentValue - prevThreshold;
const progress = Math.min(100, Math.max(0, (progressInRange / range) * 100));
return {
progress,
current: currentValue,
next: milestone.threshold,
type: milestone.type,
};
}
}
// All milestones achieved
return null;
}
function getImageMilestoneProgress(
imageCount: number,
milestones: number[]
): { progress: number; current: number; next: number } | null {
// Find the first uncompleted milestone
for (let i = 0; i < milestones.length; i++) {
const milestone = milestones[i];
if (imageCount < milestone) {
const prevThreshold = i > 0 ? milestones[i - 1] : 0;
const range = milestone - prevThreshold;
const progressInRange = imageCount - prevThreshold;
const progress = Math.min(100, Math.max(0, (progressInRange / range) * 100));
return { progress, current: imageCount, next: milestone };
}
}
// All milestones achieved
return null;
}
function isCreditMilestone(milestone: number | null, creditMilestones: number[]): boolean {
return milestone !== null && creditMilestones.includes(milestone);
}
function BadgeCard({
event,
awarded,
unlockDate,
onClick
}: {
event: NostrEvent;
awarded: boolean;
unlockDate?: number | null;
onClick?: () => void;
}) {
const dTag = event.tags.find(([t]) => t === "d")?.[1];
const nameTag = event.tags.find(([t]) => t === "name")?.[1];
const descriptionTag = event.tags.find(([t]) => t === "description")?.[1];
const imageTag = event.tags.find(([t]) => t === "image")?.[1];
const thumbTags = event.tags.filter(([t]) => t === "thumb");
const badgeName = nameTag || dTag || "Unnamed Badge";
const description = descriptionTag || "";
const imageUrl = imageTag || (thumbTags.length > 0 ? thumbTags[thumbTags.length - 1]?.[1] : null);
const formattedDate = unlockDate
? new Date(unlockDate * 1000).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric'
})
: null;
return (
<Card
className={cn(
"transition-all bg-transparent border-none shadow-none h-full",
awarded ? "cursor-pointer hover:scale-105" : ""
)}
onClick={awarded ? onClick : undefined}
>
<CardHeader className="text-center p-0 h-full flex flex-col">
<div className="flex justify-center">
{imageUrl ? (
<img
src={imageUrl}
alt={badgeName}
className={cn(
"w-32 h-32 rounded-lg object-cover",
awarded ? "" : "opacity-50 grayscale blur-md"
)}
/>
) : null}
</div>
<div className="flex flex-col flex-1 mt-4">
{/* Title area - fixed height for 2 lines */}
<div className="min-h-[3.5rem] flex items-start justify-center">
{awarded ? (
<CardTitle className="text-lg leading-tight line-clamp-2">
{badgeName}
</CardTitle>
) : (
<Lock className="h-5 w-5 text-muted-foreground mt-1" />
)}
</div>
{/* Description area - fixed height for 2 lines */}
{description && (
<p className={cn(
"text-sm min-h-[2.5rem] line-clamp-2 mt-1",
awarded ? "text-muted-foreground" : "text-muted-foreground/70"
)}>
{description}
</p>
)}
{/* Unlock date - pushed to bottom */}
<div className="mt-auto pt-2">
{awarded && formattedDate && (
<p className="text-xs text-muted-foreground/70">
Unlocked {formattedDate}
</p>
)}
</div>
</div>
</CardHeader>
</Card>
);
}
export function BadgesSettings() {
const { t } = useTranslation();
const { nostr } = useNostr();
const { user } = useCurrentUser();
const { settings } = useAISettings();
const { config } = useAppContext();
const queryClient = useQueryClient();
const userPubkey = user?.pubkey;
const [selectedBadge, setSelectedBadge] = useState<NostrEvent | null>(null);
const [progressIndex, setProgressIndex] = useState(0);
// Find a Shakespeare provider (one with nostr auth) for badge sync
const shakespeareProvider = useMemo(
() => settings.providers.find(p => p.nostr),
[settings.providers]
);
// Badge sync query - calls the server to sync badges and get stats
const { data: syncData } = useQuery({
queryKey: ['badge-sync', userPubkey, shakespeareProvider?.id],
queryFn: async (): Promise<BadgeSyncResponse> => {
if (!shakespeareProvider || !user) {
throw new Error('No provider or user available');
}
const ai = createAIClient(shakespeareProvider, user, config.corsProxy);
const response = await ai.post('/badges/sync', {}) as BadgeSyncResponse;
// If any badges were synced, invalidate the badge awards query
if (response.synced.length > 0) {
queryClient.invalidateQueries({ queryKey: ['badge-awards', BADGE_ISSUER_PUBKEY, userPubkey] });
}
return response;
},
enabled: !!user && !!shakespeareProvider,
staleTime: 0, // Always refetch on mount for fresh progress
gcTime: 5 * 60 * 1000, // Keep in cache for 5 min
retry: 1,
});
// Get stats from sync response
const stats = syncData?.stats;
// Get milestones from server (no fallbacks - if server doesn't provide, use empty arrays)
const tokenMilestones = useMemo((): TokenMilestone[] => {
return syncData?.milestones?.tokenMilestones || [];
}, [syncData?.milestones]);
const imageMilestones = useMemo(() => {
return syncData?.milestones?.imageMilestones.map(m => m.count) || [];
}, [syncData?.milestones]);
// Get credit milestones (thresholds with credit rewards)
const creditMilestones = useMemo(() => {
return syncData?.milestones?.tokenMilestones
.filter(m => m.creditReward !== undefined)
.map(m => m.threshold) || [];
}, [syncData?.milestones]);
const tokenProgress = stats
? getTokenMilestoneProgress(stats.generation_count, stats.total_tokens, tokenMilestones)
: null;
const imageProgress = stats
? getImageMilestoneProgress(stats.image_count, imageMilestones)
: null;
const { data: badgeDefinitions, isLoading: isLoadingDefinitions } = useQuery({
queryKey: ['badge-definitions', BADGE_ISSUER_PUBKEY],
queryFn: async (c) => {
const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
const events = await nostr.query([{
kinds: [30009],
authors: [BADGE_ISSUER_PUBKEY],
limit: 100,
}], { signal });
return events;
},
});
// Query for badge awards if user is logged in
const { data: badgeAwards, isLoading: isLoadingAwards } = useQuery({
queryKey: ['badge-awards', BADGE_ISSUER_PUBKEY, userPubkey],
queryFn: async (c) => {
if (!userPubkey) return [];
const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
const events = await nostr.query([{
kinds: [8],
authors: [BADGE_ISSUER_PUBKEY],
"#p": [userPubkey],
limit: 100,
}], { signal });
return events;
},
enabled: !!userPubkey,
});
// Create a map of awarded badges (a-tag -> first award date)
const awardedBadges = new Map<string, number>();
if (badgeAwards) {
for (const award of badgeAwards) {
const aTag = award.tags.find(([t]) => t === "a")?.[1];
if (aTag) {
// Store the earliest award date for this badge
const existingDate = awardedBadges.get(aTag);
if (!existingDate || award.created_at < existingDate) {
awardedBadges.set(aTag, award.created_at);
}
}
}
}
// Helper to check if a badge is awarded
const isBadgeAwarded = (badgeDefinition: NostrEvent): boolean => {
if (!userPubkey) return false;
const dTag = badgeDefinition.tags.find(([t]) => t === "d")?.[1];
if (!dTag) return false;
const aTag = `30009:${BADGE_ISSUER_PUBKEY}:${dTag}`;
return awardedBadges.has(aTag);
};
// Helper to get first award date for a badge
const getFirstAwardDate = (badgeDefinition: NostrEvent): number | null => {
if (!userPubkey) return null;
const dTag = badgeDefinition.tags.find(([t]) => t === "d")?.[1];
if (!dTag) return null;
const aTag = `30009:${BADGE_ISSUER_PUBKEY}:${dTag}`;
return awardedBadges.get(aTag) || null;
};
// Sort badges: unlocked by first award date (earliest first), then locked badges
const sortedBadgeDefinitions = badgeDefinitions ? [...badgeDefinitions].sort((a, b) => {
const aAwarded = isBadgeAwarded(a);
const bAwarded = isBadgeAwarded(b);
// If both are awarded, sort by first award date (earliest first)
if (aAwarded && bAwarded) {
const aDate = getFirstAwardDate(a) || 0;
const bDate = getFirstAwardDate(b) || 0;
return aDate - bDate;
}
// If only one is awarded, awarded comes first
if (aAwarded && !bAwarded) return -1;
if (!aAwarded && bAwarded) return 1;
// Both are locked, maintain original order
return 0;
}) : [];
const isLoading = isLoadingDefinitions || (userPubkey && isLoadingAwards);
// Calculate badge counts
const totalBadges = sortedBadgeDefinitions.length;
const unlockedBadges = sortedBadgeDefinitions.filter(badge => isBadgeAwarded(badge)).length;
const progressPercentage = totalBadges > 0 ? (unlockedBadges / totalBadges) * 100 : 0;
return (
<SettingsPageLayout
icon={Award}
titleKey="badges"
descriptionKey="badgesDescription"
titleSuffix={
!isLoading && totalBadges > 0 ? (
<div className="flex flex-wrap items-center gap-3 ml-3">
<Card className="bg-muted/50 border">
<CardContent className="py-1.5 px-4">
<p className="text-sm font-medium">
<span className="text-foreground">{unlockedBadges}</span>
<span className="text-muted-foreground"> / </span>
<span className="text-foreground">{totalBadges}</span>
<span className="text-muted-foreground"> unlocked</span>
</p>
</CardContent>
</Card>
<Card className="bg-muted/50 border">
<CardContent className="py-1.5 px-4">
<div className="flex items-center gap-2">
<Progress value={progressPercentage} className="h-1.5 w-24" />
<span className="text-sm font-medium">{Math.round(progressPercentage)}%</span>
</div>
</CardContent>
</Card>
</div>
) : undefined
}
>
<BadgeAwardModal
badgeDefinition={selectedBadge}
onClose={() => setSelectedBadge(null)}
/>
{/* Progress Tracking Section */}
{stats && (() => {
type ProgressItem =
| { category: 'token'; progress: TokenProgressResult }
| { category: 'image'; progress: { progress: number; current: number; next: number } };
const progressItems: ProgressItem[] = [];
if (tokenProgress) {
progressItems.push({ category: 'token', progress: tokenProgress });
}
if (imageProgress) {
progressItems.push({ category: 'image', progress: imageProgress });
}
if (progressItems.length === 0) return null;
const currentIndex = progressIndex % progressItems.length;
const current = progressItems[currentIndex];
// Format progress display based on milestone type
const formatProgress = () => {
if (current.category === 'token') {
const tokenProg = current.progress as TokenProgressResult;
const next = tokenProg.next ?? 0;
// For generation-based milestones, show simple numbers
if (tokenProg.type === 'generation') {
return `${tokenProg.current} / ${next}`;
}
// For token-based milestones, format large numbers
return `${formatNumber(tokenProg.current)} / ${formatNumber(next)}`;
}
// Image progress - simple numbers
return `${current.progress.current} / ${current.progress.next}`;
};
return (
<Card
className="mb-6 cursor-pointer hover:bg-muted/50 transition-colors"
onClick={() => setProgressIndex(prev => prev + 1)}
>
<CardContent className="py-4">
<div className="space-y-2">
<div className="flex justify-between items-center">
<span className="text-sm font-medium">
{current.category === 'token' ? t('tokenProgress') : t('imageProgress')}
</span>
<div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground">
{formatProgress()}
</span>
{current.category === 'token' && current.progress.next && isCreditMilestone(current.progress.next, creditMilestones) && (() => {
const milestone = syncData?.milestones?.tokenMilestones.find(m => m.threshold === current.progress.next);
const creditAmount = milestone?.creditReward ?? 0;
// Only show badge if credit amount is greater than 0
if (creditAmount <= 0) return null;
return (
<Badge variant="default" className="text-xs">
${creditAmount} Credit
</Badge>
);
})()}
</div>
</div>
<Progress value={current.progress.progress} className="h-2" />
<div className="flex justify-between items-center">
<p className="text-xs text-muted-foreground">
{t('nextBadgeAt', { milestone: formatNumber(current.progress.next ?? 0) })}
</p>
{progressItems.length > 1 && (
<div className="flex gap-1">
{progressItems.map((_, i) => (
<div
key={i}
className={cn(
"w-1.5 h-1.5 rounded-full transition-colors",
i === currentIndex ? "bg-primary" : "bg-muted-foreground/30"
)}
/>
))}
</div>
)}
</div>
</div>
</CardContent>
</Card>
);
})()}
<div className="space-y-4">
{isLoading ? (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{[1, 2, 3].map((i) => (
<Card key={i}>
<CardHeader className="text-center space-y-4">
<div className="flex justify-center">
<Skeleton className="w-32 h-32 rounded-lg" />
</div>
<div className="space-y-2">
<Skeleton className="h-5 w-32 mx-auto" />
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-3/4 mx-auto" />
</div>
</CardHeader>
</Card>
))}
</div>
) : sortedBadgeDefinitions && sortedBadgeDefinitions.length > 0 ? (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{sortedBadgeDefinitions.map((event) => (
<BadgeCard
key={event.id}
event={event}
awarded={isBadgeAwarded(event)}
unlockDate={getFirstAwardDate(event)}
onClick={isBadgeAwarded(event) ? () => setSelectedBadge(event) : undefined}
/>
))}
</div>
) : (
<Card>
<CardContent className="py-12 px-8 text-center">
<div className="max-w-sm mx-auto space-y-4">
<Award className="h-12 w-12 mx-auto text-muted-foreground" />
<p className="text-muted-foreground">
{t('noBadgesFound')}
</p>
</div>
</CardContent>
</Card>
)}
</div>
</SettingsPageLayout>
);
}
export default BadgesSettings;
+197 -97
View File
@@ -31,6 +31,9 @@ import { useGitAutosync } from '@/hooks/useGitAutosync';
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from '@tanstack/react-query';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus'; import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { FloatingChatWidget } from '@/components/Shakespeare/FloatingChatWidget';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
export function ProjectView() { export function ProjectView() {
const { projectId } = useParams<{ projectId: string }>(); const { projectId } = useParams<{ projectId: string }>();
@@ -59,6 +62,16 @@ export function ProjectView() {
const [isSidebarVisible, setIsSidebarVisible] = useState(!isMobile); const [isSidebarVisible, setIsSidebarVisible] = useState(!isMobile);
// Floating chat state
const [isFloatingChatEnabled, setIsFloatingChatEnabled] = useLocalStorage(
'shk:floatingChatEnabled',
false
);
const [isFloatingChatMinimized, setIsFloatingChatMinimized] = useLocalStorage(
'shk:floatingChatMinimized',
false
);
const build = useBuildProject(projectId!); const build = useBuildProject(projectId!);
const { data: isPreviewable = false } = useIsProjectPreviewable(projectId!); const { data: isPreviewable = false } = useIsProjectPreviewable(projectId!);
const { hasRunningSessions } = useProjectSessionStatus(projectId || ''); const { hasRunningSessions } = useProjectSessionStatus(projectId || '');
@@ -227,7 +240,7 @@ export function ProjectView() {
</div> </div>
</div> </div>
<div className="flex items-center gap-4 px-3"> <div className="flex items-center gap-2 px-3">
{project ? ( {project ? (
<> <>
<GitSyncButton <GitSyncButton
@@ -239,6 +252,24 @@ export function ProjectView() {
projectName={project.name} projectName={project.name}
disabled={isAnyLoading} disabled={isAnyLoading}
/> />
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
className="h-8 w-8"
onClick={() => {
setIsFloatingChatEnabled(true);
setIsFloatingChatMinimized(false);
}}
aria-label="Floating chat"
aria-pressed={isFloatingChatEnabled}
>
<MessageSquare className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent>Floating chat</TooltipContent>
</Tooltip>
</> </>
) : ( ) : (
<> <>
@@ -389,6 +420,23 @@ export function ProjectView() {
/> />
</> </>
)} )}
{/* Floating Chat Widget - Mobile */}
{isFloatingChatEnabled && project && (
<FloatingChatWidget
projectId={project.id}
isMinimized={isFloatingChatMinimized}
onToggleMinimize={() => setIsFloatingChatMinimized(!isFloatingChatMinimized)}
onClose={() => setIsFloatingChatEnabled(false)}
onNewChat={handleNewChat}
onFirstInteraction={handleFirstInteraction}
onLoadingChange={handleAILoadingChange}
isLoading={isAILoading}
isBuildLoading={build.isPending}
consoleError={consoleError}
onDismissConsoleError={handleDismissConsoleError}
/>
)}
</div> </div>
); );
} }
@@ -415,123 +463,175 @@ export function ProjectView() {
{/* Main Content Area */} {/* Main Content Area */}
<div className="flex-1 flex flex-col overflow-hidden bg-background"> <div className="flex-1 flex flex-col overflow-hidden bg-background">
<div className="flex-1 overflow-hidden"> <div className="flex-1 overflow-hidden">
<ResizablePanelGroup direction="horizontal" className="h-full"> {isFloatingChatEnabled ? (
{/* Chat Panel */} // Full-width preview/code when floating chat is enabled
<ResizablePanel defaultSize={35} minSize={25}> <div className="h-full">
<div className="h-full flex flex-col"> {project ? (
{/* Chat Header */} <PreviewPane
<div className="h-12 px-4 border-b flex-shrink-0"> projectId={project.id}
<div className="flex items-center justify-between h-12"> activeTab={isPreviewable ? activeTab : 'code'}
{/* Left side - Sidebar toggle (when collapsed) */} onToggleView={isPreviewable ? () => setActiveTab(activeTab === 'preview' ? 'code' : 'preview') : undefined}
<div className="flex items-center gap-3 overflow-hidden"> isPreviewable={isPreviewable}
{!isSidebarVisible && ( />
<Button ) : (
variant="ghost" <div className="h-full p-4 space-y-4">
size="sm" <Skeleton className="h-8 w-32" />
onClick={() => setIsSidebarVisible(true)} <Skeleton className="h-full w-full" />
className="h-8 w-8 p-0" </div>
aria-label="Open sidebar" )}
> </div>
<Menu className="h-4 w-4" /> ) : (
</Button> // Original resizable panel layout
)} <ResizablePanelGroup direction="horizontal" className="h-full">
{/* Chat Panel */}
<ResizablePanel defaultSize={35} minSize={25}>
<div className="h-full flex flex-col">
{/* Chat Header */}
<div className="h-12 px-4 border-b flex-shrink-0">
<div className="flex items-center justify-between h-12">
{/* Left side - Sidebar toggle (when collapsed) */}
<div className="flex items-center gap-3 overflow-hidden">
{!isSidebarVisible && (
<Button
variant="ghost"
size="sm"
onClick={() => setIsSidebarVisible(true)}
className="h-8 w-8 p-0"
aria-label="Open sidebar"
>
<Menu className="h-4 w-4" />
</Button>
)}
{/* Project title */} {/* Project title */}
<div className="flex flex-1 min-w-0 truncate"> <div className="flex flex-1 min-w-0 truncate">
{project ? (
<ProjectTitleMenu
projectId={project.id}
projectName={project.name}
onNewChat={handleNewChat}
onGitHistory={() => setGitHistoryOpen(true)}
onDuplicate={() => setDuplicateDialogOpen(true)}
onDelete={() => setDeleteDialogOpen(true)}
onProjectDetails={() => setIsProjectDetailsOpen(true)}
isAILoading={isAILoading}
isAnyLoading={isAnyLoading || isDeleting}
className="text-lg"
/>
) : (
<Skeleton className="h-6 w-40" />
)}
</div>
</div>
{/* Right side - Deploy and Sync buttons */}
<div className="flex items-center gap-2">
{project ? ( {project ? (
<ProjectTitleMenu <>
projectId={project.id} <GitSyncButton
projectName={project.name} projectId={project.id}
onNewChat={handleNewChat} className="h-8 w-8"
onGitHistory={() => setGitHistoryOpen(true)} />
onDuplicate={() => setDuplicateDialogOpen(true)} <DeployButton
onDelete={() => setDeleteDialogOpen(true)} projectId={project.id}
onProjectDetails={() => setIsProjectDetailsOpen(true)} projectName={project.name}
isAILoading={isAILoading} disabled={isAnyLoading}
isAnyLoading={isAnyLoading || isDeleting} />
className="text-lg" <Tooltip>
/> <TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
className="h-8 w-8"
onClick={() => setIsFloatingChatEnabled(true)}
aria-label="Floating chat"
aria-pressed={isFloatingChatEnabled}
>
<MessageSquare className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent>Floating chat</TooltipContent>
</Tooltip>
</>
) : ( ) : (
<Skeleton className="h-6 w-40" /> <>
<Skeleton className="h-8 w-8 rounded" />
<Skeleton className="h-8 w-8 rounded" />
</>
)} )}
</div> </div>
</div> </div>
</div>
{/* Right side - Deploy and Sync buttons */} {/* Chat Content */}
<div className="flex items-center gap-2"> <div className="flex-1 overflow-hidden">
{project ? ( {project ? (
<> <ChatPane
<GitSyncButton ref={chatPaneRef}
projectId={project.id} projectId={project.id}
className="h-8 w-8" onNewChat={handleNewChat}
/> onFirstInteraction={handleFirstInteraction}
<DeployButton onLoadingChange={handleAILoadingChange}
projectId={project.id} isLoading={isAILoading}
projectName={project.name} isBuildLoading={build.isPending}
disabled={isAnyLoading} consoleError={consoleError}
/> onDismissConsoleError={handleDismissConsoleError}
</> />
) : ( ) : (
<> <div className="h-full p-4 space-y-4">
<Skeleton className="h-8 w-8 rounded" /> <Skeleton className="h-12 w-full" />
<Skeleton className="h-8 w-8 rounded" /> <Skeleton className="h-8 w-3/4" />
</> <Skeleton className="h-8 w-1/2" />
)} <Skeleton className="h-32 w-full" />
</div> </div>
)}
</div> </div>
</div> </div>
</ResizablePanel>
{/* Chat Content */} {/* Resizable Handle */}
<div className="flex-1 overflow-hidden"> <ResizableHandle withHandle />
{/* Preview/Code Panel */}
<ResizablePanel defaultSize={65} minSize={30}>
<div className="h-full">
{project ? ( {project ? (
<ChatPane <PreviewPane
ref={chatPaneRef}
projectId={project.id} projectId={project.id}
onNewChat={handleNewChat} activeTab={isPreviewable ? activeTab : 'code'}
onFirstInteraction={handleFirstInteraction} onToggleView={isPreviewable ? () => setActiveTab(activeTab === 'preview' ? 'code' : 'preview') : undefined}
onLoadingChange={handleAILoadingChange} isPreviewable={isPreviewable}
isLoading={isAILoading}
isBuildLoading={build.isPending}
consoleError={consoleError}
onDismissConsoleError={handleDismissConsoleError}
/> />
) : ( ) : (
<div className="h-full p-4 space-y-4"> <div className="h-full p-4 space-y-4">
<Skeleton className="h-12 w-full" /> <Skeleton className="h-8 w-32" />
<Skeleton className="h-8 w-3/4" /> <Skeleton className="h-full w-full" />
<Skeleton className="h-8 w-1/2" />
<Skeleton className="h-32 w-full" />
</div> </div>
)} )}
</div> </div>
</div> </ResizablePanel>
</ResizablePanel> </ResizablePanelGroup>
)}
{/* Resizable Handle */}
<ResizableHandle withHandle />
{/* Preview/Code Panel */}
<ResizablePanel defaultSize={65} minSize={30}>
<div className="h-full">
{project ? (
<PreviewPane
projectId={project.id}
activeTab={isPreviewable ? activeTab : 'code'}
onToggleView={isPreviewable ? () => setActiveTab(activeTab === 'preview' ? 'code' : 'preview') : undefined}
isPreviewable={isPreviewable}
/>
) : (
<div className="h-full p-4 space-y-4">
<Skeleton className="h-8 w-32" />
<Skeleton className="h-full w-full" />
</div>
)}
</div>
</ResizablePanel>
</ResizablePanelGroup>
</div> </div>
</div> </div>
{/* Floating Chat Widget - Desktop */}
{isFloatingChatEnabled && project && (
<FloatingChatWidget
projectId={project.id}
isMinimized={isFloatingChatMinimized}
onToggleMinimize={() => setIsFloatingChatMinimized(!isFloatingChatMinimized)}
onClose={() => setIsFloatingChatEnabled(false)}
onNewChat={handleNewChat}
onFirstInteraction={handleFirstInteraction}
onLoadingChange={handleAILoadingChange}
isLoading={isAILoading}
isBuildLoading={build.isPending}
consoleError={consoleError}
onDismissConsoleError={handleDismissConsoleError}
/>
)}
{/* Dialogs */} {/* Dialogs */}
{project && ( {project && (
<> <>
+1 -1
View File
@@ -29,7 +29,7 @@ export default defineConfig(() => ({
plugins: [ plugins: [
react(), react(),
VitePWA({ VitePWA({
includeAssets: ['shakespeare.svg', 'shakespeare-192x192.png', 'shakespeare-512x512.png', 'sine.mp3', 'badgeAwarded.mp3'], includeAssets: ['shakespeare.svg', 'shakespeare-192x192.png', 'shakespeare-512x512.png', 'sine.mp3'],
manifest: false, // Use existing manifest.webmanifest from public folder manifest: false, // Use existing manifest.webmanifest from public folder
workbox: { workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,wasm,mp3}'], globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,wasm,mp3}'],