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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hyperdrive/packages/app-store/app-store/src/http_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn make_widget() -> String {
<h3>Top Apps</h3>
<div id="latest-apps"></div>
<script>

class HWProtocolWatcher {
constructor() {
this.isListening = false;
Expand Down Expand Up @@ -245,7 +245,7 @@ if (typeof document !== 'undefined') {
}
}




</script>
Expand Down Expand Up @@ -394,7 +394,7 @@ fn serve_public_ui(http_server: &mut server::HttpServer) {
http_server
.serve_ui(
"public-ui",
vec!["/public"],
vec!["/public", "/public/app", "/public/app/:id"],
server::HttpBindingConfig::default().authenticated(false),
)
.expect("failed to serve static public UI");
Expand Down
22 changes: 19 additions & 3 deletions hyperdrive/packages/app-store/public-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,28 @@ const BASE_URL = import.meta.env.BASE_URL;
if (window.our) window.our.process = BASE_URL?.replace("/", "");

function App() {
const trimmedBase =
!BASE_URL || BASE_URL === "/"
? ""
: BASE_URL.endsWith("/")
? BASE_URL.slice(0, -1)
: BASE_URL;
const normalizedBase =
trimmedBase.length === 0
? "/"
: trimmedBase.startsWith("/")
? trimmedBase
: `/${trimmedBase}`;

const getBasename = () => {
const path = window.location.pathname;
if (path.startsWith('/main:app-store:sys/public')) {
return '/main:app-store:sys/public';
if (
normalizedBase !== "/" &&
path.startsWith(normalizedBase)
) {
return normalizedBase;
}
return '/';
return "/";
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,30 @@ export default function AppDetail() {
}
}, [backtickPressCount]);

const derivedId = React.useMemo(() => {
if (id) return id;
const match = window.location.pathname.match(/\/app\/([^/?#]+)/);
if (match && match[1]) {
return decodeURIComponent(match[1]);
}
return undefined;
}, [id]);

useEffect(() => {
const loadApp = async () => {
if (!id) return;
if (!derivedId) {
setIsLoading(false);
return;
}
setIsLoading(true);
setError(null);

try {
if (isDevMode) {
setApp(mockApp);
} else {
const response = await fetch(`/main:app-store:sys/apps-public/${id}`);
const encodedId = encodeURIComponent(derivedId).replace(/%3A/g, ":");
const response = await fetch(`/main:app-store:sys/apps-public/${encodedId}`);
if (!response.ok) {
throw new Error('Failed to fetch app details');
}
Expand All @@ -81,7 +94,7 @@ export default function AppDetail() {

loadApp();
window.scrollTo(0, 0);
}, [id, isDevMode]);
}, [derivedId, isDevMode]);

if (isLoading) {
return (
Expand All @@ -102,7 +115,7 @@ export default function AppDetail() {
if (!app) {
return (
<div className="max-w-screen md:max-w-screen-md mx-auto flex flex-col items-center justify-center min-h-96">
<div>App details not found for {id}</div>
<div>App details not found for {derivedId ?? "unknown app"}</div>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-packages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
anyhow = "1.0.71"
clap = "4"
fs-err = "2.11"
kit = { git = "https://github.com/hyperware-ai/kit", rev = "275f02c" }
kit = { git = "https://github.com/hyperware-ai/kit", rev = "0d0469e" }
rayon = "1.8"
serde = "1"
serde_json = "1"
Expand Down