@hanzo/build 0.2.22 → 0.2.24
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/lib/api/projects.d.ts +4 -0
- package/lib/api/projects.js +2 -0
- package/lib/builder.js +4 -4
- package/lib/foot.d.ts +14 -0
- package/lib/foot.js +29 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/project.js +15 -3
- package/package.json +1 -1
package/lib/api/projects.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface Project {
|
|
|
24
24
|
live: string;
|
|
25
25
|
/** `public` or `private`, or '' when the platform did not say. */
|
|
26
26
|
visibility: '' | Visibility;
|
|
27
|
+
/** The catalog template's slug, or `<org>/<slug>` of the published project, this was taken from; '' for neither. */
|
|
28
|
+
forked: string;
|
|
27
29
|
/** Unix seconds; 0 when unknown. A deploy does not move `updated`. */
|
|
28
30
|
created: number;
|
|
29
31
|
updated: number;
|
|
@@ -51,6 +53,8 @@ export interface Template {
|
|
|
51
53
|
framework: string;
|
|
52
54
|
/** The repository the starter is cut from. */
|
|
53
55
|
source: string;
|
|
56
|
+
/** The starter's own live page, or '' when it has none the preview may frame. */
|
|
57
|
+
demo: string;
|
|
54
58
|
}
|
|
55
59
|
/** The public catalog. It is reference content: no bearer, no org. */
|
|
56
60
|
export declare function templates(t: Target): Promise<Template[]>;
|
package/lib/api/projects.js
CHANGED
|
@@ -44,6 +44,7 @@ export function project(raw) {
|
|
|
44
44
|
status: str(p.status),
|
|
45
45
|
live: safe(str(p.liveUrl)),
|
|
46
46
|
visibility: p.visibility === 'public' || p.visibility === 'private' ? p.visibility : '',
|
|
47
|
+
forked: str(p.forkedFrom),
|
|
47
48
|
created: num(p.createdAt),
|
|
48
49
|
updated: num(p.updatedAt),
|
|
49
50
|
};
|
|
@@ -92,6 +93,7 @@ export async function templates(t) {
|
|
|
92
93
|
description: str(o.description),
|
|
93
94
|
framework: str(o.framework),
|
|
94
95
|
source: str(o.source),
|
|
96
|
+
demo: safe(str(o.demo)),
|
|
95
97
|
};
|
|
96
98
|
})
|
|
97
99
|
.filter((x) => x.slug);
|
package/lib/builder.js
CHANGED
|
@@ -47,7 +47,7 @@ import { Run } from './run.js';
|
|
|
47
47
|
import { DOTS } from './section.js';
|
|
48
48
|
import { Artifacts, Templates } from './shelf.js';
|
|
49
49
|
import { Find } from './find.js';
|
|
50
|
-
import { DOCS, Slack, Who } from './foot.js';
|
|
50
|
+
import { DOCS, Slack, useWho, Who } from './foot.js';
|
|
51
51
|
import { Settings } from './settings/index.js';
|
|
52
52
|
function Shell() {
|
|
53
53
|
const host = useHost();
|
|
@@ -58,7 +58,7 @@ function Shell() {
|
|
|
58
58
|
const [drawer, setDrawer] = useState(false);
|
|
59
59
|
const [order, setOrder] = useState('newest');
|
|
60
60
|
const [finding, setFinding] = useState(false);
|
|
61
|
-
const
|
|
61
|
+
const who = useWho();
|
|
62
62
|
const [slack, setSlack] = useKept('hanzo.build.slack', false);
|
|
63
63
|
const go = (p) => {
|
|
64
64
|
setDrawer(false);
|
|
@@ -82,10 +82,10 @@ function Shell() {
|
|
|
82
82
|
name: [host.person.name || host.person.email, host.org].filter(Boolean).join(' · '),
|
|
83
83
|
onPress: () => {
|
|
84
84
|
setDrawer(false);
|
|
85
|
-
|
|
85
|
+
who.toggle();
|
|
86
86
|
},
|
|
87
87
|
}
|
|
88
|
-
: { name: 'Sign in', onPress: () => host.signIn?.() }, collapsed: collapsed, onCollapse: setCollapsed, mark: _jsx(Brand, { org: host.org }), pt: collapsed ? undefined : 92, open: drawer, onOpenChange: setDrawer, label: "Runs" }), collapsed ? null : (_jsxs(YStack, { position: "absolute", t: 10, l: 8, r: 8, z: 2, gap: "$2.5", "$max-md": { display: 'none' }, children: [_jsx(XStack, { px: "$2.5", children: name }), _jsxs(XStack, { render: "button", "aria-label": "Search runs", onPress: () => setFinding(true), items: "center", gap: "$2", px: "$2.5", height: 34, rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", hoverStyle: { bg: '$hover' }, children: [_jsx(Search, { size: 15, color: "$soft" }), _jsx(SizableText, { size: "$2", color: "$soft", children: "Search" })] })] })), host.person ? _jsx(Who, { open:
|
|
88
|
+
: { name: 'Sign in', onPress: () => host.signIn?.() }, collapsed: collapsed, onCollapse: setCollapsed, mark: _jsx(Brand, { org: host.org }), pt: collapsed ? undefined : 92, open: drawer, onOpenChange: setDrawer, label: "Runs" }), collapsed ? null : (_jsxs(YStack, { position: "absolute", t: 10, l: 8, r: 8, z: 2, gap: "$2.5", "$max-md": { display: 'none' }, children: [_jsx(XStack, { px: "$2.5", children: name }), _jsxs(XStack, { render: "button", "aria-label": "Search runs", onPress: () => setFinding(true), items: "center", gap: "$2", px: "$2.5", height: 34, rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", hoverStyle: { bg: '$hover' }, children: [_jsx(Search, { size: 15, color: "$soft" }), _jsx(SizableText, { size: "$2", color: "$soft", children: "Search" })] })] })), host.person ? _jsx(Who, { open: who.open, onOpenChange: who.onOpenChange, narrow: collapsed }) : null] }), _jsxs(YStack, { flex: 1, minW: 0, minH: 0, position: "relative", children: [_jsxs(XStack, { height: 44, px: "$2", gap: "$2", items: "center", shrink: 0, $md: { display: 'none' }, children: [_jsx(Button, { variant: "ghost", size: "icon-sm", onPress: () => setDrawer(true), "aria-label": "Open runs", children: _jsx(Menu, { size: 18 }) }), name, _jsx(XStack, { flex: 1 }), _jsx(Button, { variant: "ghost", size: "icon-sm", onPress: () => setFinding(true), "aria-label": "Search runs", children: _jsx(Search, { size: 18 }) })] }), _jsx(Pane, { onStarted: () => recents.reload() })] }), _jsx(Find, { open: finding, onOpenChange: setFinding, recents: rows, onOpen: (id) => { setFinding(false); go(id); } })] }));
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* The builder's places, as a rail draws them: four in view and the rest under
|
package/lib/foot.d.ts
CHANGED
|
@@ -4,6 +4,20 @@ export declare function Slack({ onOpen, onDismiss }: {
|
|
|
4
4
|
onOpen: () => void;
|
|
5
5
|
onDismiss: () => void;
|
|
6
6
|
}): import("react").JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* The account menu's open state, for whatever row opens it.
|
|
9
|
+
*
|
|
10
|
+
* The row that opens the menu lies outside it, so a press on the row while the
|
|
11
|
+
* menu is open reaches the popover first as a press outside, which closes it —
|
|
12
|
+
* and a row that then simply opened it put it straight back, a flicker instead
|
|
13
|
+
* of a close. So the open state is noted as each press BEGINS, before the popover
|
|
14
|
+
* acts on it, and `toggle` (the row's press) closes a menu that was open then.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useWho(): {
|
|
17
|
+
open: boolean;
|
|
18
|
+
onOpenChange: (o: boolean) => void;
|
|
19
|
+
toggle: () => void;
|
|
20
|
+
};
|
|
7
21
|
/**
|
|
8
22
|
* The account menu. The rail draws the account row and says when it was pressed,
|
|
9
23
|
* so the menu hangs off an anchor laid over the rail's foot: above it on the
|
package/lib/foot.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
6
6
|
* Everything it opens is an address of this page, but help, which is the
|
|
7
7
|
* documentation.
|
|
8
8
|
*/
|
|
9
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
10
|
import { Popover, SizableText, XStack, YStack } from '@hanzo/gui';
|
|
10
11
|
import { Gauge, LifeBuoy, LogOut, Settings, Slack as Mark, Sparkles, X } from '@hanzogui/lucide-icons-2';
|
|
11
12
|
import { MenuLabel, MenuRow, MenuRule } from '@hanzo/ui/product';
|
|
@@ -16,6 +17,34 @@ export const DOCS = 'https://docs.hanzo.ai/docs/dev';
|
|
|
16
17
|
export function Slack({ onOpen, onDismiss }) {
|
|
17
18
|
return (_jsxs(XStack, { items: "center", gap: "$2.5", px: "$3", py: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsx(Mark, { size: 16 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: "Try Hanzo in Slack" }), _jsx(XStack, { render: "button", "aria-label": "Set up Hanzo in Slack", onPress: onOpen, cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: "$soft", textDecorationLine: "underline", children: "Set up" }) })] }), _jsx(XStack, { render: "button", "aria-label": "Dismiss", onPress: onDismiss, p: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(X, { size: 14 }) })] }));
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The account menu's open state, for whatever row opens it.
|
|
22
|
+
*
|
|
23
|
+
* The row that opens the menu lies outside it, so a press on the row while the
|
|
24
|
+
* menu is open reaches the popover first as a press outside, which closes it —
|
|
25
|
+
* and a row that then simply opened it put it straight back, a flicker instead
|
|
26
|
+
* of a close. So the open state is noted as each press BEGINS, before the popover
|
|
27
|
+
* acts on it, and `toggle` (the row's press) closes a menu that was open then.
|
|
28
|
+
*/
|
|
29
|
+
export function useWho() {
|
|
30
|
+
const [open, setOpen] = useState(false);
|
|
31
|
+
const shown = useRef(open);
|
|
32
|
+
shown.current = open;
|
|
33
|
+
const began = useRef(false);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const down = () => {
|
|
36
|
+
began.current = shown.current;
|
|
37
|
+
};
|
|
38
|
+
document.addEventListener('pointerdown', down, true);
|
|
39
|
+
return () => document.removeEventListener('pointerdown', down, true);
|
|
40
|
+
}, []);
|
|
41
|
+
const toggle = useCallback(() => {
|
|
42
|
+
const was = began.current || shown.current;
|
|
43
|
+
began.current = false;
|
|
44
|
+
setOpen(!was);
|
|
45
|
+
}, []);
|
|
46
|
+
return { open, onOpenChange: setOpen, toggle };
|
|
47
|
+
}
|
|
19
48
|
/**
|
|
20
49
|
* The account menu. The rail draws the account row and says when it was pressed,
|
|
21
50
|
* so the menu hangs off an anchor laid over the rail's foot: above it on the
|
package/lib/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
export { Builder, nav } from './builder.tsx';
|
|
13
13
|
export { DevSection, DOTS, useSessions } from './section.tsx';
|
|
14
14
|
export { HostProvider } from './host.tsx';
|
|
15
|
-
export { Slack, Who } from './foot.tsx';
|
|
15
|
+
export { Slack, useWho, Who } from './foot.tsx';
|
|
16
16
|
export { administers } from './claims.ts';
|
|
17
17
|
export type { Host, Person } from './host.tsx';
|
|
18
18
|
export type { Session, Status } from './api/sessions.ts';
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
export { Builder, nav } from './builder.js';
|
|
13
13
|
export { DevSection, DOTS, useSessions } from './section.js';
|
|
14
14
|
export { HostProvider } from './host.js';
|
|
15
|
-
export { Slack, Who } from './foot.js';
|
|
15
|
+
export { Slack, useWho, Who } from './foot.js';
|
|
16
16
|
export { administers } from './claims.js';
|
|
17
17
|
export { path, route, SESSION, SLUG } from './route.js';
|
package/lib/project.js
CHANGED
|
@@ -28,7 +28,7 @@ import { HanzoMark } from '@hanzo/ui/product';
|
|
|
28
28
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
29
29
|
import { start } from './api/coding.js';
|
|
30
30
|
import { blob, tree } from './api/git.js';
|
|
31
|
-
import { name as repoName, ours } from './api/projects.js';
|
|
31
|
+
import { name as repoName, ours, templates } from './api/projects.js';
|
|
32
32
|
import { list, message, stop } from './api/sessions.js';
|
|
33
33
|
import { outcome, pull, said, who } from './api/turn.js';
|
|
34
34
|
import { verdict as record } from './api/verdict.js';
|
|
@@ -124,7 +124,13 @@ export function Project({ slug }) {
|
|
|
124
124
|
.filter((e) => !e.dir && /\.html?$/i.test(e.name) && !/^index\.html?$/i.test(e.name))
|
|
125
125
|
.map((e) => ({ id: `/${e.path}`, label: e.name.replace(/\.html?$/i, '') })),
|
|
126
126
|
], [root.value]);
|
|
127
|
-
|
|
127
|
+
// A project taken from a starter and not yet published shows the starter's own
|
|
128
|
+
// live page, which is what the copy is until its first publish.
|
|
129
|
+
const forked = project && !project.live ? project.forked : '';
|
|
130
|
+
const starters = useRead(forked ? () => templates(t) : null, [], [t.api, forked]);
|
|
131
|
+
const starter = forked ? starters.value.find((s) => s.slug === forked && s.demo) : undefined;
|
|
132
|
+
const shown = project?.live || starter?.demo || '';
|
|
133
|
+
const src = shown ? new URL(page, shown).toString() : null;
|
|
128
134
|
const lines = useMemo(() => [
|
|
129
135
|
...run.events
|
|
130
136
|
.filter((e) => e.kind === 'log' || e.kind === 'tool-call' || e.kind === 'status')
|
|
@@ -221,7 +227,13 @@ export function Project({ slug }) {
|
|
|
221
227
|
}
|
|
222
228
|
const chat = (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$3", py: "$4", gap: "$4", children: ordered.length === 0 ? (_jsx(SizableText, { size: "$2", color: "$ink", px: "$2", children: runs.loading
|
|
223
229
|
? 'Reading this project’s runs…'
|
|
224
|
-
:
|
|
230
|
+
: project?.live
|
|
231
|
+
? `${project.name} is loaded — it is in the preview, and every run on it is under the clock above. Say what to change and it gets built.`
|
|
232
|
+
: starter
|
|
233
|
+
? `${project?.name} is loaded — the preview shows the ${starter.title} starter until your copy is published. Say what to change and it gets built.`
|
|
234
|
+
: project
|
|
235
|
+
? `${project.name} is loaded and nothing is published yet. Say what to change and it gets built.`
|
|
236
|
+
: `${slug} is loaded. Say what to change and it gets built.` })) : (ordered.map((r) => (_jsxs(YStack, { gap: "$2", children: [_jsx(Turn, { run: r, open: r.id === current, onOpen: () => setChosen(r.id), project: slug }), r.id === current ? (_jsxs(YStack, { gap: "$1", pl: "$2", borderLeftWidth: 1, borderColor: "$borderColor", children: [fold(run.events.map((e) => ({ kind: e.kind, actor: who(e.actor), seq: e.seq, id: e.id, text: said(e, run.record?.mode) })).filter((b) => b.text)).map((b) => (_jsx(SizableText, { size: "$1", color: "$soft", children: b.text }, b.key))), pr.href ? (_jsxs(Out, { href: pr.href, label: `Open pull request ${pr.label}`, children: [_jsxs(SizableText, { size: "$1", color: "$ink", textDecorationLine: "underline", children: ["Pull request ", pr.label] }), _jsx(ExternalLink, { size: 11 })] })) : null] })) : null] }, r.id)))) }), _jsxs(YStack, { px: "$3", pb: "$3", gap: "$2", children: [!dismissed && !running ? _jsx(Suggestions, { items: SUGGESTIONS, onPick: (s) => void send(s), onDismiss: () => setDismissed(true) }) : null, note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note })) : null, picked.length ? _jsx(Attachments, { items: picked, onRemove: () => setPicked([]) }) : null, attached.length ? (_jsx(XStack, { gap: 6, flexWrap: "wrap", children: _jsx(Files, { files: attached, onFiles: setAttached }) })) : null, _jsxs(Composer, { value: draft, onChange: setDraft, onSend: () => void (current && running ? steer(current) : send()), onStop: current
|
|
225
237
|
? () => void stop(t, current).then(() => setNote('Stop requested — the run keeps its work on its branch'), (e) => setNote(e.message))
|
|
226
238
|
: undefined, busy: busy || (running && !draft.trim()), rows: 3, placeholder: running ? 'Steer this run' : 'Ask Hanzo for edits', label: "Ask Hanzo for edits", children: [_jsx(Attach, { files: attached, onFiles: setAttached, onNote: setNote }), _jsx(XStack, { flex: 1 }), _jsx(ModeSelect, { modes: MODES, value: mode, onChange: (m) => setMode(m), self: "center" }), _jsx(Dictate, { onText: (said) => setDraft((d) => (d ? `${d} ${said}` : said)), onNote: setNote })] })] })] }));
|
|
227
239
|
const body = view === 'preview' ? (_jsx(PreviewFrame, { ref: frame, src: src, title: `${project?.name ?? slug} preview`, device: device, onBridge: onBridge, empty: _jsxs(YStack, { items: "center", gap: "$2", p: "$6", children: [_jsx(SizableText, { size: "$3", color: "$ink", children: "Nothing deployed yet" }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: "Publish this project and its page appears here." })] }), toolbar: bridge ? (_jsx(XStack, { render: "button", "aria-pressed": editing, "aria-label": editing ? 'Stop picking elements' : 'Pick an element to edit', onPress: () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.",
|