@hanzo/app 0.2.38 → 0.2.40
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/App.js +11 -12
- package/dist/Betas.d.ts +6 -0
- package/dist/Betas.js +5 -3
- package/dist/Column.js +1 -1
- package/dist/Drawer.d.ts +0 -7
- package/dist/Drawer.js +2 -9
- package/dist/Hosted.d.ts +14 -0
- package/dist/Hosted.js +162 -0
- package/dist/Palette.js +3 -2
- package/dist/Rail.d.ts +3 -1
- package/dist/Rail.js +11 -7
- package/dist/lib/betas.d.ts +11 -0
- package/dist/lib/betas.js +5 -5
- package/dist/lib/host.d.ts +10 -0
- package/dist/lib/host.js +16 -0
- package/dist/lib/hosted.d.ts +43 -0
- package/dist/lib/hosted.js +59 -0
- package/dist/where.d.ts +1 -1
- package/package.json +1 -1
package/dist/App.js
CHANGED
|
@@ -75,14 +75,14 @@ import { Orgs } from './Orgs.js';
|
|
|
75
75
|
import { useRooms } from './host.js';
|
|
76
76
|
import { useKept } from './kept.js';
|
|
77
77
|
import { Mark, raised, Rail, Toggle } from './Rail.js';
|
|
78
|
-
import {
|
|
78
|
+
import { Layer, Lift, RAISED, useDrawer } from './Drawer.js';
|
|
79
79
|
import { empty, openThread, showSettings, useOpen } from './open.js';
|
|
80
80
|
import { Paned } from './Shell.js';
|
|
81
81
|
import { Palette } from './Palette.js';
|
|
82
82
|
import { summons } from './seek.js';
|
|
83
83
|
import { floor, pane } from './ground.js';
|
|
84
84
|
import { pick } from './lib/session.js';
|
|
85
|
-
import { app, go, place, settings, studio, talk, TERMINALS, visit } from './lib/host.js';
|
|
85
|
+
import { app, go, hosted, place, settings, studio, talk, TERMINALS, visit } from './lib/host.js';
|
|
86
86
|
import { Top } from './Top.js';
|
|
87
87
|
import { FOOT, HEIGHT, TOP, useView } from './view.js';
|
|
88
88
|
import { dragWindow, toggleWindowMaximize, WindowControls } from './WindowControls.js';
|
|
@@ -90,6 +90,8 @@ import { dragWindow, toggleWindowMaximize, WindowControls } from './WindowContro
|
|
|
90
90
|
const Studio = lazy(() => import('@hanzo/studio').then((m) => ({ default: m.Studio })));
|
|
91
91
|
/** Tabs, the same way: the terminals on the reader's machines (Terminals.tsx). */
|
|
92
92
|
const Terminals = lazy(() => import('./Terminals.js'));
|
|
93
|
+
/** The apps in beta that draw inside the app (lib/hosted), fetched when one is opened at /apps/<id>. */
|
|
94
|
+
const Hosted = lazy(() => import('./Hosted.js').then((m) => ({ default: m.HostedPane })));
|
|
93
95
|
/** Betas, fetched when opening /beta in the app. */
|
|
94
96
|
const Betas = lazy(() => import('./Betas.js').then((m) => ({ default: m.BetasPane })));
|
|
95
97
|
/** `/` is Chat on a new conversation. */
|
|
@@ -136,8 +138,10 @@ function Window({ bar, betas }) {
|
|
|
136
138
|
const here = path ?? '/';
|
|
137
139
|
const at = place(here) ?? HOME;
|
|
138
140
|
const mode = at.mode;
|
|
139
|
-
// Tabs and
|
|
140
|
-
const alone = mode === 'tabs' || mode === 'beta';
|
|
141
|
+
// Tabs, Betas and the hosted apps are their panes alone: no sidebar beside them, and no Dev places in a phone's menu.
|
|
142
|
+
const alone = mode === 'tabs' || mode === 'beta' || mode === 'hosted';
|
|
143
|
+
// The hosted app the address names (lib/hosted), for the rail to light.
|
|
144
|
+
const inside = at.mode === 'hosted' ? at.id : null;
|
|
141
145
|
const where = at.mode === 'dev' ? at.at : null;
|
|
142
146
|
// Studio's host: Dev's, at Studio's address, its moves under /studio, and
|
|
143
147
|
// another organization opening Studio's New in it.
|
|
@@ -251,17 +255,12 @@ function Window({ bar, betas }) {
|
|
|
251
255
|
const toDev = () => move(last.dev || app(''));
|
|
252
256
|
const toStudio = () => move(last.studio || studio(''));
|
|
253
257
|
const toTabs = () => move(TERMINALS);
|
|
254
|
-
/** The drawer's New chat. */
|
|
255
|
-
const fresh = () => {
|
|
256
|
-
empty();
|
|
257
|
-
move(talk());
|
|
258
|
-
};
|
|
259
258
|
// Another organization: picked, and the app opened in it at the mode's New.
|
|
260
259
|
const org = (o) => {
|
|
261
260
|
pick(o);
|
|
262
|
-
window.location.assign(mode === 'dev' ? app('') : mode === 'studio' ? studio('') : mode === 'tabs' ? TERMINALS : talk());
|
|
261
|
+
window.location.assign(mode === 'dev' ? app('') : mode === 'studio' ? studio('') : mode === 'tabs' ? TERMINALS : inside ? hosted(inside) : talk());
|
|
263
262
|
};
|
|
264
|
-
const sidebar = mode === 'beta' ? [] : mode === 'studio' ? places(maker, (p) => maker.go(p)) : mode === 'dev' && raised(where) === 'customize'
|
|
263
|
+
const sidebar = mode === 'beta' || mode === 'hosted' ? [] : mode === 'studio' ? places(maker, (p) => maker.go(p)) : mode === 'dev' && raised(where) === 'customize'
|
|
265
264
|
? tabs(host, (p) => host.go(p), t).map((group) => ({ ...group, links: [...group.links, {
|
|
266
265
|
id: 'learning', label: t('Learning'), active: learning, icon: _jsx(RefreshCw, { size: 16, "aria-hidden": true }),
|
|
267
266
|
onPress: () => { shut(); setLearning(true); },
|
|
@@ -275,5 +274,5 @@ function Window({ bar, betas }) {
|
|
|
275
274
|
// inline-style: the slide, a transform with no logical form whose sign and distance the drawer writes on the element itself, a drag every frame (Drawer.tsx).
|
|
276
275
|
style: drawer.slide ?? undefined, flex: 1, minW: 0, minH: 0, paddingInlineEnd: "var(--pane-gap)", pb: "var(--pane-gap)",
|
|
277
276
|
// The gap above the pane is the gap at its end and foot; a window's own bar above it is that gap.
|
|
278
|
-
pt: bar ? 0 : 'var(--pane-gap)', "$max-md": { p: 0 }, children: [drawer.slide ? _jsx(Lift, {}) : null, _jsx(YStack, { height: "100%", "$max-md": { display: 'none' }, children: _jsx(Rail, { host: host, mode: mode, at: where, open: !closed, toggle: bar ? undefined : flip, onChat: toChat, onDev: toDev, onStudio: toStudio, onTabs: toTabs, go: move, onOrg: org }) }), closed || alone ? null : (_jsx(YStack, { "$max-md": { display: 'none' }, children: _jsx(Column, { host: host, mode: mode, thread: thread, go: move, onShut: () => setClosed(true), onSeek: seek, onBack: back, places: sidebar }) })), _jsxs(YStack, { "data-slot": "stage", flex: 1, minW: 0, minH: 0, marginInlineStart: closed || alone ? 0 : 'var(--pane-gap)', "$max-md": { marginInlineStart: 0, pb: `max(var(--pane-gap), ${FOOT})` }, children: [bar ? null : _jsx(Top, { host: host, mode: mode, places: sidebar, open: drawer.state !== 'shut', go: move, onMenu: drawer.open, onChat: toChat, onDev: toDev }), _jsx(XStack, { "data-slot": "panes", flex: 1, minW: 0, minH: 0, children: mode === 'chat' ? (_jsx(Paned, { framed: true, children: _jsx(Chat, {}) })) : mode === 'tabs' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(Suspense, { fallback: null, children: _jsx(Terminals, {}) }) })) : mode === 'studio' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(Studio, { host: maker, rail: false }) }) }) })) : mode === 'beta' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflowY: "auto", overflowX: "hidden", flex: 1, minW: 0, minH: 0, p: "$4", $md: { p: '$6' }, children: betas ?? (_jsx(Suspense, { fallback: null, children: _jsx(Betas, { go: move }) })) })) : (_jsx(YStack, { render: "main", "data-slot": "pane", ...(run ? null : { ...pane(), overflow: 'hidden' }), flex: 1, minW: 0, minH: 0, children: plans ? null : _jsx(Builder, { host: host, rail: false }) })) })] })] }), drawer.state === 'shut' ? null : (_jsx(Layer, { drawer: drawer, top: bar ? BAR : 0, children:
|
|
277
|
+
pt: bar ? 0 : 'var(--pane-gap)', "$max-md": { p: 0 }, children: [drawer.slide ? _jsx(Lift, {}) : null, _jsx(YStack, { height: "100%", "$max-md": { display: 'none' }, children: _jsx(Rail, { host: host, mode: mode, at: where, inside: inside, open: !closed, toggle: bar ? undefined : flip, onChat: toChat, onDev: toDev, onStudio: toStudio, onTabs: toTabs, go: move, onOrg: org }) }), closed || alone ? null : (_jsx(YStack, { "$max-md": { display: 'none' }, children: _jsx(Column, { host: host, mode: mode, thread: thread, go: move, onShut: () => setClosed(true), onSeek: seek, onBack: back, places: sidebar }) })), _jsxs(YStack, { "data-slot": "stage", flex: 1, minW: 0, minH: 0, marginInlineStart: closed || alone ? 0 : 'var(--pane-gap)', "$max-md": { marginInlineStart: 0, pb: `max(var(--pane-gap), ${FOOT})` }, children: [bar ? null : _jsx(Top, { host: host, mode: mode, places: sidebar, open: drawer.state !== 'shut', go: move, onMenu: drawer.open, onChat: toChat, onDev: toDev }), _jsx(XStack, { "data-slot": "panes", flex: 1, minW: 0, minH: 0, children: mode === 'chat' ? (_jsx(Paned, { framed: true, children: _jsx(Chat, {}) })) : mode === 'tabs' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(Suspense, { fallback: null, children: _jsx(Terminals, {}) }) })) : mode === 'studio' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(YStack, { flex: 1, minH: 0, height: "100%", children: _jsx(Suspense, { fallback: null, children: _jsx(Studio, { host: maker, rail: false }) }) }) })) : at.mode === 'hosted' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflow: "hidden", flex: 1, minW: 0, minH: 0, children: _jsx(Suspense, { fallback: null, children: _jsx(Hosted, { id: at.id, go: move }) }) })) : mode === 'beta' ? (_jsx(YStack, { render: "main", "data-slot": "pane", ...pane(), overflowY: "auto", overflowX: "hidden", flex: 1, minW: 0, minH: 0, p: "$4", $md: { p: '$6' }, children: betas ?? (_jsx(Suspense, { fallback: null, children: _jsx(Betas, { go: move }) })) })) : (_jsx(YStack, { render: "main", "data-slot": "pane", ...(run ? null : { ...pane(), overflow: 'hidden' }), flex: 1, minW: 0, minH: 0, children: plans ? null : _jsx(Builder, { host: host, rail: false }) })) })] })] }), drawer.state === 'shut' ? null : (_jsx(Layer, { drawer: drawer, top: bar ? BAR : 0, children: _jsxs(XStack, { flex: 1, minH: 0, children: [_jsx(YStack, { "data-slot": "drawer-rail", shrink: 0, children: _jsx(Rail, { host: host, mode: mode, at: where, inside: inside, open: true, onChat: toChat, onDev: toDev, onStudio: toStudio, onTabs: toTabs, go: move, onOrg: org }) }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Column, { host: host, mode: mode, thread: thread, go: move, onShut: shut, onSeek: seek, onBack: back, drawer: true, places: sidebar }) })] }) })), finding ? _jsx(Palette, { go: move, onClose: found, mode: mode, host: host }) : null, learning ? _jsx(Learning, { open: true, onClose: () => setLearning(false) }) : null] }) }) }) }));
|
|
279
278
|
}
|
package/dist/Betas.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Beta } from './lib/betas.js';
|
|
1
2
|
/** The apps in beta as this reader stands: which open, which they asked for, and the ask. */
|
|
2
3
|
export declare function useBetas(): {
|
|
3
4
|
/** The one predicate: whether this reader may open the app `id`. */
|
|
@@ -13,6 +14,11 @@ export declare function useBetas(): {
|
|
|
13
14
|
/** The cloud has answered for this reader. */
|
|
14
15
|
ready: boolean;
|
|
15
16
|
};
|
|
17
|
+
/** One app's action: Open where it may (in the app, for one that draws inside it), Requested once asked, else Request access. */
|
|
18
|
+
export declare function Ask({ beta, go }: {
|
|
19
|
+
beta: Beta;
|
|
20
|
+
go?: (href: string) => void;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
16
22
|
/** Every app in beta, by group, each with its action. */
|
|
17
23
|
export declare function BetasList({ go }: {
|
|
18
24
|
go?: (href: string) => void;
|
package/dist/Betas.js
CHANGED
|
@@ -30,6 +30,7 @@ import { Button, Dialog, DialogContent, DialogTitle, Text, XStack, YStack } from
|
|
|
30
30
|
import { api } from './lib/api.js';
|
|
31
31
|
import { BETAS, GROUPS, opens } from './lib/betas.js';
|
|
32
32
|
import { bearer, scope, superAdmin } from './lib/session.js';
|
|
33
|
+
import { hosted } from './lib/host.js';
|
|
33
34
|
import { CHANGED, optin } from './lib/optin.js';
|
|
34
35
|
const NONE = { flags: {}, asked: [], public: [], blocked: false };
|
|
35
36
|
/** A group's heading as the list draws it: authored English, drawn through `t`. */
|
|
@@ -129,14 +130,15 @@ function here() {
|
|
|
129
130
|
const host = window.location.hostname;
|
|
130
131
|
return host === 'localhost' || host === '127.0.0.1' || host === '[::1]' || host.endsWith('.local') || /^10\./.test(host) || /^192\.168\./.test(host);
|
|
131
132
|
}
|
|
132
|
-
/** One app's action: Open where it may, Requested once asked, else Request access. */
|
|
133
|
-
function Ask({ beta, go }) {
|
|
133
|
+
/** One app's action: Open where it may (in the app, for one that draws inside it), Requested once asked, else Request access. */
|
|
134
|
+
export function Ask({ beta, go }) {
|
|
134
135
|
const { t } = useI18n();
|
|
135
136
|
const { open, asked, promoted, blocked, request } = useBetas();
|
|
136
137
|
const [busy, setBusy] = useState(false);
|
|
137
138
|
const [wrong, setWrong] = useState(null);
|
|
138
139
|
if (open(beta.id)) {
|
|
139
|
-
|
|
140
|
+
const to = beta.embed !== undefined ? hosted(beta.id) : beta.href;
|
|
141
|
+
return to && go ? (_jsx(Button, { size: "sm", rounded: 999, onPress: () => go(to), "data-slot": "beta-open", children: t('Open') })) : (_jsx(Text, { fontSize: "$2", color: "$color11", "data-slot": "beta-on", children: t('You’re in') }));
|
|
140
142
|
}
|
|
141
143
|
if (promoted(beta.id)) {
|
|
142
144
|
return (_jsx(Text, { fontSize: "$2", color: "$color11", text: "right", maxW: 200, "data-slot": "beta-optin", children: t(blocked ? 'Turned off by your organization' : 'Turn on experimental features in Settings') }));
|
package/dist/Column.js
CHANGED
|
@@ -130,5 +130,5 @@ export function Column({ host, mode, thread, go, onShut, onSeek, onBack, drawer
|
|
|
130
130
|
borderColor: 'var(--border-strong)',
|
|
131
131
|
bg: 'var(--pane-fill)',
|
|
132
132
|
}
|
|
133
|
-
: HEAD), children: _jsx(Search, { size: drawer ? 18 : 16, "aria-hidden": true }) })] })), mode === 'chat' ? (_jsx(YStack, { role: "list", gap: 2, shrink: 0, children: _jsx(YStack, { role: "listitem", children: _jsx(SidebarItem, { "data-slot": "app-new", ...ROW, active: !thread, bg: "transparent", hoverStyle: { bg: '$hover' }, icon: _jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: _jsx(SquarePen, { size: 16, "aria-hidden": true }) }), onPress: create, ...keys(create), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('New chat') }) }) }) })) : (_jsx(YStack, { "data-slot": "app-places", shrink: 0, 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", children: _jsx(SidebarItem, { ...ROW, ...(link.id === NEW ? { 'data-slot': 'app-new' } : {}), active: link.active, icon: link.id === NEW ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: _jsx(SquarePen, { size: 16, "aria-hidden": true }) })) : link.icon ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: link.icon })) : 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 === 'studio' || mode === 'tabs' || mode === 'beta' || at ? _jsx(YStack, { flex: 1, minH: 0 }) : _jsx(Recents, { host: host, mode: mode, thread: thread, onOpen: open, onNew: create }), at ? null : (_jsxs(YStack, { gap: "$2", pt: "$2", shrink: 0, children: [_jsx(Made, {}), _jsx(Setup, { go: go })] })), free ? (_jsx(YStack, { role: "list", gap: 2, shrink: 0, pt: "$2", children: _jsx(YStack, { role: "listitem", minH: MARK, justify: "center", children: _jsx(SidebarItem, { ...ROW, "data-slot": "column-upgrade", icon: _jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: _jsx(Sparkles, { size: 16, "aria-hidden": true, color: "var(--primary)" }) }), onPress: () => window.location.assign(payUrl('/cart', { returnUrl: window.location.href })), ...keys(() => window.location.assign(payUrl('/cart', { returnUrl: window.location.href }))), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Upgrade plan') }) }) }) })) : null, foot] }), drawer ? null : (_jsx(Gutter, { side: dir === 'rtl' ? 'right' : 'left', span: span.span, floor: FLOOR, ceil: CEIL, reset: WIDTH, onSpan: span.move, onKeep: span.keep, onShut: onShut, label: t('Resize sidebar') }))] }));
|
|
133
|
+
: HEAD), children: _jsx(Search, { size: drawer ? 18 : 16, "aria-hidden": true }) })] })), mode === 'chat' ? (_jsx(YStack, { role: "list", gap: 2, shrink: 0, children: _jsx(YStack, { role: "listitem", children: _jsx(SidebarItem, { "data-slot": "app-new", ...ROW, active: !thread, bg: "transparent", hoverStyle: { bg: '$hover' }, icon: _jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: _jsx(SquarePen, { size: 16, "aria-hidden": true }) }), onPress: create, ...keys(create), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('New chat') }) }) }) })) : (_jsx(YStack, { "data-slot": "app-places", shrink: 0, 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", children: _jsx(SidebarItem, { ...ROW, ...(link.id === NEW ? { 'data-slot': 'app-new' } : {}), active: link.active, icon: link.id === NEW ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: _jsx(SquarePen, { size: 16, "aria-hidden": true }) })) : link.icon ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: link.icon })) : 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 === 'studio' || mode === 'tabs' || mode === 'beta' || mode === 'hosted' || at ? _jsx(YStack, { flex: 1, minH: 0 }) : _jsx(Recents, { host: host, mode: mode, thread: thread, onOpen: open, onNew: create }), at ? null : (_jsxs(YStack, { gap: "$2", pt: "$2", shrink: 0, children: [_jsx(Made, {}), _jsx(Setup, { go: go })] })), free ? (_jsx(YStack, { role: "list", gap: 2, shrink: 0, pt: "$2", children: _jsx(YStack, { role: "listitem", minH: MARK, justify: "center", children: _jsx(SidebarItem, { ...ROW, "data-slot": "column-upgrade", icon: _jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: _jsx(Sparkles, { size: 16, "aria-hidden": true, color: "var(--primary)" }) }), onPress: () => window.location.assign(payUrl('/cart', { returnUrl: window.location.href })), ...keys(() => window.location.assign(payUrl('/cart', { returnUrl: window.location.href }))), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Upgrade plan') }) }) }) })) : null, foot] }), drawer ? null : (_jsx(Gutter, { side: dir === 'rtl' ? 'right' : 'left', span: span.span, floor: FLOOR, ceil: CEIL, reset: WIDTH, onSpan: span.move, onKeep: span.keep, onShut: onShut, label: t('Resize sidebar') }))] }));
|
|
134
134
|
}
|
package/dist/Drawer.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
-
import { type Who } from './Me.js';
|
|
3
2
|
import { type State } from './slide.js';
|
|
4
3
|
/** A press that moves the app: told whether it should take the menu's place in history. */
|
|
5
4
|
export type Move = (replace: boolean) => void;
|
|
@@ -53,9 +52,3 @@ export declare function Layer({ drawer, top, children }: {
|
|
|
53
52
|
top?: number;
|
|
54
53
|
children: ReactNode;
|
|
55
54
|
}): import("react").JSX.Element;
|
|
56
|
-
/** The menu's foot: the accent New chat at the start and the account (its menu opens above it) at the end. */
|
|
57
|
-
export declare function Foot({ host, onChat, onOrg }: {
|
|
58
|
-
host: Who;
|
|
59
|
-
onChat: () => void;
|
|
60
|
-
onOrg: (org: string) => void;
|
|
61
|
-
}): import("react").JSX.Element;
|
package/dist/Drawer.js
CHANGED
|
@@ -12,7 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
// │ ✎ New chat │ │ the press that closes (`drawer-close`)
|
|
13
13
|
// │ ◇ Studio ⌨ Tabs ⋯ More │ │
|
|
14
14
|
// │ Pinned … Recents … │ │
|
|
15
|
-
// │
|
|
15
|
+
// │ │ │ the account stands at the rail's foot (Rail.tsx)
|
|
16
16
|
// └──────────────────────────┴────╯
|
|
17
17
|
//
|
|
18
18
|
// Three states, because the slide home has to be seen: shut (no menu, the pane
|
|
@@ -37,10 +37,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
37
37
|
// Its list's scroll stays its own (Recents' `overscrollBehavior`), and the pane,
|
|
38
38
|
// never unmounted, keeps its own.
|
|
39
39
|
import { useI18n } from '@hanzo/i18n/react';
|
|
40
|
-
import {
|
|
41
|
-
import { SquarePen } from 'lucide-react';
|
|
40
|
+
import { YStack, useMedia } from '@hanzo/gui';
|
|
42
41
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
43
|
-
import { Me } from './Me.js';
|
|
44
42
|
import { axis, OPEN, pull, settle, sign } from './slide.js';
|
|
45
43
|
/**
|
|
46
44
|
* The pane's offset as a transform: `--drawer-way` the end side's sign,
|
|
@@ -351,8 +349,3 @@ export function Layer({ drawer, top = 0, children }) {
|
|
|
351
349
|
const { t } = useI18n();
|
|
352
350
|
return (_jsxs(YStack, { ref: drawer.layer, role: "dialog", "aria-modal": true, "aria-label": t('Menu'), tabIndex: -1, "data-slot": "drawer", "data-state": drawer.state, position: "absolute", t: top, b: 0, insetInlineStart: 0, insetInlineEnd: 0, outlineStyle: "none", $md: { display: 'none' }, children: [_jsx(YStack, { "data-slot": "menu", position: "absolute", t: 0, b: 0, insetInlineStart: 0, z: "var(--z-base)", width: OPEN, bg: "var(--pane-floor)", pt: "var(--safe-top)", pb: "max(var(--pane-gap), var(--safe-bottom))", ...{ paddingInlineStart: 'max(var(--safe-left), var(--safe-right))', touchAction: 'pan-y' }, children: children }), drawer.state === 'open' ? (_jsx(YStack, { render: "button", "data-slot": "drawer-close", "aria-label": t('Close sidebar'), onPress: drawer.close, position: "absolute", t: 0, b: 0, insetInlineEnd: 0, z: "var(--z-drawer)", bg: "transparent", borderWidth: 0, cursor: "pointer", ...{ insetInlineStart: OPEN, touchAction: 'none' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' } })) : null] }));
|
|
353
351
|
}
|
|
354
|
-
/** The menu's foot: the accent New chat at the start and the account (its menu opens above it) at the end. */
|
|
355
|
-
export function Foot({ host, onChat, onOrg }) {
|
|
356
|
-
const { t } = useI18n();
|
|
357
|
-
return (_jsxs(XStack, { "data-slot": "drawer-foot", items: "center", justify: "space-between", gap: "$2", pt: "$2", px: "$1", shrink: 0, children: [_jsxs(XStack, { render: "button", "data-slot": "drawer-chat", "aria-label": t('New chat'), onPress: onChat, height: 44, px: "$4.5", gap: "$2", rounded: 9999, items: "center", justify: "center", bg: "var(--accent)", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: 'var(--accent-hover)' }, pressStyle: { bg: 'var(--accent-hover)' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: [_jsx(SquarePen, { size: 18, color: "var(--accent-foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: "$4", fontWeight: "600", color: "var(--accent-foreground)", children: t('Chat') })] }), _jsx(Me, { host: host, narrow: true, above: true, onOrg: onOrg })] }));
|
|
358
|
-
}
|
package/dist/Hosted.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** How long a frame may take to load before the pane says it did not. */
|
|
2
|
+
export declare const PATIENCE = 20000;
|
|
3
|
+
/** What the host tells a frame about how it looks. */
|
|
4
|
+
export interface Hostly {
|
|
5
|
+
type: 'hanzo:host';
|
|
6
|
+
theme: 'light' | 'dark';
|
|
7
|
+
accent?: string;
|
|
8
|
+
density?: string;
|
|
9
|
+
org?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function HostedPane({ id, go }: {
|
|
12
|
+
id: string;
|
|
13
|
+
go: (address: string) => void;
|
|
14
|
+
}): import("react").JSX.Element;
|
package/dist/Hosted.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The apps in beta that stand inside the app, at /apps/<id> (lib/hosted): one
|
|
4
|
+
// pane for CRM, Commerce, CMS, Analytics and Insights. Each is a standalone app
|
|
5
|
+
// on a host of its own, and the pane frames that live host, so the app deploys
|
|
6
|
+
// on its own and hanzo.ai shows the deploy at once.
|
|
7
|
+
//
|
|
8
|
+
// WHO MAY OPEN ONE is `useBetas().open`, the one predicate (lib/betas): a reader
|
|
9
|
+
// the switch is off for is shown the app's request path, the Betas list's own
|
|
10
|
+
// action, never a frame. Still reading the switches, or the cloud not
|
|
11
|
+
// answering, shows the loader and then the request path, never the app.
|
|
12
|
+
//
|
|
13
|
+
// THE FRAME is `?embed=1` on the app's own address, same registrable domain, so
|
|
14
|
+
// IAM's session cookie is first-party in it. The host tells the frame how it
|
|
15
|
+
// looks (`hanzo:host`: theme, accent, density, organization) when it has loaded
|
|
16
|
+
// and whenever the look or the organization changes; the frame may say where it
|
|
17
|
+
// is (`hanzo:navigate`, kept in this address as `?at=`) and that it is up
|
|
18
|
+
// (`hanzo:ready`). A message is heard only from that host's origin and that one
|
|
19
|
+
// frame, and an app that never speaks still works.
|
|
20
|
+
//
|
|
21
|
+
// A frame the host refuses to draw fires no error a page can read, so a frame
|
|
22
|
+
// that has not loaded after `PATIENCE` is said to have failed, with the way out:
|
|
23
|
+
// the app in a tab.
|
|
24
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
25
|
+
import { ExternalLink, RotateCw } from 'lucide-react';
|
|
26
|
+
import { current, dark } from '@hanzo/appearance';
|
|
27
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
28
|
+
import { Button, Spinner, Text, XStack, YStack } from '@hanzo/ui';
|
|
29
|
+
import { View } from '@hanzo/gui';
|
|
30
|
+
import { Ask, useBetas } from './Betas.js';
|
|
31
|
+
import { out } from './help.js';
|
|
32
|
+
import { useOrg } from './host.js';
|
|
33
|
+
import { BETAS } from './lib/betas.js';
|
|
34
|
+
import { go as replace, hosted } from './lib/host.js';
|
|
35
|
+
import { frameUrl, hostedApp, origin, pathOn } from './lib/hosted.js';
|
|
36
|
+
/** How long a frame may take to load before the pane says it did not. */
|
|
37
|
+
export const PATIENCE = 20_000;
|
|
38
|
+
/** What the frame may use of the browser: the clipboard and full screen, which the apps' own pages ask for. */
|
|
39
|
+
const ALLOW = 'clipboard-read; clipboard-write; fullscreen';
|
|
40
|
+
/**
|
|
41
|
+
* How the page looks as the reader has it, read off their stored choice for the
|
|
42
|
+
* organization and read again whenever the document's own look is repainted
|
|
43
|
+
* (a class or a variable on <html>), so a change in Settings reaches the frame
|
|
44
|
+
* without a second reading of the account.
|
|
45
|
+
*/
|
|
46
|
+
function useLooks(orgId) {
|
|
47
|
+
const read = useCallback(() => {
|
|
48
|
+
const { pref } = current({ orgId });
|
|
49
|
+
return { theme: dark(pref.theme ?? 'system') ? 'dark' : 'light', accent: pref.accent, density: pref.density };
|
|
50
|
+
}, [orgId]);
|
|
51
|
+
const [looks, setLooks] = useState(read);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const again = () => setLooks((was) => {
|
|
54
|
+
const now = read();
|
|
55
|
+
return was.theme === now.theme && was.accent === now.accent && was.density === now.density ? was : now;
|
|
56
|
+
});
|
|
57
|
+
again();
|
|
58
|
+
const watch = new MutationObserver(again);
|
|
59
|
+
watch.observe(document.documentElement, { attributes: true, attributeFilter: ['class', 'style', 'data-scheme', 'data-theme'] });
|
|
60
|
+
return () => watch.disconnect();
|
|
61
|
+
}, [read]);
|
|
62
|
+
return looks;
|
|
63
|
+
}
|
|
64
|
+
/** The page the address names inside the app, when it names one: `?at=/path` on the app's own host. */
|
|
65
|
+
const started = () => {
|
|
66
|
+
const at = new URLSearchParams(window.location.search).get('at');
|
|
67
|
+
return at && at.startsWith('/') && !at.startsWith('//') ? at : null;
|
|
68
|
+
};
|
|
69
|
+
export function HostedPane({ id, go }) {
|
|
70
|
+
const { open, ready } = useBetas();
|
|
71
|
+
const app = hostedApp(id);
|
|
72
|
+
if (!app)
|
|
73
|
+
return null;
|
|
74
|
+
if (!ready)
|
|
75
|
+
return _jsx(Waiting, {});
|
|
76
|
+
if (!open(app.id))
|
|
77
|
+
return _jsx(Request, { app: app, go: go });
|
|
78
|
+
return _jsx(Frame, { app: app }, app.id);
|
|
79
|
+
}
|
|
80
|
+
/** The loader: the shell's spinner, centred in the pane. */
|
|
81
|
+
function Waiting() {
|
|
82
|
+
return (_jsx(YStack, { flex: 1, items: "center", justify: "center", "data-slot": "hosted-loading", children: _jsx(Spinner, { size: 28, color: "$color10" }) }));
|
|
83
|
+
}
|
|
84
|
+
/** The request path: the app, what it is, and the Betas list's own action for it. */
|
|
85
|
+
function Request({ app, go }) {
|
|
86
|
+
const { t } = useI18n();
|
|
87
|
+
const beta = BETAS.find((b) => b.id === app.id);
|
|
88
|
+
const Icon = app.icon;
|
|
89
|
+
return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", gap: "$3", p: "$6", "data-slot": "hosted-request", "data-app": app.id, children: [_jsx(Icon, { size: 28, "aria-hidden": true }), _jsx(Text, { fontSize: "$6", fontWeight: "600", color: "$color12", children: app.name }), beta ? (_jsx(Text, { fontSize: "$3", color: "$color11", text: "center", maxW: 420, children: t(beta.line) })) : null, beta ? _jsx(Ask, { beta: beta, go: go }) : null, _jsx(Button, { size: "sm", variant: "ghost", rounded: 999, onPress: () => go('/beta'), children: t('All betas') })] }));
|
|
90
|
+
}
|
|
91
|
+
/** The frame, with its quiet toolbar, its loader and its failure. */
|
|
92
|
+
function Frame({ app }) {
|
|
93
|
+
const { t } = useI18n();
|
|
94
|
+
const org = useOrg();
|
|
95
|
+
const looks = useLooks(org.id);
|
|
96
|
+
const frame = useRef(null);
|
|
97
|
+
// The page the frame is on, as the app last said (or the address asked for): reload and the tab keep it.
|
|
98
|
+
const at = useRef(started());
|
|
99
|
+
const [src, setSrc] = useState(() => frameUrl(app, at.current));
|
|
100
|
+
const [turn, setTurn] = useState(0);
|
|
101
|
+
const [state, setState] = useState('loading');
|
|
102
|
+
const host = origin(app);
|
|
103
|
+
// What the frame is told: each time it loads, and whenever the look or the organization changes after.
|
|
104
|
+
const tell = useCallback(() => {
|
|
105
|
+
const to = frame.current?.contentWindow;
|
|
106
|
+
if (!to)
|
|
107
|
+
return;
|
|
108
|
+
const said = { type: 'hanzo:host', ...looks, org: org.id };
|
|
109
|
+
try {
|
|
110
|
+
to.postMessage(said, host);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
/* a window that is no longer the app's: nothing to tell */
|
|
114
|
+
}
|
|
115
|
+
}, [looks, org.id, host]);
|
|
116
|
+
const up = useRef(false);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
up.current = state === 'ready';
|
|
119
|
+
}, [state]);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (up.current)
|
|
122
|
+
tell();
|
|
123
|
+
}, [tell]);
|
|
124
|
+
const loaded = () => {
|
|
125
|
+
setState((was) => (was === 'failed' ? was : 'ready'));
|
|
126
|
+
tell();
|
|
127
|
+
};
|
|
128
|
+
// What the frame says: heard from its host and from it alone.
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
const hear = (e) => {
|
|
131
|
+
if (e.origin !== host || e.source !== frame.current?.contentWindow)
|
|
132
|
+
return;
|
|
133
|
+
const said = e.data;
|
|
134
|
+
if (said?.type === 'hanzo:ready')
|
|
135
|
+
setState('ready');
|
|
136
|
+
else if (said?.type === 'hanzo:navigate' && typeof said.href === 'string') {
|
|
137
|
+
const to = pathOn(app, said.href);
|
|
138
|
+
if (!to)
|
|
139
|
+
return;
|
|
140
|
+
at.current = to;
|
|
141
|
+
replace(hosted(app.id, to === '/' ? undefined : to), true);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
window.addEventListener('message', hear);
|
|
145
|
+
return () => window.removeEventListener('message', hear);
|
|
146
|
+
}, [app, host]);
|
|
147
|
+
// A frame that never loads is said not to have.
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (state !== 'loading')
|
|
150
|
+
return;
|
|
151
|
+
const late = window.setTimeout(() => setState('failed'), PATIENCE);
|
|
152
|
+
return () => window.clearTimeout(late);
|
|
153
|
+
}, [state, turn]);
|
|
154
|
+
const reload = () => {
|
|
155
|
+
setSrc(frameUrl(app, at.current));
|
|
156
|
+
setState('loading');
|
|
157
|
+
setTurn((n) => n + 1);
|
|
158
|
+
};
|
|
159
|
+
const tab = () => out(at.current ? `${host}${at.current}` : app.href);
|
|
160
|
+
const Icon = app.icon;
|
|
161
|
+
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] })] }));
|
|
162
|
+
}
|
package/dist/Palette.js
CHANGED
|
@@ -43,7 +43,7 @@ import { empty, openThread, withAgents } from './open.js';
|
|
|
43
43
|
import { useThreadList } from './thread.js';
|
|
44
44
|
import { useSignOut } from './lib/signout.js';
|
|
45
45
|
import { choose } from './lib/session.js';
|
|
46
|
-
import { app, paged, settings, studio, talk, TERMINALS, WORKSPACE } from './lib/host.js';
|
|
46
|
+
import { app, hosted, paged, settings, studio, talk, TERMINALS, WORKSPACE } from './lib/host.js';
|
|
47
47
|
import { BETAS } from './lib/betas.js';
|
|
48
48
|
import { useBetas } from './Betas.js';
|
|
49
49
|
import { tidy } from './lib/title.js';
|
|
@@ -207,7 +207,8 @@ export function Palette({ onClose, go, actions: frame = [], mode = 'chat', host,
|
|
|
207
207
|
icon: _jsx(Sparkles, { ...ICON }),
|
|
208
208
|
where: t('Beta'),
|
|
209
209
|
keywords: ['beta', b.line],
|
|
210
|
-
|
|
210
|
+
// One that draws inside the app opens there; any other at its own host.
|
|
211
|
+
run: () => (b.embed !== undefined ? go(hosted(b.id)) : out(b.href)),
|
|
211
212
|
}));
|
|
212
213
|
const here = [...top.map(swap), ...frame.filter((b) => !top.some((a) => a.id === b.id)), ...granted];
|
|
213
214
|
const doing = actions(host, go, () => void signOut(), () => (setQuery(''), setKeys(true)), t);
|
package/dist/Rail.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function Toggle({ open, onPress, label }: {
|
|
|
29
29
|
onPress: () => void;
|
|
30
30
|
label?: string;
|
|
31
31
|
}): import("react").JSX.Element;
|
|
32
|
-
export declare function Rail({ host, mode, at, open, toggle, rows, onChat, onDev, onStudio, onTabs, go, onOrg, }: {
|
|
32
|
+
export declare function Rail({ host, mode, at, open, toggle, inside, rows, onChat, onDev, onStudio, onTabs, go, onOrg, }: {
|
|
33
33
|
host: Host;
|
|
34
34
|
mode: Place['mode'];
|
|
35
35
|
/** Dev's builder address, or null outside Dev. */
|
|
@@ -38,6 +38,8 @@ export declare function Rail({ host, mode, at, open, toggle, rows, onChat, onDev
|
|
|
38
38
|
open: boolean;
|
|
39
39
|
/** Lead with the sidebar's toggle; absent where the host's bar holds it. */
|
|
40
40
|
toggle?: () => void;
|
|
41
|
+
/** The hosted app (lib/hosted) the reader is in, if any. */
|
|
42
|
+
inside?: string | null;
|
|
41
43
|
/** Listed as rows in a phone's menu rather than marks down the window's edge. */
|
|
42
44
|
rows?: boolean;
|
|
43
45
|
/** To Chat, Dev and Studio, each where the reader left it. */
|
package/dist/Rail.js
CHANGED
|
@@ -43,9 +43,10 @@ import { SidebarItem } from '@hanzo/ui/chat';
|
|
|
43
43
|
import { BetasDialog, useBetas } from './Betas.js';
|
|
44
44
|
import { out } from './help.js';
|
|
45
45
|
import { BETAS } from './lib/betas.js';
|
|
46
|
+
import { HOSTED_APPS } from './lib/hosted.js';
|
|
46
47
|
import { Me } from './Me.js';
|
|
47
48
|
import { BAND } from './ground.js';
|
|
48
|
-
import { app, WORKSPACE } from './lib/host.js';
|
|
49
|
+
import { app, hosted, WORKSPACE } from './lib/host.js';
|
|
49
50
|
/** The rail's width, px. */
|
|
50
51
|
export const RAIL = 44;
|
|
51
52
|
/** A mark, px: a 36px square on a 44px pitch. */
|
|
@@ -87,7 +88,7 @@ export function Toggle({ open, onPress, label }) {
|
|
|
87
88
|
const { t } = useI18n();
|
|
88
89
|
return (_jsx(Mark, { label: label ?? t(open ? 'Close sidebar' : 'Open sidebar'), "data-slot": "sidebar-toggle", "aria-expanded": open, onPress: onPress, children: _jsx(PanelLeft, { size: 18, "aria-hidden": true, "data-i18n-mirror": true }) }));
|
|
89
90
|
}
|
|
90
|
-
export function Rail({ host, mode, at, open, toggle, rows = false, onChat, onDev, onStudio, onTabs, go, onOrg, }) {
|
|
91
|
+
export function Rail({ host, mode, at, open, toggle, inside = null, rows = false, onChat, onDev, onStudio, onTabs, go, onOrg, }) {
|
|
91
92
|
const { t, dir } = useI18n();
|
|
92
93
|
const here = mode === 'dev' ? raised(at) : null;
|
|
93
94
|
const to = (p) => () => go(app(p));
|
|
@@ -96,8 +97,11 @@ export function Rail({ host, mode, at, open, toggle, rows = false, onChat, onDev
|
|
|
96
97
|
const team = mode !== 'studio';
|
|
97
98
|
const { open: opened } = useBetas();
|
|
98
99
|
const [betas, setBetas] = useState(false);
|
|
99
|
-
// The apps in beta this reader may open, each where it lives.
|
|
100
|
-
const granted = BETAS.filter((b) => b.href && opened(b.id));
|
|
100
|
+
// The apps in beta this reader may open, each where it lives; those that draw inside the app have marks of their own.
|
|
101
|
+
const granted = BETAS.filter((b) => b.href && b.embed === undefined && opened(b.id));
|
|
102
|
+
const apps = HOSTED_APPS.filter((a) => opened(a.id));
|
|
103
|
+
// A link out of the app, or a place in it.
|
|
104
|
+
const reach = (address) => (address.startsWith('/') ? go(address) : out(address));
|
|
101
105
|
const rest = [
|
|
102
106
|
...(rows
|
|
103
107
|
? [
|
|
@@ -117,12 +121,12 @@ export function Rail({ host, mode, at, open, toggle, rows = false, onChat, onDev
|
|
|
117
121
|
]
|
|
118
122
|
: []),
|
|
119
123
|
];
|
|
120
|
-
const betasDialog = _jsx(BetasDialog, { open: betas, onOpenChange: setBetas, go:
|
|
124
|
+
const betasDialog = _jsx(BetasDialog, { open: betas, onOpenChange: setBetas, go: reach });
|
|
121
125
|
if (rows)
|
|
122
|
-
return (_jsxs(YStack, { "data-slot": "places", render: "nav", "aria-label": t('Products'), pt: "$2", shrink: 0, children: [_jsxs(YStack, { role: "list", gap: 2, children: [_jsx(YStack, { role: "listitem", children: _jsx(Row, { label: "Studio", on: mode === 'studio', onPress: onStudio, "data-slot": "place-studio", icon: _jsx(WandSparkles, { size: 16, "aria-hidden": true }) }) }), _jsx(YStack, { role: "listitem", children: _jsx(Row, { label: "Tabs", on: mode === 'tabs', onPress: onTabs, "data-slot": "place-tabs", icon: _jsx(SquareTerminal, { size: 16, "aria-hidden": true }) }) }), _jsx(YStack, { role: "listitem", children: _jsx(DropdownMenu, { placement: "bottom-start", minWidth: 220, trigger: _jsx(Row, { label: t('More'), "data-slot": "place-more", "aria-haspopup": "menu", icon: _jsx(Ellipsis, { size: 16, "aria-hidden": true }) }), items: rest }) })] }), betasDialog] }));
|
|
126
|
+
return (_jsxs(YStack, { "data-slot": "places", render: "nav", "aria-label": t('Products'), pt: "$2", shrink: 0, children: [_jsxs(YStack, { role: "list", gap: 2, children: [_jsx(YStack, { role: "listitem", children: _jsx(Row, { label: "Studio", on: mode === 'studio', onPress: onStudio, "data-slot": "place-studio", icon: _jsx(WandSparkles, { size: 16, "aria-hidden": true }) }) }), _jsx(YStack, { role: "listitem", children: _jsx(Row, { label: "Tabs", on: mode === 'tabs', onPress: onTabs, "data-slot": "place-tabs", icon: _jsx(SquareTerminal, { size: 16, "aria-hidden": true }) }) }), apps.map((a) => (_jsx(YStack, { role: "listitem", children: _jsx(Row, { label: a.name, on: inside === a.id, onPress: () => go(hosted(a.id)), "data-slot": `place-app-${a.id}`, icon: _jsx(a.icon, { size: 16, "aria-hidden": true }) }) }, a.id))), _jsx(YStack, { role: "listitem", children: _jsx(DropdownMenu, { placement: "bottom-start", minWidth: 220, trigger: _jsx(Row, { label: t('More'), "data-slot": "place-more", "aria-haspopup": "menu", icon: _jsx(Ellipsis, { size: 16, "aria-hidden": true }) }), items: rest }) })] }), betasDialog] }));
|
|
123
127
|
return (_jsxs(YStack, { "data-slot": "rail", render: "nav", "aria-label": t('Products'), width: RAIL, flex: 1,
|
|
124
128
|
// The first mark centred on the head band beside it (BAND), the account on the sidebar's foot (Column's `pb`).
|
|
125
|
-
pt: (BAND - MARK) / 2, pb: "$2", gap: 4, shrink: 0, items: "center", $touchable: { pt: (BAND - TOUCH) / 2 }, children: [toggle ? (_jsx(YStack, { pb: 4, children: _jsx(Toggle, { open: open, onPress: toggle }) })) : null, _jsx(Mark, { label: t('Chat'), on: mode === 'chat', onPress: onChat, "data-slot": "rail-chat", children: _jsx(MessageSquare, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: "Dev", on: mode === 'dev' && !here, onPress: onDev, "data-slot": "rail-dev", children: _jsx(Code2, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: "Studio", on: mode === 'studio', onPress: onStudio, "data-slot": "rail-studio", children: _jsx(WandSparkles, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: "Tabs", on: mode === 'tabs', onPress: onTabs, "data-slot": "rail-tabs", children: _jsx(SquareTerminal, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Library'), on: here === 'library', onPress: to(RAISED.library), "data-slot": "rail-library", children: _jsx(Library, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Scheduled tasks'), on: here === 'scheduled', onPress: to(RAISED.scheduled), "data-slot": "rail-scheduled", children: _jsx(Clock, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Customize'), on: here === 'customize', onPress: to(RAISED.customize), "data-slot": "rail-customize", children: _jsx(Puzzle, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Betas'), on: mode === 'beta', onPress: () => go('/beta'), "data-slot": "rail-betas", children: _jsx(FlaskConical, { size: 18, "aria-hidden": true }) }), betasDialog, rest.length ? (_jsx(DropdownMenu
|
|
129
|
+
pt: (BAND - MARK) / 2, pb: "$2", gap: 4, shrink: 0, items: "center", $touchable: { pt: (BAND - TOUCH) / 2 }, children: [toggle ? (_jsx(YStack, { pb: 4, children: _jsx(Toggle, { open: open, onPress: toggle }) })) : null, _jsx(Mark, { label: t('Chat'), on: mode === 'chat', onPress: onChat, "data-slot": "rail-chat", children: _jsx(MessageSquare, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: "Dev", on: mode === 'dev' && !here, onPress: onDev, "data-slot": "rail-dev", children: _jsx(Code2, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: "Studio", on: mode === 'studio', onPress: onStudio, "data-slot": "rail-studio", children: _jsx(WandSparkles, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: "Tabs", on: mode === 'tabs', onPress: onTabs, "data-slot": "rail-tabs", children: _jsx(SquareTerminal, { size: 18, "aria-hidden": true }) }), apps.map((a) => (_jsx(Mark, { label: a.name, on: inside === a.id, onPress: () => go(hosted(a.id)), "data-slot": `rail-app-${a.id}`, children: _jsx(a.icon, { size: 18, "aria-hidden": true }) }, a.id))), _jsx(Mark, { label: t('Library'), on: here === 'library', onPress: to(RAISED.library), "data-slot": "rail-library", children: _jsx(Library, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Scheduled tasks'), on: here === 'scheduled', onPress: to(RAISED.scheduled), "data-slot": "rail-scheduled", children: _jsx(Clock, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Customize'), on: here === 'customize', onPress: to(RAISED.customize), "data-slot": "rail-customize", children: _jsx(Puzzle, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Betas'), on: mode === 'beta', onPress: () => go('/beta'), "data-slot": "rail-betas", children: _jsx(FlaskConical, { size: 18, "aria-hidden": true }) }), betasDialog, rest.length ? (_jsx(DropdownMenu
|
|
126
130
|
// Toward the content: right of the rail, left of it right to left.
|
|
127
131
|
, {
|
|
128
132
|
// Toward the content: right of the rail, left of it right to left.
|
package/dist/lib/betas.d.ts
CHANGED
|
@@ -21,6 +21,15 @@
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const GROUPS: readonly ['Business', 'Data', 'Agents', 'Build & run', 'Security', 'Creative', 'Models'];
|
|
23
23
|
export type Group = (typeof GROUPS)[number];
|
|
24
|
+
/**
|
|
25
|
+
* How an app draws inside the Hanzo app, at /apps/<id>: its own live host in a
|
|
26
|
+
* frame (`href`, with `?embed=1`), so a deploy of the standalone app reaches
|
|
27
|
+
* hanzo.ai with no release here. A row may later name a module the app exports
|
|
28
|
+
* instead (`mount`); nothing reads it yet.
|
|
29
|
+
*/
|
|
30
|
+
export type Embed = 'frame' | {
|
|
31
|
+
mount: string;
|
|
32
|
+
};
|
|
24
33
|
export interface Beta {
|
|
25
34
|
/** Stable, lowercase, one word: the switch is `beta.<id>`. */
|
|
26
35
|
id: string;
|
|
@@ -30,6 +39,8 @@ export interface Beta {
|
|
|
30
39
|
group: Group;
|
|
31
40
|
/** Where it opens once granted; absent while it is not built as an app. */
|
|
32
41
|
href?: string;
|
|
42
|
+
/** Drawn inside the app as well, once granted (lib/hosted). */
|
|
43
|
+
embed?: Embed;
|
|
33
44
|
}
|
|
34
45
|
export declare const BETAS: readonly Beta[];
|
|
35
46
|
/** The switch of one app in beta. */
|
package/dist/lib/betas.js
CHANGED
|
@@ -24,16 +24,16 @@ export const GROUPS = ['Business', 'Data', 'Agents', 'Build & run', 'Security',
|
|
|
24
24
|
/** The developer platform, where a module in beta opens at its own address for anyone who has it. */
|
|
25
25
|
const PLATFORM = 'https://platform.hanzo.ai';
|
|
26
26
|
export const BETAS = [
|
|
27
|
-
{ id: 'crm', name: 'CRM', line: phrase('Companies, contacts and deals, per org'), group: 'Business', href:
|
|
27
|
+
{ id: 'crm', name: 'CRM', line: phrase('Companies, contacts and deals, per org'), group: 'Business', href: 'https://crm.hanzo.ai/', embed: 'frame' },
|
|
28
28
|
{ id: 'erp', name: 'ERP', line: phrase('Items, sales, purchasing, accounting and HR'), group: 'Business', href: `${PLATFORM}/erp` },
|
|
29
|
-
{ id: 'commerce', name: 'Commerce', line: phrase('Catalog, cart, checkout and orders'), group: 'Business', href: 'https://commerce-admin.hanzo.ai/admin' },
|
|
29
|
+
{ id: 'commerce', name: 'Commerce', line: phrase('Catalog, cart, checkout and orders'), group: 'Business', href: 'https://commerce-admin.hanzo.ai/admin/', embed: 'frame' },
|
|
30
30
|
{ id: 'books', name: 'Books', line: phrase('Chart of accounts, ledger and bank reconciliation'), group: 'Business' },
|
|
31
31
|
{ id: 'finance', name: 'Finance', line: phrase('One ledger for your money operations'), group: 'Business', href: 'https://finance.hanzo.ai' },
|
|
32
32
|
{ id: 'treasury', name: 'Treasury & Ledger', line: phrase('Reserves, payouts and a double-entry journal'), group: 'Business' },
|
|
33
33
|
{ id: 'dataroom', name: 'Data Room', line: phrase('Share documents and see who opened them'), group: 'Business', href: 'https://dataroom.hanzo.ai' },
|
|
34
34
|
{ id: 'sign', name: 'Sign', line: phrase('Send a PDF, get it signed, keep the record'), group: 'Business', href: 'https://esign.hanzo.ai' },
|
|
35
35
|
{ id: 'company', name: 'Company', line: phrase('Formation, documents and filings'), group: 'Business', href: `${PLATFORM}/company` },
|
|
36
|
-
{ id: 'cms', name: 'CMS', line: phrase('Pages, posts, media and navigation'), group: 'Business', href: 'https://cms.hanzo.ai/admin' },
|
|
36
|
+
{ id: 'cms', name: 'CMS', line: phrase('Pages, posts, media and navigation'), group: 'Business', href: 'https://cms.hanzo.ai/admin', embed: 'frame' },
|
|
37
37
|
{ id: 'helpdesk', name: 'Help Center', line: phrase('Tickets, teams and SLAs'), group: 'Business', href: 'https://hanzo.help' },
|
|
38
38
|
{ id: 'marketing', name: 'Marketing', line: phrase('Campaigns, audiences and email sequences'), group: 'Business', href: 'https://marketing.hanzo.ai' },
|
|
39
39
|
{ id: 'ads', name: 'Ads', line: phrase('Paid campaigns, launched and paused in one place'), group: 'Business', href: 'https://ads.hanzo.ai' },
|
|
@@ -42,8 +42,8 @@ export const BETAS = [
|
|
|
42
42
|
{ id: 'risk', name: 'Risk', line: phrase('AML monitoring and fraud on one engine'), group: 'Business', href: 'https://aml.hanzo.ai' },
|
|
43
43
|
{ id: 'idv', name: 'Identity Verification', line: phrase('KYC, KYB and AML vendors behind one interface'), group: 'Business' },
|
|
44
44
|
{ id: 'base', name: 'Base', line: phrase('Data, users, files and live updates per org'), group: 'Data', href: 'https://base.hanzo.ai' },
|
|
45
|
-
{ id: 'analytics', name: 'Analytics', line: phrase('Privacy-first product analytics'), group: 'Data', href: 'https://analytics.hanzo.ai' },
|
|
46
|
-
{ id: 'insights', name: 'Insights', line: phrase('Funnels, session replay, flags and experiments'), group: 'Data', href: 'https://insights.hanzo.ai' },
|
|
45
|
+
{ id: 'analytics', name: 'Analytics', line: phrase('Privacy-first product analytics'), group: 'Data', href: 'https://analytics.hanzo.ai', embed: 'frame' },
|
|
46
|
+
{ id: 'insights', name: 'Insights', line: phrase('Funnels, session replay, flags and experiments'), group: 'Data', href: 'https://insights.hanzo.ai', embed: 'frame' },
|
|
47
47
|
{ id: 'search', name: 'Search', line: phrase('Keyword and meaning in one query'), group: 'Data', href: `${PLATFORM}/search` },
|
|
48
48
|
{ id: 'world', name: 'World', line: phrase('A live map of every model and AI workload'), group: 'Data', href: 'https://world.hanzo.ai' },
|
|
49
49
|
{ id: 'crawl', name: 'Crawl', line: phrase('Turn a website into clean Markdown'), group: 'Data', href: `${PLATFORM}/crawl` },
|
package/dist/lib/host.d.ts
CHANGED
|
@@ -62,6 +62,13 @@ export declare const TERMINALS = "/tabs";
|
|
|
62
62
|
* Betas: ecosystem betas, early access preview, and waitlist dashboard.
|
|
63
63
|
*/
|
|
64
64
|
export declare const BETA = "/beta";
|
|
65
|
+
/**
|
|
66
|
+
* The apps in beta that stand inside the app (lib/hosted): /apps/<id>, one
|
|
67
|
+
* pane for all of them, each the live host of the standalone app in a frame.
|
|
68
|
+
*/
|
|
69
|
+
export declare const HOSTED = "/apps";
|
|
70
|
+
/** The address of one hosted app, and the page inside it (`at`, a path on its own host) when it is on one. */
|
|
71
|
+
export declare const hosted: (id: string, at?: string) => string;
|
|
65
72
|
/** Studio at an address of its own (@hanzo/studio `route`): '' is New, /studio. */
|
|
66
73
|
export declare const studio: (at: string) => string;
|
|
67
74
|
/** Chat on a conversation, or /chat itself for a new one. */
|
|
@@ -99,6 +106,9 @@ export type Place = {
|
|
|
99
106
|
mode: 'tabs';
|
|
100
107
|
} | {
|
|
101
108
|
mode: 'beta';
|
|
109
|
+
} | {
|
|
110
|
+
mode: 'hosted';
|
|
111
|
+
id: string;
|
|
102
112
|
};
|
|
103
113
|
/** The place a path names, or null when it names none of the app's. */
|
|
104
114
|
export declare function place(pathname: string): Place | null;
|
package/dist/lib/host.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import APP from './rooms.json' with { type: 'json' };
|
|
17
17
|
import { href, parse, path, route, SESSION, SLUG } from '@hanzo/build/route';
|
|
18
18
|
import { site } from '../where.js';
|
|
19
|
+
import { BETAS } from './betas.js';
|
|
19
20
|
/** The workspace's own address. */
|
|
20
21
|
export const WORKSPACE = 'https://hanzo.team';
|
|
21
22
|
/**
|
|
@@ -65,6 +66,15 @@ export const TERMINALS = '/tabs';
|
|
|
65
66
|
* Betas: ecosystem betas, early access preview, and waitlist dashboard.
|
|
66
67
|
*/
|
|
67
68
|
export const BETA = '/beta';
|
|
69
|
+
/**
|
|
70
|
+
* The apps in beta that stand inside the app (lib/hosted): /apps/<id>, one
|
|
71
|
+
* pane for all of them, each the live host of the standalone app in a frame.
|
|
72
|
+
*/
|
|
73
|
+
export const HOSTED = '/apps';
|
|
74
|
+
/** The address of one hosted app, and the page inside it (`at`, a path on its own host) when it is on one. */
|
|
75
|
+
export const hosted = (id, at) => `${HOSTED}/${id}${at ? `?at=${encodeURIComponent(at)}` : ''}`;
|
|
76
|
+
/** Whether `id` is an app in beta that draws inside the app. */
|
|
77
|
+
const inside = (id) => BETAS.some((b) => b.id === id && b.embed !== undefined);
|
|
68
78
|
/** Studio at an address of its own (@hanzo/studio `route`): '' is New, /studio. */
|
|
69
79
|
export const studio = (at) => (at ? `${STUDIO}/${at.replace(/^\/+/, '')}` : STUDIO);
|
|
70
80
|
/** Chat on a conversation, or /chat itself for a new one. */
|
|
@@ -118,6 +128,10 @@ export function place(pathname) {
|
|
|
118
128
|
return { mode: 'tabs' };
|
|
119
129
|
if (p === BETA)
|
|
120
130
|
return { mode: 'beta' };
|
|
131
|
+
if (p.startsWith(`${HOSTED}/`)) {
|
|
132
|
+
const id = p.slice(HOSTED.length + 1);
|
|
133
|
+
return inside(id) ? { mode: 'hosted', id } : null;
|
|
134
|
+
}
|
|
121
135
|
if (!p.startsWith(`${CHAT}/`))
|
|
122
136
|
return null;
|
|
123
137
|
const id = p.slice(CHAT.length + 1);
|
|
@@ -143,6 +157,8 @@ export function page(pathname) {
|
|
|
143
157
|
return STUDIO;
|
|
144
158
|
if (at.mode === 'beta')
|
|
145
159
|
return BETA;
|
|
160
|
+
if (at.mode === 'hosted')
|
|
161
|
+
return `${HOSTED}/:id`;
|
|
146
162
|
const r = route(at.at);
|
|
147
163
|
if (r.kind === 'run')
|
|
148
164
|
return `${DEV}/run/:id`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The apps that draw inside the Hanzo app: one table, derived from the apps in
|
|
3
|
+
* beta (lib/betas) that name an `embed`, so an app is listed once.
|
|
4
|
+
*
|
|
5
|
+
* Each stays a standalone app on a host of its own and deploys on its own. The
|
|
6
|
+
* pane at /apps/<id> frames that live host (`frame`), so a deploy of the
|
|
7
|
+
* standalone app reaches hanzo.ai with no release of this package. `?embed=1`
|
|
8
|
+
* asks the standalone app to leave out its own wordmark and sidebar once it
|
|
9
|
+
* knows the flag; an app that does not still works, in its own chrome.
|
|
10
|
+
*
|
|
11
|
+
* Whether a reader may open one is `opens` (lib/betas), the one predicate; this
|
|
12
|
+
* table says only what there is to open and where.
|
|
13
|
+
*/
|
|
14
|
+
import { type LucideIcon } from 'lucide-react';
|
|
15
|
+
import { type Embed } from './betas.js';
|
|
16
|
+
export interface Hosted {
|
|
17
|
+
/** The app's id: `beta.<id>` is its switch, and /apps/<id> its address. */
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
/** Its standalone host, `crm.hanzo.ai`. */
|
|
21
|
+
host: string;
|
|
22
|
+
/** Where it opens on its own: the host and the page it starts on. */
|
|
23
|
+
href: string;
|
|
24
|
+
icon: LucideIcon;
|
|
25
|
+
/** The principal switch, `beta.<id>`. */
|
|
26
|
+
flag: string;
|
|
27
|
+
/** How it is drawn: a frame of its live host today; a row may name a module instead. */
|
|
28
|
+
embed: Embed;
|
|
29
|
+
}
|
|
30
|
+
/** The apps that draw inside the app, in the order the list holds them. */
|
|
31
|
+
export declare const HOSTED_APPS: readonly Hosted[];
|
|
32
|
+
/** One hosted app by id. */
|
|
33
|
+
export declare const hostedApp: (id: string) => Hosted | undefined;
|
|
34
|
+
/** The origin of an app's host, the only one a frame of it speaks to and hears from. */
|
|
35
|
+
export declare const origin: (app: Hosted) => string;
|
|
36
|
+
/**
|
|
37
|
+
* The address the frame loads: the app's own page (`app.href`), or `at`, a path
|
|
38
|
+
* on the same host the reader was last on, with `embed=1` on it. A path that
|
|
39
|
+
* names another host or is not a path is the start page.
|
|
40
|
+
*/
|
|
41
|
+
export declare function frameUrl(app: Hosted, at?: string | null): string;
|
|
42
|
+
/** The path and query of an address on the app's own host, without `embed`, or null when it is on another. */
|
|
43
|
+
export declare function pathOn(app: Hosted, href: string): string | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The apps that draw inside the Hanzo app: one table, derived from the apps in
|
|
3
|
+
* beta (lib/betas) that name an `embed`, so an app is listed once.
|
|
4
|
+
*
|
|
5
|
+
* Each stays a standalone app on a host of its own and deploys on its own. The
|
|
6
|
+
* pane at /apps/<id> frames that live host (`frame`), so a deploy of the
|
|
7
|
+
* standalone app reaches hanzo.ai with no release of this package. `?embed=1`
|
|
8
|
+
* asks the standalone app to leave out its own wordmark and sidebar once it
|
|
9
|
+
* knows the flag; an app that does not still works, in its own chrome.
|
|
10
|
+
*
|
|
11
|
+
* Whether a reader may open one is `opens` (lib/betas), the one predicate; this
|
|
12
|
+
* table says only what there is to open and where.
|
|
13
|
+
*/
|
|
14
|
+
import { ChartColumn, ContactRound, Newspaper, ShoppingCart, Sparkles, Telescope } from 'lucide-react';
|
|
15
|
+
import { BETAS, key } from './betas.js';
|
|
16
|
+
const ICON = {
|
|
17
|
+
crm: ContactRound,
|
|
18
|
+
commerce: ShoppingCart,
|
|
19
|
+
cms: Newspaper,
|
|
20
|
+
analytics: ChartColumn,
|
|
21
|
+
insights: Telescope,
|
|
22
|
+
};
|
|
23
|
+
/** The apps that draw inside the app, in the order the list holds them. */
|
|
24
|
+
export const HOSTED_APPS = BETAS.flatMap((b) => b.embed !== undefined && b.href ? [{ id: b.id, name: b.name, host: new URL(b.href).host, href: b.href, icon: ICON[b.id] ?? Sparkles, flag: key(b.id), embed: b.embed }] : []);
|
|
25
|
+
/** One hosted app by id. */
|
|
26
|
+
export const hostedApp = (id) => HOSTED_APPS.find((a) => a.id === id);
|
|
27
|
+
/** The origin of an app's host, the only one a frame of it speaks to and hears from. */
|
|
28
|
+
export const origin = (app) => new URL(app.href).origin;
|
|
29
|
+
/**
|
|
30
|
+
* The address the frame loads: the app's own page (`app.href`), or `at`, a path
|
|
31
|
+
* on the same host the reader was last on, with `embed=1` on it. A path that
|
|
32
|
+
* names another host or is not a path is the start page.
|
|
33
|
+
*/
|
|
34
|
+
export function frameUrl(app, at) {
|
|
35
|
+
const base = new URL(app.href);
|
|
36
|
+
if (at && at.startsWith('/') && !at.startsWith('//')) {
|
|
37
|
+
const to = new URL(at, base.origin);
|
|
38
|
+
if (to.origin === base.origin)
|
|
39
|
+
return withEmbed(to);
|
|
40
|
+
}
|
|
41
|
+
return withEmbed(base);
|
|
42
|
+
}
|
|
43
|
+
function withEmbed(url) {
|
|
44
|
+
url.searchParams.set('embed', '1');
|
|
45
|
+
return url.toString();
|
|
46
|
+
}
|
|
47
|
+
/** The path and query of an address on the app's own host, without `embed`, or null when it is on another. */
|
|
48
|
+
export function pathOn(app, href) {
|
|
49
|
+
try {
|
|
50
|
+
const to = new URL(href, origin(app));
|
|
51
|
+
if (to.origin !== origin(app))
|
|
52
|
+
return null;
|
|
53
|
+
to.searchParams.delete('embed');
|
|
54
|
+
return `${to.pathname}${to.search}`;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
package/dist/where.d.ts
CHANGED
|
@@ -74,6 +74,6 @@ export declare const where: () => Addresses;
|
|
|
74
74
|
/** The product's name, as the host states it. Read at call time, like every address. */
|
|
75
75
|
export declare const brand: () => string;
|
|
76
76
|
/** The product's name in each mode of the app: the host's brand in Chat (Hanzo AI, Hanzo Team), Hanzo Dev in Dev. */
|
|
77
|
-
export declare const wordmark: (mode: 'chat' | 'dev' | 'studio' | 'tabs' | 'beta') => string;
|
|
77
|
+
export declare const wordmark: (mode: 'chat' | 'dev' | 'studio' | 'tabs' | 'beta' | 'hosted') => string;
|
|
78
78
|
/** A page of the app's own, from wherever the rooms are mounted. */
|
|
79
79
|
export declare const site: (path: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.40",
|
|
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",
|