@hanzo/app 0.3.59 → 0.3.61
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.d.ts +2 -1
- package/dist/Hosted.js +7 -3
- package/dist/Sidebar.js +50 -13
- package/dist/Terminals.js +8 -5
- package/package.json +1 -1
package/dist/Hosted.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/** How long a frame may take to load before the pane says it did not. */
|
|
2
2
|
export declare const PATIENCE = 20000;
|
|
3
|
-
/** What the host tells a frame about how it looks. */
|
|
3
|
+
/** What the host tells a frame about how it looks and who is signed in. */
|
|
4
4
|
export interface Hostly {
|
|
5
5
|
type: 'hanzo:host';
|
|
6
6
|
theme: 'light' | 'dark';
|
|
7
7
|
accent?: string;
|
|
8
8
|
density?: string;
|
|
9
9
|
org?: string;
|
|
10
|
+
token?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare function HostedPane({ id, go }: {
|
|
12
13
|
id: string;
|
package/dist/Hosted.js
CHANGED
|
@@ -33,6 +33,7 @@ import { useOrg } from './host.js';
|
|
|
33
33
|
import { BETAS } from './lib/betas.js';
|
|
34
34
|
import { go as replace, hosted } from './lib/host.js';
|
|
35
35
|
import { frameUrl, hostedApp, origin, pathOn } from './lib/hosted.js';
|
|
36
|
+
import { bearer } from './lib/session.js';
|
|
36
37
|
/** How long a frame may take to load before the pane says it did not. */
|
|
37
38
|
export const PATIENCE = 20_000;
|
|
38
39
|
/** What the frame may use of the browser: the clipboard and full screen, which the apps' own pages ask for. */
|
|
@@ -100,12 +101,13 @@ function Frame({ app }) {
|
|
|
100
101
|
const [turn, setTurn] = useState(0);
|
|
101
102
|
const [state, setState] = useState('loading');
|
|
102
103
|
const host = origin(app);
|
|
103
|
-
// What the frame is told: each time it loads, and whenever the look or the organization changes after.
|
|
104
|
+
// What the frame is told: each time it loads, when it announces ready, and whenever the look or the organization changes after.
|
|
104
105
|
const tell = useCallback(() => {
|
|
105
106
|
const to = frame.current?.contentWindow;
|
|
106
107
|
if (!to)
|
|
107
108
|
return;
|
|
108
|
-
const
|
|
109
|
+
const token = bearer();
|
|
110
|
+
const said = { type: 'hanzo:host', ...looks, org: org.id, ...(token ? { token } : {}) };
|
|
109
111
|
try {
|
|
110
112
|
to.postMessage(said, host);
|
|
111
113
|
}
|
|
@@ -131,8 +133,10 @@ function Frame({ app }) {
|
|
|
131
133
|
if (e.origin !== host || e.source !== frame.current?.contentWindow)
|
|
132
134
|
return;
|
|
133
135
|
const said = e.data;
|
|
134
|
-
if (said?.type === 'hanzo:ready')
|
|
136
|
+
if (said?.type === 'hanzo:ready') {
|
|
135
137
|
setState('ready');
|
|
138
|
+
tell();
|
|
139
|
+
}
|
|
136
140
|
else if (said?.type === 'hanzo:navigate' && typeof said.href === 'string') {
|
|
137
141
|
const to = pathOn(app, said.href);
|
|
138
142
|
if (!to)
|
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';
|
|
@@ -176,7 +178,20 @@ function useTabsGroups(t, active) {
|
|
|
176
178
|
onPress: () => dispatchTabsAction({ kind: 'cloud' }),
|
|
177
179
|
},
|
|
178
180
|
];
|
|
179
|
-
const
|
|
181
|
+
const knownMachines = fleet.length > 0 ? new Set(fleet.map((h) => h.machine)) : null;
|
|
182
|
+
const recentLinks = Object.entries(bind)
|
|
183
|
+
.filter(([, b]) => {
|
|
184
|
+
if (b.kind === 'page')
|
|
185
|
+
return Boolean(b.url);
|
|
186
|
+
if (b.kind === 'screen')
|
|
187
|
+
return Boolean(b.machine) && (!knownMachines || knownMachines.has(b.machine));
|
|
188
|
+
if (b.kind === 'shell') {
|
|
189
|
+
const m = b.shell?.machine ?? b.machine;
|
|
190
|
+
return Boolean(m) && (!knownMachines || knownMachines.has(m));
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
})
|
|
194
|
+
.map(([id, b]) => {
|
|
180
195
|
if (b.kind === 'screen') {
|
|
181
196
|
return {
|
|
182
197
|
id: `tab-${id}`,
|
|
@@ -280,16 +295,38 @@ export function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer
|
|
|
280
295
|
// Each place the rail holds lists its own rows: Library its kinds and Upload, Scheduled tasks its tasks and New task.
|
|
281
296
|
const scheduled = useScheduled(host, dev, at === 'scheduled');
|
|
282
297
|
const tabsGroups = useTabsGroups(t, mode === 'tabs');
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
298
|
+
const { open: betaOpen } = useBetas();
|
|
299
|
+
const hostedGroups = useMemo(() => {
|
|
300
|
+
if (mode !== 'hosted')
|
|
301
|
+
return [];
|
|
302
|
+
const path = typeof window !== 'undefined' ? window.location.pathname : host.path;
|
|
303
|
+
const links = HOSTED_APPS.filter((a) => betaOpen(a.id)).map((a) => {
|
|
304
|
+
const href = hosted(a.id);
|
|
305
|
+
const active = path === href || path.startsWith(`${href}/`);
|
|
306
|
+
return {
|
|
307
|
+
id: `app-${a.id}`,
|
|
308
|
+
label: a.name,
|
|
309
|
+
active,
|
|
310
|
+
icon: _jsx(a.icon, { size: 16, "aria-hidden": true }),
|
|
311
|
+
onPress: () => go(href),
|
|
312
|
+
};
|
|
313
|
+
});
|
|
314
|
+
return links.length > 0 ? [{ id: 'hosted-apps', label: '', links }] : [];
|
|
315
|
+
}, [mode, betaOpen, host.path, go]);
|
|
316
|
+
const groups = places && places.length > 0
|
|
317
|
+
? places
|
|
318
|
+
: mode === 'hosted'
|
|
319
|
+
? hostedGroups
|
|
320
|
+
: places ??
|
|
321
|
+
(mode === 'tabs'
|
|
322
|
+
? tabsGroups
|
|
323
|
+
: at === 'customize'
|
|
324
|
+
? tabs(host, dev, t)
|
|
325
|
+
: at === 'library'
|
|
326
|
+
? library(host, dev, t)
|
|
327
|
+
: at === 'scheduled'
|
|
328
|
+
? scheduled
|
|
329
|
+
: own(host, dev, t));
|
|
293
330
|
const open = (row) => (row.kind === 'chat' ? go(talk(row.id)) : dev(row.id));
|
|
294
331
|
const setAnonSettings = (next) => {
|
|
295
332
|
setAnonSettingsOpen(next);
|
|
@@ -347,7 +384,7 @@ export function Sidebar({ host, mode, thread, go, onShut, onSeek, onBack, drawer
|
|
|
347
384
|
if (typeof window !== 'undefined') {
|
|
348
385
|
window.dispatchEvent(new CustomEvent('hanzo:anon-plugins'));
|
|
349
386
|
}
|
|
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: () => {
|
|
387
|
+
}), 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
388
|
if (typeof window !== 'undefined')
|
|
352
389
|
window.location.assign('/login?next=%2Fchat');
|
|
353
390
|
}, 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
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.3.61",
|
|
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",
|