@oxy.so/bloom 23.9.1 → 23.10.0
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/docs/bloom-lang-spec.mdx +730 -0
- package/docs/bloom-language-for-agents.mdx +18 -4
- package/docs/bloom-language-getting-started.mdx +2 -1
- package/docs/bloom-language-modifiers.mdx +16 -6
- package/docs/bloom-language-nodes.mdx +1296 -435
- package/docs/bloom-language-tour.mdx +54 -9
- package/docs/bloom-language.mdx +30 -2
- package/docs/task-catalog.json +1 -1
- package/docs/task-catalog.mdx +1 -1
- package/lib/commonjs/agent-avatar/VectorCharacterAvatar.js +18 -10
- package/lib/commonjs/agent-avatar/VectorCharacterAvatar.js.map +1 -1
- package/lib/commonjs/agent-avatar/VectorStaticPortrait.js +102 -77
- package/lib/commonjs/agent-avatar/VectorStaticPortrait.js.map +1 -1
- package/lib/commonjs/agent-avatar/vector-halo.js +57 -0
- package/lib/commonjs/agent-avatar/vector-halo.js.map +1 -0
- package/lib/commonjs/avatar/Avatar.js +65 -62
- package/lib/commonjs/avatar/Avatar.js.map +1 -1
- package/lib/commonjs/avatar/CharacterFace.js +50 -45
- package/lib/commonjs/avatar/CharacterFace.js.map +1 -1
- package/lib/commonjs/avatar-group/AvatarGroupBase.js +311 -244
- package/lib/commonjs/avatar-group/AvatarGroupBase.js.map +1 -1
- package/lib/module/agent-avatar/VectorCharacterAvatar.js +18 -10
- package/lib/module/agent-avatar/VectorCharacterAvatar.js.map +1 -1
- package/lib/module/agent-avatar/VectorStaticPortrait.js +103 -78
- package/lib/module/agent-avatar/VectorStaticPortrait.js.map +1 -1
- package/lib/module/agent-avatar/vector-halo.js +52 -0
- package/lib/module/agent-avatar/vector-halo.js.map +1 -0
- package/lib/module/avatar/Avatar.js +65 -62
- package/lib/module/avatar/Avatar.js.map +1 -1
- package/lib/module/avatar/CharacterFace.js +50 -45
- package/lib/module/avatar/CharacterFace.js.map +1 -1
- package/lib/module/avatar-group/AvatarGroupBase.js +311 -244
- package/lib/module/avatar-group/AvatarGroupBase.js.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/VectorCharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/VectorStaticPortrait.d.ts +2 -2
- package/lib/typescript/commonjs/agent-avatar/VectorStaticPortrait.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/types.d.ts +6 -0
- package/lib/typescript/commonjs/agent-avatar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/vector-halo.d.ts +32 -0
- package/lib/typescript/commonjs/agent-avatar/vector-halo.d.ts.map +1 -0
- package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar/CharacterFace.d.ts +4 -1
- package/lib/typescript/commonjs/avatar/CharacterFace.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar/types.d.ts +9 -0
- package/lib/typescript/commonjs/avatar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar-group/AvatarGroupBase.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/VectorCharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/VectorStaticPortrait.d.ts +2 -2
- package/lib/typescript/module/agent-avatar/VectorStaticPortrait.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/types.d.ts +6 -0
- package/lib/typescript/module/agent-avatar/types.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/vector-halo.d.ts +32 -0
- package/lib/typescript/module/agent-avatar/vector-halo.d.ts.map +1 -0
- package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/module/avatar/CharacterFace.d.ts +4 -1
- package/lib/typescript/module/avatar/CharacterFace.d.ts.map +1 -1
- package/lib/typescript/module/avatar/types.d.ts +9 -0
- package/lib/typescript/module/avatar/types.d.ts.map +1 -1
- package/lib/typescript/module/avatar-group/AvatarGroupBase.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agent-avatar/VectorCharacterAvatar.tsx +26 -7
- package/src/agent-avatar/VectorStaticPortrait.tsx +18 -5
- package/src/agent-avatar/types.ts +6 -0
- package/src/agent-avatar/vector-halo.ts +52 -0
- package/src/avatar/Avatar.tsx +2 -0
- package/src/avatar/CharacterFace.tsx +6 -0
- package/src/avatar/types.ts +6 -0
- package/src/avatar-group/AvatarGroupBase.tsx +36 -4
|
@@ -3,17 +3,27 @@ import { svgA11yProps } from '../styles/svg-a11y';
|
|
|
3
3
|
import { useSvgIdPrefix } from '../styles/svg-id';
|
|
4
4
|
import { Platform, View } from 'react-native';
|
|
5
5
|
import { AvatarSnapshotObserver } from './context';
|
|
6
|
-
import { memo, useContext, useEffect, useRef, type ComponentRef } from 'react';
|
|
6
|
+
import { memo, useContext, useEffect, useMemo, useRef, type ComponentRef } from 'react';
|
|
7
|
+
import { haloSurfaceStyle, withHalo } from './vector-halo';
|
|
7
8
|
import Svg, { ClipPath, Defs, Path } from 'react-native-svg';
|
|
8
9
|
import type { AgentAvatarProps } from './types';
|
|
9
10
|
import type { VectorFrame } from './vector-types';
|
|
10
11
|
|
|
11
12
|
type Props = Pick<
|
|
12
13
|
AgentAvatarProps,
|
|
13
|
-
'size' | 'style' | 'testID' | 'onReady' | 'accessibilityLabel' | 'label'
|
|
14
|
+
'size' | 'style' | 'testID' | 'onReady' | 'accessibilityLabel' | 'label' | 'halo'
|
|
14
15
|
> & { frame?: VectorFrame; bodyColor?: string };
|
|
15
16
|
/** Offline projected portrait: no asset fetch, animation clock or runtime canvas. */
|
|
16
|
-
function StaticPortrait({ frame, size = 64, bodyColor, onReady, ...props }: Props) {
|
|
17
|
+
function StaticPortrait({ frame: plain, size = 64, bodyColor, onReady, halo, ...props }: Props) {
|
|
18
|
+
const haloColor = halo?.color;
|
|
19
|
+
const haloWidth = halo?.width;
|
|
20
|
+
const frame = useMemo(
|
|
21
|
+
() =>
|
|
22
|
+
plain && haloColor !== undefined && haloWidth
|
|
23
|
+
? withHalo(plain, size, { color: haloColor, width: haloWidth })
|
|
24
|
+
: plain,
|
|
25
|
+
[plain, size, haloColor, haloWidth],
|
|
26
|
+
);
|
|
17
27
|
const host = useRef<ComponentRef<typeof View> | null>(null);
|
|
18
28
|
const svg = useRef<Svg | null>(null);
|
|
19
29
|
const observe = useContext(AvatarSnapshotObserver);
|
|
@@ -58,8 +68,9 @@ function StaticPortrait({ frame, size = 64, bodyColor, onReady, ...props }: Prop
|
|
|
58
68
|
{frame ? (
|
|
59
69
|
<Svg
|
|
60
70
|
ref={svg}
|
|
61
|
-
width=
|
|
62
|
-
height=
|
|
71
|
+
width={haloSurfaceStyle(size, halo).width}
|
|
72
|
+
height={haloSurfaceStyle(size, halo).height}
|
|
73
|
+
style={halo ? haloSurfaceStyle(size, halo) : undefined}
|
|
63
74
|
viewBox={avatarViewBox(frame.viewBox)}
|
|
64
75
|
{...svgA11yProps()}
|
|
65
76
|
>
|
|
@@ -102,6 +113,8 @@ export const VectorStaticPortrait = memo(
|
|
|
102
113
|
a.frame === b.frame &&
|
|
103
114
|
a.bodyColor === b.bodyColor &&
|
|
104
115
|
a.size === b.size &&
|
|
116
|
+
a.halo?.color === b.halo?.color &&
|
|
117
|
+
a.halo?.width === b.halo?.width &&
|
|
105
118
|
a.style === b.style &&
|
|
106
119
|
a.testID === b.testID &&
|
|
107
120
|
a.onReady === b.onReady &&
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VectorHalo } from './vector-halo';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
4
|
import type { BloomThemeStorage } from '../theme/persistence';
|
|
@@ -45,6 +46,11 @@ export type AgentAvatarProps = {
|
|
|
45
46
|
onLoadingChange?: (loading: boolean) => void;
|
|
46
47
|
/** The vector assets to draw from, overriding the provider's. See `createVectorAssetLoader`. */
|
|
47
48
|
catalog?: VectorAssetLoader;
|
|
49
|
+
/**
|
|
50
|
+
* A gap cut around the character's silhouette, in the surface's colour, drawn with the character
|
|
51
|
+
* so it follows every pose. It overflows the avatar's box by `width`. For overlapping characters.
|
|
52
|
+
*/
|
|
53
|
+
halo?: VectorHalo;
|
|
48
54
|
style?: StyleProp<ViewStyle>;
|
|
49
55
|
accessibilityLabel?: string;
|
|
50
56
|
testID?: string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { VectorDrawPath, VectorFrame } from './vector-types';
|
|
2
|
+
import { avatarViewBox } from './vector-viewbox';
|
|
3
|
+
|
|
4
|
+
/** A gap cut around a character's silhouette: painted in `color` (the surface), `width` pixels wide. */
|
|
5
|
+
export type VectorHalo = { color: string; width: number };
|
|
6
|
+
|
|
7
|
+
/** The id of the one path that carries a frame's halo. Not a part index, so no paint is looked up for it. */
|
|
8
|
+
export const HALO_PATH_ID = 'halo';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The frame with a gap around its silhouette: one extra path drawn first, that is every unclipped
|
|
12
|
+
* outline of the frame stroked and filled in the surface colour, and a viewBox widened so the gap
|
|
13
|
+
* is not cropped. It is part of the frame, so it moves with the character on every pose, is cached
|
|
14
|
+
* with it and is drawn by whichever renderer draws the frame (SVG, or the native surface for a
|
|
15
|
+
* single frame and for a loop alike). One path, whatever the character is made of, keeps a frame
|
|
16
|
+
* as cheap as it was.
|
|
17
|
+
*/
|
|
18
|
+
export function withHalo(frame: VectorFrame, size: number, halo: VectorHalo): VectorFrame {
|
|
19
|
+
const [x = 0, y = 0, w = 1] = avatarViewBox(frame.viewBox)
|
|
20
|
+
.split(/[\s,]+/)
|
|
21
|
+
.map(Number);
|
|
22
|
+
// Units of the viewBox per pixel, so the gap is `width` pixels at any size.
|
|
23
|
+
const gap = (halo.width * w) / size;
|
|
24
|
+
let d = '';
|
|
25
|
+
for (const path of frame.paths) if (path.clip === undefined) d += path.d;
|
|
26
|
+
const outline: VectorDrawPath = {
|
|
27
|
+
id: HALO_PATH_ID,
|
|
28
|
+
d,
|
|
29
|
+
fill: halo.color,
|
|
30
|
+
opacity: 1,
|
|
31
|
+
fillOpacity: 1,
|
|
32
|
+
stroke: halo.color,
|
|
33
|
+
strokeWidth: gap * 2,
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
viewBox: `${x - gap} ${y - gap} ${w + gap * 2} ${w + gap * 2}`,
|
|
37
|
+
paths: [outline, ...frame.paths],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The style of a drawing's surface: the avatar's box, or that box grown by the halo on every side. */
|
|
42
|
+
export function haloSurfaceStyle(size: number, halo: VectorHalo | undefined) {
|
|
43
|
+
return halo && halo.width > 0
|
|
44
|
+
? ({
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
left: -halo.width,
|
|
47
|
+
top: -halo.width,
|
|
48
|
+
width: size + halo.width * 2,
|
|
49
|
+
height: size + halo.width * 2,
|
|
50
|
+
} as const)
|
|
51
|
+
: ({ width: '100%', height: '100%' } as const);
|
|
52
|
+
}
|
package/src/avatar/Avatar.tsx
CHANGED
|
@@ -361,6 +361,7 @@ const AvatarComponent: React.FC<AvatarProps> = ({
|
|
|
361
361
|
liveLabel: liveLabelProp,
|
|
362
362
|
liveColor,
|
|
363
363
|
ring,
|
|
364
|
+
halo,
|
|
364
365
|
testID,
|
|
365
366
|
}) => {
|
|
366
367
|
const theme = useTheme();
|
|
@@ -463,6 +464,7 @@ const AvatarComponent: React.FC<AvatarProps> = ({
|
|
|
463
464
|
character={resolvedCharacter}
|
|
464
465
|
still={characterStill}
|
|
465
466
|
size={size}
|
|
467
|
+
halo={halo}
|
|
466
468
|
motion={motion}
|
|
467
469
|
activity={activity}
|
|
468
470
|
reactionKey={reactionKey}
|
|
@@ -4,6 +4,7 @@ import { View } from 'react-native';
|
|
|
4
4
|
import { AGENT_AVATAR_MESSAGES } from '../agent-avatar/messages';
|
|
5
5
|
import { avatarCharacterOf, type ResolvedAvatarCharacter } from '../agent-avatar/character';
|
|
6
6
|
import type { ImageSource } from '../shapes';
|
|
7
|
+
import type { VectorHalo } from '../agent-avatar/vector-halo';
|
|
7
8
|
import { usePrefersReducedMotion } from '../hooks/use-prefers-reduced-motion';
|
|
8
9
|
import { useMessages } from '../locale/messages';
|
|
9
10
|
import type { AvatarMotion } from './types';
|
|
@@ -47,6 +48,8 @@ export interface CharacterFaceProps {
|
|
|
47
48
|
alt?: string;
|
|
48
49
|
/** The account's display name or handle, when it has one. */
|
|
49
50
|
name?: string;
|
|
51
|
+
/** A gap cut around the silhouette, drawn with the character so it follows every pose. */
|
|
52
|
+
halo?: VectorHalo;
|
|
50
53
|
/** Drawn at the same size until the picture is there: reserves the box, so nothing jumps. */
|
|
51
54
|
placeholder: ReactNode;
|
|
52
55
|
}
|
|
@@ -62,6 +65,7 @@ export function CharacterFace({
|
|
|
62
65
|
reactionKey,
|
|
63
66
|
alt,
|
|
64
67
|
name,
|
|
68
|
+
halo,
|
|
65
69
|
placeholder,
|
|
66
70
|
}: CharacterFaceProps) {
|
|
67
71
|
// Read here, not in `Avatar`: only an account with a character mounts this,
|
|
@@ -97,6 +101,7 @@ export function CharacterFace({
|
|
|
97
101
|
<AgentAvatar
|
|
98
102
|
character={written}
|
|
99
103
|
size={size}
|
|
104
|
+
halo={halo}
|
|
100
105
|
workingKey={workingKey ?? (episodes > 0 ? episodes : undefined)}
|
|
101
106
|
reactionKey={reactionKey}
|
|
102
107
|
onReady={() => setReady(true)}
|
|
@@ -115,6 +120,7 @@ export function CharacterFace({
|
|
|
115
120
|
<AgentAvatar
|
|
116
121
|
character={written}
|
|
117
122
|
size={size}
|
|
123
|
+
halo={halo}
|
|
118
124
|
portrait
|
|
119
125
|
paused
|
|
120
126
|
interactive={false}
|
package/src/avatar/types.ts
CHANGED
|
@@ -180,5 +180,11 @@ export interface AvatarProps {
|
|
|
180
180
|
liveColor?: string;
|
|
181
181
|
/** Decorative inner border: one color or a gradient. Does not change layout size. */
|
|
182
182
|
ring?: AvatarRingConfig;
|
|
183
|
+
/**
|
|
184
|
+
* A gap cut around a character's silhouette, in `color` (the surface behind), `width` pixels
|
|
185
|
+
* wide. For characters that overlap, as in an `AvatarGroup`; it overflows the avatar's box and
|
|
186
|
+
* does nothing for an avatar that is not a character.
|
|
187
|
+
*/
|
|
188
|
+
halo?: { color: string; width: number };
|
|
183
189
|
testID?: string;
|
|
184
190
|
}
|
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
type ViewStyle,
|
|
12
12
|
} from 'react-native';
|
|
13
13
|
|
|
14
|
+
import { tryResolveAvatarCharacter } from '../agent-avatar/character';
|
|
14
15
|
import { Avatar } from '../avatar';
|
|
16
|
+
import { pickAccountCharacter } from '../avatar/account';
|
|
15
17
|
import type { AvatarMotion } from '../avatar/types';
|
|
16
18
|
import { useMessages } from '../locale/messages';
|
|
17
19
|
import { useColorTokens } from '../theme/color-tokens';
|
|
@@ -83,6 +85,15 @@ function getItemKey(item: AvatarGroupItem, index: number): string {
|
|
|
83
85
|
return firstNonBlank(item.id, item.username, item.uri) ?? `avatar-${index}`;
|
|
84
86
|
}
|
|
85
87
|
|
|
88
|
+
/** Whether this member is drawn as a character (an agent) rather than a photo or initials. */
|
|
89
|
+
function hasCharacter(item: AvatarGroupItem): boolean {
|
|
90
|
+
return (
|
|
91
|
+
tryResolveAvatarCharacter(
|
|
92
|
+
pickAccountCharacter({ account: { kind: item.kind, character: item.character } }),
|
|
93
|
+
) !== undefined
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
86
97
|
/** Hover callbacks injected by the web fork; undefined (no-op) on native. */
|
|
87
98
|
export interface AvatarGroupCellHoverHandlers {
|
|
88
99
|
onHoverIn?: (item: AvatarGroupItem, index: number) => void;
|
|
@@ -139,10 +150,17 @@ function AvatarGroupCell({
|
|
|
139
150
|
typeof hoverHandlers?.onHoverIn === 'function' ||
|
|
140
151
|
typeof hoverHandlers?.onHoverOut === 'function';
|
|
141
152
|
|
|
142
|
-
|
|
153
|
+
// A character is its own silhouette: clipping it to the cell's circle would cut it and a circular
|
|
154
|
+
// ring would not follow it, so it is drawn unclipped with a gap cut around its outline instead.
|
|
155
|
+
const silhouette = hasCharacter(item);
|
|
156
|
+
const expressive = silhouette || (shape !== undefined && shape !== 'circle');
|
|
143
157
|
const frame = StyleSheet.flatten(cellStyle);
|
|
158
|
+
const halo =
|
|
159
|
+
silhouette && typeof frame?.borderWidth === 'number' && frame.borderWidth > 0
|
|
160
|
+
? { width: frame.borderWidth, color: String(frame.borderColor) }
|
|
161
|
+
: undefined;
|
|
144
162
|
const shapeRing =
|
|
145
|
-
expressive && typeof frame?.borderWidth === 'number' && frame.borderWidth > 0
|
|
163
|
+
expressive && !silhouette && typeof frame?.borderWidth === 'number' && frame.borderWidth > 0
|
|
146
164
|
? { width: frame.borderWidth, colors: String(frame.borderColor) }
|
|
147
165
|
: undefined;
|
|
148
166
|
|
|
@@ -178,6 +196,7 @@ function AvatarGroupCell({
|
|
|
178
196
|
motion={motion}
|
|
179
197
|
size={innerSize + (shapeRing?.width ?? 0) * 2}
|
|
180
198
|
ring={shapeRing}
|
|
199
|
+
halo={halo}
|
|
181
200
|
shape={shape}
|
|
182
201
|
testID={testID}
|
|
183
202
|
/>
|
|
@@ -371,6 +390,7 @@ const AvatarGroupBaseComponent: React.FC<AvatarGroupBaseProps> = ({
|
|
|
371
390
|
...(isRow ? {} : { zIndex: 0 }),
|
|
372
391
|
}}
|
|
373
392
|
textStyle={overflowTextStyle}
|
|
393
|
+
plain={shown.some(hasCharacter)}
|
|
374
394
|
onPress={overflowOnPress}
|
|
375
395
|
/>
|
|
376
396
|
)}
|
|
@@ -481,6 +501,7 @@ const ClusterAvatarGroup: React.FC<ClusterAvatarGroupProps> = ({
|
|
|
481
501
|
fontSize: Math.max(fontSize._2xs, Math.round(diameter * 0.34)),
|
|
482
502
|
fontWeight: '600',
|
|
483
503
|
}}
|
|
504
|
+
plain={shown.some(hasCharacter)}
|
|
484
505
|
onPress={overflowOnPress}
|
|
485
506
|
/>
|
|
486
507
|
);
|
|
@@ -553,12 +574,15 @@ function OverflowCircle({
|
|
|
553
574
|
cellStyle,
|
|
554
575
|
wrapperStyle,
|
|
555
576
|
textStyle,
|
|
577
|
+
plain = false,
|
|
556
578
|
onPress,
|
|
557
579
|
}: {
|
|
558
580
|
count: number;
|
|
559
581
|
cellStyle: StyleProp<ViewStyle>;
|
|
560
582
|
wrapperStyle: StyleProp<ViewStyle>;
|
|
561
583
|
textStyle: TextStyle;
|
|
584
|
+
/** Just the count, no chip: beside characters, whose silhouettes are not circles. */
|
|
585
|
+
plain?: boolean;
|
|
562
586
|
onPress?: () => void;
|
|
563
587
|
}) {
|
|
564
588
|
const tokens = useColorTokens();
|
|
@@ -569,8 +593,15 @@ function OverflowCircle({
|
|
|
569
593
|
// (margin for the facepile, absolute coords for the cluster) is supplied by
|
|
570
594
|
// the caller via `wrapperStyle`.
|
|
571
595
|
const circle = (
|
|
572
|
-
<View
|
|
573
|
-
|
|
596
|
+
<View
|
|
597
|
+
style={[cellStyle, plain ? styles.plainCount : { backgroundColor: tokens.mutedForeground }]}
|
|
598
|
+
>
|
|
599
|
+
<Text
|
|
600
|
+
allowFontScaling={false}
|
|
601
|
+
style={
|
|
602
|
+
plain ? [textStyle, { color: tokens.mutedForeground, fontWeight: '700' }] : textStyle
|
|
603
|
+
}
|
|
604
|
+
>
|
|
574
605
|
+{count}
|
|
575
606
|
</Text>
|
|
576
607
|
</View>
|
|
@@ -593,6 +624,7 @@ function OverflowCircle({
|
|
|
593
624
|
}
|
|
594
625
|
|
|
595
626
|
const styles = StyleSheet.create({
|
|
627
|
+
plainCount: { borderWidth: 0 },
|
|
596
628
|
row: {
|
|
597
629
|
flexDirection: 'row',
|
|
598
630
|
alignItems: 'center',
|