@hanzo/studio 0.1.16 → 0.1.18
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/source.d.ts +6 -0
- package/lib/source.js +16 -0
- package/lib/talk.js +5 -4
- package/package.json +1 -1
package/lib/source.d.ts
CHANGED
|
@@ -60,6 +60,12 @@ export type Address = {
|
|
|
60
60
|
export declare function address(raw: string): Address;
|
|
61
61
|
/** The web addresses a message names, in order, at most `NAMED`. */
|
|
62
62
|
export declare function named(text: string): string[];
|
|
63
|
+
/**
|
|
64
|
+
* Whether a message is about the pages it names, so they are read before it goes: an address alone, or words
|
|
65
|
+
* that ask something of the page (`INTENT`). Any other link stays words, read by nobody: a page is never read,
|
|
66
|
+
* metered and carried in every later turn because a message happened to mention it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function about(text: string): boolean;
|
|
63
69
|
/** Whether a message is an address alone: what pasting a link into the composer leaves. */
|
|
64
70
|
export declare const bare: (text: string) => boolean;
|
|
65
71
|
/**
|
package/lib/source.js
CHANGED
|
@@ -106,6 +106,22 @@ export function named(text) {
|
|
|
106
106
|
}
|
|
107
107
|
return out;
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* What a message asks of a page it names, in its other words: to remake it, judge it, or make something from it
|
|
111
|
+
* (`redesign acme.com`, `what do you think of …`, `a poster from acme.com`). A link mentioned in passing (`put
|
|
112
|
+
* acme.com in the footer`) asks nothing of the page.
|
|
113
|
+
*/
|
|
114
|
+
const INTENT = /\b(?:re-?design|re-?build|re-?make|re-?vamp|re-?style|re-?work|critique|review|audit|improve|moderni[sz]e|refresh|clone|inspired by|based on|what do you think)\b|\b(?:from|like|of|about)\s+(?:the\s+|this\s+|that\s+)?(?:(?:web\s*)?page\s+|site\s+|website\s+)?LINK\b/i;
|
|
115
|
+
/**
|
|
116
|
+
* Whether a message is about the pages it names, so they are read before it goes: an address alone, or words
|
|
117
|
+
* that ask something of the page (`INTENT`). Any other link stays words, read by nobody: a page is never read,
|
|
118
|
+
* metered and carried in every later turn because a message happened to mention it.
|
|
119
|
+
*/
|
|
120
|
+
export function about(text) {
|
|
121
|
+
if (!named(text).length)
|
|
122
|
+
return false;
|
|
123
|
+
return bare(text) || INTENT.test(text.replace(LINK, ' LINK '));
|
|
124
|
+
}
|
|
109
125
|
/** Whether a message is an address alone: what pasting a link into the composer leaves. */
|
|
110
126
|
export const bare = (text) => {
|
|
111
127
|
const t = text.trim();
|
package/lib/talk.js
CHANGED
|
@@ -30,7 +30,7 @@ import { BRAIN, touch, useAvailable, useLibrary, useWire, WRITER } from './live.
|
|
|
30
30
|
import { blank, current } from './made.js';
|
|
31
31
|
import { path } from './route.js';
|
|
32
32
|
import { take } from './starters.js';
|
|
33
|
-
import { bare, named, readPage, shown, sourced } from './source.js';
|
|
33
|
+
import { about, bare, named, readPage, shown, sourced } from './source.js';
|
|
34
34
|
import { useUrl } from './use.js';
|
|
35
35
|
import { put } from './wire.js';
|
|
36
36
|
/** The conversations open in this page, by id: an address change does not drop the one in hand. */
|
|
@@ -211,8 +211,9 @@ function Conversation({ start, host, wire, available }) {
|
|
|
211
211
|
}
|
|
212
212
|
const ctl = new AbortController();
|
|
213
213
|
setWorking(ctl);
|
|
214
|
-
// A page the message
|
|
215
|
-
|
|
214
|
+
// A page the message is about is read before it goes: a source, like one added from the field. A link
|
|
215
|
+
// mentioned in passing stays words (source.ts `about`).
|
|
216
|
+
const pages = about(words) ? await readSources(named(words), ctl.signal) : [];
|
|
216
217
|
if (!pages || ctl.signal.aborted) {
|
|
217
218
|
setWorking(null);
|
|
218
219
|
return;
|
|
@@ -484,7 +485,7 @@ function Conversation({ start, host, wire, available }) {
|
|
|
484
485
|
const tools = (_jsx(TooltipProvider, { delay: 200, children: _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", maxW: "100%", children: [_jsxs(Tooltip, { placement: "top", offset: 6, open: openMenu === 'source' ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", children: _jsx(DropdownMenu, { onOpenChange: (o) => setOpenMenu(o ? 'source' : null), trigger: _jsx(Pillish, { label: "Source", "aria-label": `Source: ${sourceValue} (design from a web page or a file)`, icon: _jsx(Globe, { size: 12, color: "$soft" }), value: sourceValue, open: openMenu === 'source' }), items: sourceItems }) }) }), _jsx(TooltipContent, { children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Start from a web page or a file" }) })] }), _jsxs(Tooltip, { placement: "top", offset: 6, open: openMenu === 'format' ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", children: _jsx(DropdownMenu, { onOpenChange: (o) => setOpenMenu(o ? 'format' : null), trigger: _jsx(Pillish, { label: "Format", icon: _jsx(Sparkles, { size: 12, color: "$soft" }), value: formatValue, open: openMenu === 'format' }), items: kindItems }) }) }), _jsx(TooltipContent, { children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Output format \u2014 Auto picks from what you ask" }) })] }), _jsxs(Tooltip, { placement: "top", offset: 6, open: openMenu === 'brand' ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", children: _jsx(DropdownMenu, { onOpenChange: (o) => setOpenMenu(o ? 'brand' : null), trigger: _jsx(Pillish, { label: "Brand", icon: _jsx(Palette, { size: 12, color: "$soft" }), value: brandName, open: openMenu === 'brand' }), items: brandItems }) }) }), _jsx(TooltipContent, { children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Brand & type system used for typography and palette" }) })] }), _jsxs(Tooltip, { placement: "top", offset: 6, open: openMenu === 'options' ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", children: _jsx(DropdownMenu, { onOpenChange: (o) => setOpenMenu(o ? 'options' : null), trigger: _jsx(Pillish, { label: "Options", "aria-label": `Options: ${optionsValue} (image model, aspect ratio, count)`, icon: _jsx(SlidersHorizontal, { size: 12, color: "$soft" }), value: optionsValue, open: openMenu === 'options' }), items: optionItems }) }) }), _jsx(TooltipContent, { children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Image model, aspect ratio, and variant count" }) })] })] }) }));
|
|
485
486
|
const showRefinementChips = Boolean(activeStarter || draft.trim().length > 0);
|
|
486
487
|
const pasted = bare(draft) && !sources.some((p) => p.url === named(draft)[0]) ? named(draft)[0] : '';
|
|
487
|
-
const head = attached.length || uploading || uploadError || showRefinementChips || linking || sources.length || reading.length || sourceError || pasted ? (_jsxs(YStack, { gap: "$2", width: "100%", minW: 0, children: [sourceError ? (_jsxs(XStack, { role: "alert", "data-slot": "source-error", items: "center", justify: "space-between", gap: "$2", px: "$2.5", py: "$1.5", rounded: "$3", bg: "var(--state-error-bg)", borderWidth: 1, borderColor: "var(--state-error)", children: [_jsx(SizableText, { size: "$1", color: "var(--state-error)", flex: 1, minW: 0, children: sourceError }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Dismiss", onClick: () => setSourceError(''), width: 20, height: 20, rounded: 99, items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: _jsx(X, { size: 11, color: "var(--state-error)" }) })] })) : null, linking ? (_jsxs(XStack, { "data-slot": "source-field", render: _jsx("form", {
|
|
488
|
+
const head = attached.length || uploading || uploadError || showRefinementChips || linking || sources.length || reading.length || sourceError || pasted ? (_jsxs(YStack, { gap: "$2", width: "100%", minW: 0, rounded: "$3", "data-slot": "composer-extras", style: { background: 'linear-gradient(var(--pane-fill, transparent), var(--pane-fill, transparent)), var(--background)' }, children: [sourceError ? (_jsxs(XStack, { role: "alert", "data-slot": "source-error", items: "center", justify: "space-between", gap: "$2", px: "$2.5", py: "$1.5", rounded: "$3", bg: "var(--state-error-bg)", borderWidth: 1, borderColor: "var(--state-error)", children: [_jsx(SizableText, { size: "$1", color: "var(--state-error)", flex: 1, minW: 0, children: sourceError }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Dismiss", onClick: () => setSourceError(''), width: 20, height: 20, rounded: 99, items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: _jsx(X, { size: 11, color: "var(--state-error)" }) })] })) : null, linking ? (_jsxs(XStack, { "data-slot": "source-field", render: _jsx("form", {
|
|
488
489
|
// Design reads the address itself (source.ts `address`): a bare example.com is a page, and a refusal is said in words.
|
|
489
490
|
noValidate: true, onSubmit: (e) => {
|
|
490
491
|
e.preventDefault();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/studio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"description": "Hanzo Studio: a chat that makes images, posters, documents, slides, type systems, 3D, video and sound, with every result open in a tab beside it. Mounted by the Hanzo app at hanzo.ai/studio and served whole at studio.hanzo.ai.",
|