@hanzo/app 0.3.60 → 0.3.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Hosted.js CHANGED
@@ -101,9 +101,10 @@ function Frame({ app }) {
101
101
  const [turn, setTurn] = useState(0);
102
102
  const [state, setState] = useState('loading');
103
103
  const host = origin(app);
104
+ const target = () => frame.current ?? (typeof document !== 'undefined' ? document.querySelector('iframe[data-slot="hosted-frame"]') : null);
104
105
  // What the frame is told: each time it loads, when it announces ready, and whenever the look or the organization changes after.
105
106
  const tell = useCallback(() => {
106
- const to = frame.current?.contentWindow;
107
+ const to = target()?.contentWindow;
107
108
  if (!to)
108
109
  return;
109
110
  const token = bearer();
@@ -130,7 +131,7 @@ function Frame({ app }) {
130
131
  // What the frame says: heard from its host and from it alone.
131
132
  useEffect(() => {
132
133
  const hear = (e) => {
133
- if (e.origin !== host || e.source !== frame.current?.contentWindow)
134
+ if (e.origin !== host || e.source !== target()?.contentWindow)
134
135
  return;
135
136
  const said = e.data;
136
137
  if (said?.type === 'hanzo:ready') {
@@ -147,7 +148,7 @@ function Frame({ app }) {
147
148
  };
148
149
  window.addEventListener('message', hear);
149
150
  return () => window.removeEventListener('message', hear);
150
- }, [app, host]);
151
+ }, [app, host, tell]);
151
152
  // A frame that never loads is said not to have.
152
153
  useEffect(() => {
153
154
  if (state !== 'loading')
@@ -162,5 +163,5 @@ function Frame({ app }) {
162
163
  };
163
164
  const tab = () => out(at.current ? `${host}${at.current}` : app.href);
164
165
  const Icon = app.icon;
165
- return (_jsxs(YStack, { flex: 1, minH: 0, "data-slot": "hosted", "data-app": app.id, children: [_jsxs(XStack, { items: "center", gap: "$2", px: "$3", height: 36, shrink: 0, borderBottomWidth: 1, borderColor: "$borderColor", "data-slot": "hosted-bar", children: [_jsx(Icon, { size: 14, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$color12", children: app.name }), _jsx(Text, { fontSize: "$2", color: "$color10", numberOfLines: 1, flex: 1, minW: 0, children: app.host }), _jsx(Button, { size: "sm", variant: "ghost", rounded: 999, "aria-label": t('Reload'), onPress: reload, "data-slot": "hosted-reload", children: _jsx(RotateCw, { size: 14, "aria-hidden": true }) }), _jsx(Button, { size: "sm", variant: "ghost", rounded: 999, "aria-label": t('Open in a tab'), onPress: tab, "data-slot": "hosted-tab", children: _jsx(ExternalLink, { size: 14, "aria-hidden": true }) })] }), _jsxs(YStack, { flex: 1, minH: 0, position: "relative", children: [_jsx(View, { flex: 1, width: "100%", height: "100%", borderWidth: 0, bg: "transparent", render: _jsx("iframe", { ref: frame, src: src, title: app.name, allow: ALLOW, referrerPolicy: "strict-origin-when-cross-origin", "data-slot": "hosted-frame", onLoad: loaded }, turn) }), state === 'loading' ? (_jsx(YStack, { position: "absolute", t: 0, l: 0, r: 0, b: 0, items: "center", justify: "center", pointerEvents: "none", "data-slot": "hosted-loading", children: _jsx(Spinner, { size: 28, color: "$color10" }) })) : null, state === 'failed' ? (_jsxs(YStack, { position: "absolute", t: 0, l: 0, r: 0, b: 0, items: "center", justify: "center", gap: "$3", bg: "$background", "data-slot": "hosted-failed", children: [_jsx(Text, { fontSize: "$3", color: "$color11", children: t('{name} did not open here.', { name: app.name }) }), _jsx(Button, { size: "sm", rounded: 999, onPress: tab, children: t('Open in a tab') })] })) : null] })] }));
166
+ return (_jsxs(YStack, { flex: 1, minH: 0, "data-slot": "hosted", "data-app": app.id, children: [_jsxs(XStack, { items: "center", gap: "$2", px: "$3", height: 36, shrink: 0, borderBottomWidth: 1, borderColor: "$borderColor", "data-slot": "hosted-bar", children: [_jsx(Icon, { size: 14, "aria-hidden": true }), _jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$color12", children: app.name }), _jsx(Text, { fontSize: "$2", color: "$color10", numberOfLines: 1, flex: 1, minW: 0, children: app.host }), _jsx(Button, { size: "sm", variant: "ghost", rounded: 999, "aria-label": t('Reload'), onPress: reload, "data-slot": "hosted-reload", children: _jsx(RotateCw, { size: 14, "aria-hidden": true }) }), _jsx(Button, { size: "sm", variant: "ghost", rounded: 999, "aria-label": t('Open in a tab'), onPress: tab, "data-slot": "hosted-tab", children: _jsx(ExternalLink, { size: 14, "aria-hidden": true }) })] }), _jsxs(YStack, { flex: 1, minH: 0, position: "relative", children: [_jsx(View, { ref: frame, flex: 1, width: "100%", height: "100%", borderWidth: 0, bg: "transparent", render: _jsx("iframe", { ref: frame, src: src, title: app.name, allow: ALLOW, referrerPolicy: "strict-origin-when-cross-origin", "data-slot": "hosted-frame", onLoad: loaded }, turn) }), state === 'loading' ? (_jsx(YStack, { position: "absolute", t: 0, l: 0, r: 0, b: 0, items: "center", justify: "center", pointerEvents: "none", "data-slot": "hosted-loading", children: _jsx(Spinner, { size: 28, color: "$color10" }) })) : null, state === 'failed' ? (_jsxs(YStack, { position: "absolute", t: 0, l: 0, r: 0, b: 0, items: "center", justify: "center", gap: "$3", bg: "$background", "data-slot": "hosted-failed", children: [_jsx(Text, { fontSize: "$3", color: "$color11", children: t('{name} did not open here.', { name: app.name }) }), _jsx(Button, { size: "sm", rounded: 999, onPress: tab, children: t('Open in a tab') })] })) : null] })] }));
166
167
  }
package/dist/Sidebar.js CHANGED
@@ -36,6 +36,7 @@ import { Button, DropdownMenu, Switch } from '@hanzo/ui';
36
36
  import { Sidebar as Base, SidebarIconButton, SidebarItem, StatusDot } from '@hanzo/ui/chat';
37
37
  import { useEffect, useId, useMemo, useState } from 'react';
38
38
  import { Made } from './Account.js';
39
+ import { useBetas } from './Betas.js';
39
40
  import { Recents } from './Recents.js';
40
41
  import { MARK, raised } from './Rail.js';
41
42
  import { Setup } from './Setup.js';
@@ -43,7 +44,8 @@ import { ago, UNTITLED_RUN } from './recent.js';
43
44
  import { empty } from './open.js';
44
45
  import { useSpan } from './span.js';
45
46
  import { useFree } from './Upgrade.js';
46
- import { talk } from './lib/host.js';
47
+ import { hosted, talk } from './lib/host.js';
48
+ import { HOSTED_APPS } from './lib/hosted.js';
47
49
  import { payUrl } from './lib/pay.js';
48
50
  import { brand, wordmark } from './where.js';
49
51
  import { dragWindow, toggleWindowMaximize } from './WindowControls.js';
@@ -161,8 +163,9 @@ function useTabsGroups(t, active) {
161
163
  onPress: () => dispatchTabsAction({ kind: 'cloud' }),
162
164
  },
163
165
  ];
164
- const sandboxLinks = fleet.length > 0
165
- ? fleet.map((h) => ({
166
+ const liveFleet = fleet.filter((h) => h.status !== 'offline');
167
+ const sandboxLinks = liveFleet.length > 0
168
+ ? liveFleet.map((h) => ({
166
169
  id: `sandbox-${h.machine}`,
167
170
  label: h.label ? `${h.machine} · ${h.label}` : h.machine,
168
171
  icon: h.desktop ? _jsx(Monitor, { size: 16, "aria-hidden": true }) : _jsx(Cloud, { size: 16, "aria-hidden": true }),
@@ -176,7 +179,20 @@ function useTabsGroups(t, active) {
176
179
  onPress: () => dispatchTabsAction({ kind: 'cloud' }),
177
180
  },
178
181
  ];
179
- const recentLinks = Object.entries(bind).map(([id, b]) => {
182
+ const knownMachines = fleet.length > 0 ? new Set(liveFleet.map((h) => h.machine)) : null;
183
+ const recentLinks = Object.entries(bind)
184
+ .filter(([, b]) => {
185
+ if (b.kind === 'page')
186
+ return Boolean(b.url);
187
+ if (b.kind === 'screen')
188
+ return Boolean(b.machine) && (!knownMachines || knownMachines.has(b.machine));
189
+ if (b.kind === 'shell') {
190
+ const m = b.shell?.machine ?? b.machine;
191
+ return Boolean(m) && (!knownMachines || knownMachines.has(m));
192
+ }
193
+ return false;
194
+ })
195
+ .map(([id, b]) => {
180
196
  if (b.kind === 'screen') {
181
197
  return {
182
198
  id: `tab-${id}`,
@@ -280,16 +296,38 @@ export function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer
280
296
  // Each place the rail holds lists its own rows: Library its kinds and Upload, Scheduled tasks its tasks and New task.
281
297
  const scheduled = useScheduled(host, dev, at === 'scheduled');
282
298
  const tabsGroups = useTabsGroups(t, mode === 'tabs');
283
- const groups = places ??
284
- (mode === 'tabs'
285
- ? tabsGroups
286
- : at === 'customize'
287
- ? tabs(host, dev, t)
288
- : at === 'library'
289
- ? library(host, dev, t)
290
- : at === 'scheduled'
291
- ? scheduled
292
- : own(host, dev, t));
299
+ const { open: betaOpen } = useBetas();
300
+ const hostedGroups = useMemo(() => {
301
+ if (mode !== 'hosted')
302
+ return [];
303
+ const path = typeof window !== 'undefined' ? window.location.pathname : host.path;
304
+ const links = HOSTED_APPS.filter((a) => betaOpen(a.id)).map((a) => {
305
+ const href = hosted(a.id);
306
+ const active = path === href || path.startsWith(`${href}/`);
307
+ return {
308
+ id: `app-${a.id}`,
309
+ label: a.name,
310
+ active,
311
+ icon: _jsx(a.icon, { size: 16, "aria-hidden": true }),
312
+ onPress: () => go(href),
313
+ };
314
+ });
315
+ return links.length > 0 ? [{ id: 'hosted-apps', label: '', links }] : [];
316
+ }, [mode, betaOpen, host.path, go]);
317
+ const groups = places && places.length > 0
318
+ ? places
319
+ : mode === 'hosted'
320
+ ? hostedGroups
321
+ : places ??
322
+ (mode === 'tabs'
323
+ ? tabsGroups
324
+ : at === 'customize'
325
+ ? tabs(host, dev, t)
326
+ : at === 'library'
327
+ ? library(host, dev, t)
328
+ : at === 'scheduled'
329
+ ? scheduled
330
+ : own(host, dev, t));
293
331
  const open = (row) => (row.kind === 'chat' ? go(talk(row.id)) : dev(row.id));
294
332
  const setAnonSettings = (next) => {
295
333
  setAnonSettingsOpen(next);
@@ -347,7 +385,7 @@ export function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer
347
385
  if (typeof window !== 'undefined') {
348
386
  window.dispatchEvent(new CustomEvent('hanzo:anon-plugins'));
349
387
  }
350
- }), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Plugins') }) }) })] })) : null] })) : mode === 'beta' && !drawer ? null : (_jsx(YStack, { "data-slot": "app-places", shrink: 0, pt: drawer ? 0 : 4, children: groups.map((g, i) => (_jsxs(YStack, { pt: i ? '$2' : 0, children: [i && g.label ? (_jsx(Text, { id: `${uid}-${g.id}`, paddingInlineStart: "$2", pb: 2, fontSize: "$3", color: "$soft", children: g.label })) : null, _jsx(YStack, { role: "list", "aria-labelledby": i && g.label ? `${uid}-${g.id}` : undefined, "aria-label": i && g.label ? undefined : g.label || (at ? t(TITLE[at]) : g.id), gap: 1, children: g.links.map((link) => (_jsx(YStack, { role: "listitem", self: "flex-start", children: _jsx(SidebarItem, { ...COMPACT_ROW, "data-place-id": link.id, ...(link.id === NEW ? { 'data-slot': 'app-new' } : {}), active: link.active, icon: link.icon || link.id === NEW ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: link.icon ?? _jsx(Make, { size: 16, "aria-hidden": true }) })) : null, onPress: link.onPress, ...keys(() => link.onPress?.()), children: _jsx(Text, { fontSize: "$3", color: link.active ? '$ink' : '$quiet', children: link.label }) }) }, link.id))) })] }, g.id))) })), rail, mode === 'beta' && !drawer ? (_jsx(YStack, { "data-slot": "beta-sidebar-slot", flex: 1, minH: 0, pt: 4 })) : anon && mode === 'chat' && anonThreadTitle ? (_jsxs(YStack, { "data-slot": "recents", flex: 1, minH: 0, pt: "$3", children: [_jsx(Text, { paddingInlineStart: "$2", pb: "$1", fontSize: "$3", color: "$soft", children: t('Recents') }), _jsx(YStack, { role: "list", gap: 1, children: _jsx(YStack, { role: "listitem", children: _jsx(SidebarItem, { ...ROW, active: !anonSettingsOpen, onPress: () => setAnonSettings(false), children: _jsx(Text, { fontSize: "$3", color: "$ink", numberOfLines: 1, children: anonThreadTitle }) }) }) })] })) : mode === 'hosted' || mode === 'beta' || anon || at ? (_jsx(YStack, { flex: 1, minH: 0 })) : (_jsx(Recents, { host: host, mode: mode === 'dev' ? 'dev' : 'chat', thread: thread, onOpen: open, onNew: create })), anon ? (_jsx(YStack, { "data-slot": "anon-foot", gap: "$2", pt: "$2", shrink: 0, z: 10, children: _jsxs(YStack, { "data-slot": "anon-tailored", gap: "$2", pt: "$1", pb: "$1", px: "$2", children: [_jsxs(XStack, { render: "button", "aria-expanded": tailoredOpen, "aria-label": t('Get responses tailored to you'), items: "center", justify: "space-between", gap: "$1.5", cursor: "pointer", onPress: () => setTailoredOpen((v) => !v), hoverStyle: { opacity: 0.85 }, children: [_jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "700", color: "$ink", numberOfLines: 1, flex: 1, children: t('Get responses tailored to you') }), tailoredOpen ? (_jsx(ChevronDown, { size: 14, "aria-hidden": true, color: "var(--soft, var(--muted-foreground))" })) : (_jsx(ChevronUp, { size: 14, "aria-hidden": true, color: "var(--soft, var(--muted-foreground))" }))] }), tailoredOpen ? (_jsx(Text, { fontSize: 12, lineHeight: 17, color: "$soft", children: t('Log in to get answers based on saved chats, plus create images and upload files.') })) : null, _jsxs(XStack, { gap: "$2", pt: "$0.5", children: [_jsx(Button, { size: "sm", variant: "outline", flex: 1, rounded: 9999, "data-slot": "column-login", onPress: () => {
388
+ }), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Plugins') }) }) })] })) : null] })) : mode === 'beta' && !drawer ? null : (_jsx(YStack, { "data-slot": "app-places", shrink: 0, pt: drawer ? 0 : 4, children: groups.map((g, i) => (_jsxs(YStack, { pt: i ? '$2' : 0, children: [i && g.label ? (_jsx(Text, { id: `${uid}-${g.id}`, paddingInlineStart: "$2", pb: 2, fontSize: "$3", color: "$soft", children: g.label })) : null, _jsx(YStack, { role: "list", "aria-labelledby": i && g.label ? `${uid}-${g.id}` : undefined, "aria-label": i && g.label ? undefined : g.label || (at ? t(TITLE[at]) : g.id), gap: 1, children: g.links.map((link) => (_jsx(YStack, { role: "listitem", self: "flex-start", maxW: "100%", minW: 0, children: _jsx(SidebarItem, { ...COMPACT_ROW, "data-place-id": link.id, ...(link.id === NEW ? { 'data-slot': 'app-new' } : {}), active: link.active, icon: link.icon || link.id === NEW ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: link.icon ?? _jsx(Make, { size: 16, "aria-hidden": true }) })) : null, onPress: link.onPress, ...keys(() => link.onPress?.()), children: _jsx(Text, { fontSize: "$3", color: link.active ? '$ink' : '$quiet', numberOfLines: 1, children: link.label }) }) }, link.id))) })] }, g.id))) })), rail, mode === 'beta' && !drawer ? (_jsx(YStack, { "data-slot": "beta-sidebar-slot", flex: 1, minH: 0, pt: 4 })) : anon && mode === 'chat' && anonThreadTitle ? (_jsxs(YStack, { "data-slot": "recents", flex: 1, minH: 0, pt: "$3", children: [_jsx(Text, { paddingInlineStart: "$2", pb: "$1", fontSize: "$3", color: "$soft", children: t('Recents') }), _jsx(YStack, { role: "list", gap: 1, children: _jsx(YStack, { role: "listitem", children: _jsx(SidebarItem, { ...ROW, active: !anonSettingsOpen, onPress: () => setAnonSettings(false), children: _jsx(Text, { fontSize: "$3", color: "$ink", numberOfLines: 1, children: anonThreadTitle }) }) }) })] })) : mode === 'hosted' || mode === 'beta' || mode === 'tabs' || anon || at ? (_jsx(YStack, { flex: 1, minH: 0 })) : (_jsx(Recents, { host: host, mode: mode === 'dev' ? 'dev' : 'chat', thread: thread, onOpen: open, onNew: create })), anon ? (_jsx(YStack, { "data-slot": "anon-foot", gap: "$2", pt: "$2", shrink: 0, z: 10, children: _jsxs(YStack, { "data-slot": "anon-tailored", gap: "$2", pt: "$1", pb: "$1", px: "$2", children: [_jsxs(XStack, { render: "button", "aria-expanded": tailoredOpen, "aria-label": t('Get responses tailored to you'), items: "center", justify: "space-between", gap: "$1.5", cursor: "pointer", onPress: () => setTailoredOpen((v) => !v), hoverStyle: { opacity: 0.85 }, children: [_jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: "700", color: "$ink", numberOfLines: 1, flex: 1, children: t('Get responses tailored to you') }), tailoredOpen ? (_jsx(ChevronDown, { size: 14, "aria-hidden": true, color: "var(--soft, var(--muted-foreground))" })) : (_jsx(ChevronUp, { size: 14, "aria-hidden": true, color: "var(--soft, var(--muted-foreground))" }))] }), tailoredOpen ? (_jsx(Text, { fontSize: 12, lineHeight: 17, color: "$soft", children: t('Log in to get answers based on saved chats, plus create images and upload files.') })) : null, _jsxs(XStack, { gap: "$2", pt: "$0.5", children: [_jsx(Button, { size: "sm", variant: "outline", flex: 1, rounded: 9999, "data-slot": "column-login", onPress: () => {
351
389
  if (typeof window !== 'undefined')
352
390
  window.location.assign('/login?next=%2Fchat');
353
391
  }, children: t('Log in') }), _jsx(Button, { size: "sm", flex: 1, rounded: 9999, "data-slot": "column-signup", onPress: () => {
package/dist/Terminals.js CHANGED
@@ -13,18 +13,21 @@ import { api } from './lib/api.js';
13
13
  import { bearer } from './lib/session.js';
14
14
  export default function Terminals() {
15
15
  const { t } = useI18n();
16
- const fleet = useFleet(bearer(), api());
16
+ const token = bearer();
17
+ const fleet = useFleet(token, api());
17
18
  useEffect(() => {
18
- if (typeof window === 'undefined')
19
+ if (typeof window === 'undefined' || !fleet.read)
19
20
  return;
20
21
  try {
21
- const lite = fleet.hosts.map((h) => ({ machine: h.machine, label: h.label, status: h.status, desktop: Boolean(h.screen) }));
22
+ const lite = fleet.hosts
23
+ .filter((h) => (h.base || h.sandbox) && h.status !== 'offline')
24
+ .map((h) => ({ machine: h.machine, label: h.label, status: h.status, desktop: Boolean(h.screen) }));
22
25
  window.localStorage.setItem('hanzo.tabs.fleet', JSON.stringify(lite));
23
26
  window.dispatchEvent(new CustomEvent('hanzo:tabs-fleet', { detail: lite }));
24
27
  }
25
28
  catch {
26
29
  // ignore storage errors
27
30
  }
28
- }, [fleet.hosts]);
29
- return (_jsxs(YStack, { "data-slot": "terminals", flex: 1, minH: 0, minW: 0, children: [fleet.error ? (_jsx(Text, { role: "alert", px: "$4", py: "$2", fontSize: "$2", color: "$soft", children: t('The machines could not be read: {error}', { error: fleet.error }) })) : null, _jsx(Workspace, { hosts: fleet.hosts, mint: fleet.mint, onLaunch: fleet.launch, agent: fleet.agent })] }));
31
+ }, [fleet.hosts, fleet.read]);
32
+ return (_jsxs(YStack, { "data-slot": "terminals", flex: 1, minH: 0, minW: 0, children: [fleet.error ? (_jsx(Text, { role: "alert", px: "$4", py: "$2", fontSize: "$2", color: "$soft", children: t('The machines could not be read: {error}', { error: fleet.error }) })) : null, fleet.read || fleet.error || !token ? (_jsx(Workspace, { hosts: fleet.hosts, mint: fleet.mint, onLaunch: fleet.launch, agent: fleet.agent })) : (_jsx(YStack, { flex: 1, items: "center", justify: "center", children: _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Reading your machines…') }) }))] }));
30
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.3.60",
3
+ "version": "0.3.62",
4
4
  "description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",