@hanzo/build 0.2.121 → 0.2.122
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/data.js +24 -4
- package/lib/shelf.js +5 -4
- package/package.json +1 -1
package/lib/data.js
CHANGED
|
@@ -114,13 +114,32 @@ export function useCached(key, load, initial, wait = WAIT) {
|
|
|
114
114
|
}, [key, tick, wait]);
|
|
115
115
|
return { value, error, loading, reload };
|
|
116
116
|
}
|
|
117
|
+
/** Last coding runs read per `api\norg`, so mounting another rail or switching tabs starts warm. */
|
|
118
|
+
const recentRuns = new Map();
|
|
117
119
|
/**
|
|
118
120
|
* The org's coding runs, newest first, kept current by the org's own session
|
|
119
121
|
* stream: a status that moves moves its dot, and a run started anywhere appears.
|
|
120
122
|
*/
|
|
121
123
|
export function useRecents(t, signed) {
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
+
const scope = signed ? `${t.api}\n${t.org ?? ''}` : null;
|
|
125
|
+
const warm = scope !== null ? recentRuns.get(scope) : undefined;
|
|
126
|
+
const read = useRead(signed
|
|
127
|
+
? async () => {
|
|
128
|
+
const next = await list(t, { kind: 'coding', limit: 50 });
|
|
129
|
+
if (scope !== null)
|
|
130
|
+
recentRuns.set(scope, next);
|
|
131
|
+
return next;
|
|
132
|
+
}
|
|
133
|
+
: null, warm ?? [], [t.api, t.org, signed]);
|
|
134
|
+
const [settled, setSettled] = useState(warm !== undefined);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
setSettled(scope !== null && recentRuns.has(scope));
|
|
137
|
+
}, [scope]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!read.loading)
|
|
140
|
+
setSettled(true);
|
|
141
|
+
}, [read.loading]);
|
|
142
|
+
const [rows, setRows] = useState(() => warm ?? read.value);
|
|
124
143
|
useEffect(() => setRows(read.value), [read.value]);
|
|
125
144
|
const last = useRef(0);
|
|
126
145
|
// useRead's reload is the same function every render, so it never reopens the feed.
|
|
@@ -143,7 +162,8 @@ export function useRecents(t, signed) {
|
|
|
143
162
|
const i = prev.findIndex((r) => r.id === s.id);
|
|
144
163
|
if (i === -1) {
|
|
145
164
|
// A run this list has not seen: re-read rather than guess its kind.
|
|
146
|
-
|
|
165
|
+
if (!s.kind || s.kind === 'coding')
|
|
166
|
+
reload();
|
|
147
167
|
return prev;
|
|
148
168
|
}
|
|
149
169
|
const next = prev.slice();
|
|
@@ -159,7 +179,7 @@ export function useRecents(t, signed) {
|
|
|
159
179
|
});
|
|
160
180
|
return () => ctl.abort();
|
|
161
181
|
}, [t, signed, again]);
|
|
162
|
-
return { ...read, value: rows };
|
|
182
|
+
return { ...read, value: rows, loading: read.loading && !settled };
|
|
163
183
|
}
|
|
164
184
|
export function usePlaces(t, signed) {
|
|
165
185
|
return useRead(signed ? () => places(t) : null, [], [t, signed]);
|
package/lib/shelf.js
CHANGED
|
@@ -19,7 +19,7 @@ import { Address, Confirm, Rename } from './ask.js';
|
|
|
19
19
|
import { useProjects, useRead } from './data.js';
|
|
20
20
|
import { useHost, useTarget } from './host.js';
|
|
21
21
|
import { Out } from './out.js';
|
|
22
|
-
const SHOTS = 'https://hanzo.ai/templates';
|
|
22
|
+
const SHOTS = ['/templates', 'https://gallery.hanzo.ai/screenshots', 'https://hanzo.ai/templates'];
|
|
23
23
|
function Head({ title, says }) {
|
|
24
24
|
return (_jsxs(YStack, { gap: "$1", pb: "$4", children: [_jsx(SizableText, { render: "h1", size: "$6", color: "$ink", children: title }), _jsx(SizableText, { size: "$2", color: "$soft", children: says })] }));
|
|
25
25
|
}
|
|
@@ -134,13 +134,14 @@ export function Sites() {
|
|
|
134
134
|
* anchored at its top edge, so nothing of the page's header is cropped away.
|
|
135
135
|
*/
|
|
136
136
|
function Shot({ slug }) {
|
|
137
|
-
const [
|
|
138
|
-
|
|
137
|
+
const [step, setStep] = useState(0);
|
|
138
|
+
const base = SHOTS[step];
|
|
139
|
+
return (_jsxs(YStack, { width: "100%", aspectRatio: 16 / 10, bg: "$hover", items: "center", justify: "center", position: "relative", overflow: "hidden", children: [_jsxs(YStack, { items: "center", gap: "$2", opacity: 0.6, children: [_jsx(Boxes, { size: 24 }), _jsx(SizableText, { size: "$1", color: "$soft", textTransform: "uppercase", letterSpacing: 1, children: slug })] }), base ? (_jsx("img", { src: `${base}/${encodeURIComponent(slug)}.webp`, alt: "", loading: "lazy", onError: () => setStep((s) => s + 1), style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'top' } })) : null] }));
|
|
139
140
|
}
|
|
140
141
|
export function Templates() {
|
|
141
142
|
const { t: say } = useI18n();
|
|
142
143
|
const t = useTarget();
|
|
143
144
|
const list = useRead(() => templates(t), [], [t.api]);
|
|
144
145
|
const { busy, failed, take } = useFork();
|
|
145
|
-
return (_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$6", py: "$6", items: "center", children: _jsxs(YStack, { width: "100%", maxW: 1080, children: [_jsx(Head, { title: say('Templates'), says: `${say('Start from a working app.')} ${say('Picking one copies its repository into a project of yours.')}` }), failed ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", pb: "$3", children: failed })) : null, list.error ? (_jsx(SizableText, { size: "$2", color: "$soft", children: say(list.error.message) })) : list.loading && !list.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", children: say('Reading templates…') })) : !list.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", children: `${say('No templates here right now.')} ${say('The whole catalog has more.')}` })) : (_jsx(XStack, { flexWrap: "wrap", gap: "$3", children: list.value.map((x) => (_jsxs(Card, { label: say('Start from {template}', { template: x.title }), onPress: () => void take(x.slug), children: [_jsx(Shot, { slug: x.slug }), _jsxs(YStack, { p: "$3", gap: "$1", children: [
|
|
146
|
+
return (_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$6", py: "$6", items: "center", children: _jsxs(YStack, { width: "100%", maxW: 1080, children: [_jsx(Head, { title: say('Templates'), says: `${say('Start from a working app.')} ${say('Picking one copies its repository into a project of yours.')}` }), failed ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", pb: "$3", children: failed })) : null, list.error ? (_jsx(SizableText, { size: "$2", color: "$soft", children: say(list.error.message) })) : list.loading && !list.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", children: say('Reading templates…') })) : !list.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", children: `${say('No templates here right now.')} ${say('The whole catalog has more.')}` })) : (_jsx(XStack, { flexWrap: "wrap", gap: "$3", children: list.value.map((x) => (_jsxs(Card, { label: say('Start from {template}', { template: x.title }), onPress: () => void take(x.slug), children: [_jsx(Shot, { slug: x.slug }), _jsxs(YStack, { p: "$3", gap: "$1", children: [_jsx(SizableText, { size: "$3", color: "$ink", numberOfLines: 1, children: busy === x.slug ? say('Copying…') : x.title }), x.framework ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: x.framework })) : null, _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: x.description })] })] }, x.slug))) })), _jsx(YStack, { pt: "$5", children: _jsxs(Out, { href: "https://gallery.hanzo.ai", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: say('The whole catalog') }), _jsx(ExternalLink, { size: 12, opacity: 0.6 })] }) })] }) }));
|
|
146
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.122",
|
|
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.",
|