@oxy.so/bloom 7.33.1 → 8.0.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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/docs/adoption-matrix.mdx +1 -1
  3. package/docs/link-preview.mdx +19 -2
  4. package/docs/tab-bar.mdx +1 -1
  5. package/lib/commonjs/index.js +102 -110
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/index.web.js +102 -110
  8. package/lib/commonjs/index.web.js.map +1 -1
  9. package/lib/commonjs/link-preview/LinkPreviewCard.js +25 -10
  10. package/lib/commonjs/link-preview/LinkPreviewCard.js.map +1 -1
  11. package/lib/module/index.js +5 -2
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/module/index.web.js +5 -2
  14. package/lib/module/index.web.js.map +1 -1
  15. package/lib/module/link-preview/LinkPreviewCard.js +27 -10
  16. package/lib/module/link-preview/LinkPreviewCard.js.map +1 -1
  17. package/lib/typescript/commonjs/index.d.ts +0 -2
  18. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/index.web.d.ts +0 -2
  20. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  21. package/lib/typescript/commonjs/link-preview/LinkPreviewCard.d.ts +5 -4
  22. package/lib/typescript/commonjs/link-preview/LinkPreviewCard.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/link-preview/index.d.ts +1 -1
  24. package/lib/typescript/commonjs/link-preview/index.d.ts.map +1 -1
  25. package/lib/typescript/commonjs/link-preview/types.d.ts +16 -4
  26. package/lib/typescript/commonjs/link-preview/types.d.ts.map +1 -1
  27. package/lib/typescript/module/index.d.ts +0 -2
  28. package/lib/typescript/module/index.d.ts.map +1 -1
  29. package/lib/typescript/module/index.web.d.ts +0 -2
  30. package/lib/typescript/module/index.web.d.ts.map +1 -1
  31. package/lib/typescript/module/link-preview/LinkPreviewCard.d.ts +5 -4
  32. package/lib/typescript/module/link-preview/LinkPreviewCard.d.ts.map +1 -1
  33. package/lib/typescript/module/link-preview/index.d.ts +1 -1
  34. package/lib/typescript/module/link-preview/index.d.ts.map +1 -1
  35. package/lib/typescript/module/link-preview/types.d.ts +16 -4
  36. package/lib/typescript/module/link-preview/types.d.ts.map +1 -1
  37. package/package.json +2 -2
  38. package/src/__tests__/support/adoption-matrix.ts +695 -0
  39. package/src/__tests__/support/card-surface.ts +31 -0
  40. package/src/__tests__/support/collision-fixture-barrel.ts +20 -0
  41. package/src/__tests__/support/commerce-harness.tsx +97 -0
  42. package/src/__tests__/support/composite.ts +71 -0
  43. package/src/__tests__/support/constructed-style-sheets.ts +64 -0
  44. package/src/__tests__/support/messages-in.ts +10 -0
  45. package/src/__tests__/support/press-host.ts +30 -0
  46. package/src/__tests__/support/rendered-style.ts +99 -0
  47. package/src/__tests__/support/unread-hook-fixture.ts +33 -0
  48. package/src/__tests__/support/worklet-capture-fixture.tsx +34 -0
  49. package/src/__tests__/support/yoga-host-tree.ts +73 -0
  50. package/src/agent-avatar/__tests__/artwork-golden.json +774 -0
  51. package/src/agent-creator/__tests__/support/character-runtime-fixture.tsx +24 -0
  52. package/src/index.ts +4 -3
  53. package/src/index.web.ts +4 -3
  54. package/src/link-preview/LinkPreviewCard.tsx +31 -9
  55. package/src/link-preview/index.ts +1 -1
  56. package/src/link-preview/types.ts +17 -4
  57. package/src/theme/__tests__/__fixtures__/golden-resolved-tokens.json +9346 -0
  58. package/src/theme/__tests__/__fixtures__/tonal-glass-primary-failures.json +69 -0
  59. package/src/theme/__tests__/fixtures/color-engine-golden.json +1 -0
@@ -0,0 +1,24 @@
1
+ import type { ContextType, ReactNode } from 'react';
2
+ import {
3
+ CharacterCapabilitiesContext,
4
+ CharacterRuntimeContext,
5
+ } from '../../../agent-avatar/context';
6
+
7
+ /** Supply both internal channels without starting the browser engine in UI tests. */
8
+ export function CharacterRuntimeFixture({
9
+ value,
10
+ children,
11
+ }: {
12
+ value: ContextType<typeof CharacterRuntimeContext> &
13
+ ContextType<typeof CharacterCapabilitiesContext>;
14
+ children: ReactNode;
15
+ }) {
16
+ const { runtimeUrl, reportCapabilities, ...catalog } = value;
17
+ return (
18
+ <CharacterRuntimeContext.Provider value={{ runtimeUrl, reportCapabilities }}>
19
+ <CharacterCapabilitiesContext.Provider value={catalog}>
20
+ {children}
21
+ </CharacterCapabilitiesContext.Provider>
22
+ </CharacterRuntimeContext.Provider>
23
+ );
24
+ }
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  // 1. Importing it would add a package to this barrel's module graph. Metro
6
6
  // does not tree-shake, so `import { Button } from '@oxy.so/bloom'` links
7
7
  // everything this file can reach — and an unmet REQUIRED peer is a build
8
- // failure, not a degradation. Measured today exactly three families fail
8
+ // failure, not a degradation. Measured today exactly four families fail
9
9
  // this, and each is reachable only through its own subpath:
10
10
  // · `./tab-bar` — statically imports `expo-glass-effect` + `expo-symbols`
11
11
  // from its `.native` files. Both ship Apple-only native modules, and the
@@ -15,6 +15,9 @@
15
15
  // router restoration is supplied explicitly.
16
16
  // · `./zoomable-media-gallery` and `./media-flight` — both reach
17
17
  // `expo-image` through the shared `media-flight/MediaSurface`.
18
+ // · `./link-preview` — `LinkPreviewCard` renders its cover with
19
+ // `expo-image`, which picks among the cover's renditions by its laid-out
20
+ // size (Bloom 8.0.0 took it off this barrel for that).
18
21
  // Gate: `src/__tests__/root-barrel-graph.test.ts`.
19
22
  // `./video-view` links no package, but its DECLARATIONS name the optional
20
23
  // peer `expo-video`'s own types; on this barrel every app's typecheck
@@ -2005,8 +2008,6 @@ export * from './tabs';
2005
2008
  export * from './checkbox';
2006
2009
  export * from './radio';
2007
2010
  export * from './accordion';
2008
- export { LinkPreviewCard } from './link-preview';
2009
- export type { LinkPreviewCardProps } from './link-preview';
2010
2011
 
2011
2012
  // Stat / profile widgets
2012
2013
  export { CompositionBar } from './composition-bar';
package/src/index.web.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  // 1. Importing it would add a package to this barrel's module graph. Metro
11
11
  // does not tree-shake, so `import { Button } from '@oxy.so/bloom'` links
12
12
  // everything this file can reach — and an unmet REQUIRED peer is a build
13
- // failure, not a degradation. Measured today exactly three families fail
13
+ // failure, not a degradation. Measured today exactly four families fail
14
14
  // this, and each is reachable only through its own subpath:
15
15
  // · `./tab-bar` — statically imports `expo-glass-effect` + `expo-symbols`
16
16
  // from its `.native` files. Both ship Apple-only native modules, and the
@@ -20,6 +20,9 @@
20
20
  // router restoration is supplied explicitly.
21
21
  // · `./zoomable-media-gallery` and `./media-flight` — both reach
22
22
  // `expo-image` through the shared `media-flight/MediaSurface`.
23
+ // · `./link-preview` — `LinkPreviewCard` renders its cover with
24
+ // `expo-image`, which picks among the cover's renditions by its laid-out
25
+ // size (Bloom 8.0.0 took it off this barrel for that).
23
26
  // Gate: `src/__tests__/root-barrel-graph.test.ts`.
24
27
  // `./video-view` links no package, but its DECLARATIONS name the optional
25
28
  // peer `expo-video`'s own types; on this barrel every app's typecheck
@@ -2010,8 +2013,6 @@ export * from './tabs';
2010
2013
  export * from './checkbox';
2011
2014
  export * from './radio';
2012
2015
  export * from './accordion/index.web';
2013
- export { LinkPreviewCard } from './link-preview';
2014
- export type { LinkPreviewCardProps } from './link-preview';
2015
2016
 
2016
2017
  // Stat / profile widgets
2017
2018
  export { CompositionBar } from './composition-bar';
@@ -25,17 +25,20 @@
25
25
  * The numbers below are exactly what those class strings resolved to, and each
26
26
  * one is named beside the utility it came from.
27
27
  *
28
- * The `image` prop is a plain absolute URL (e.g. a `cloud.oxy.so` OG image) and
29
- * is rendered directly with the RN `Image` primitive — NOT through
30
- * `ImageResolver` / `Avatar`, which resolve bare Oxy file IDs.
28
+ * The `image` prop is an absolute URL, or the same image at several widths, and
29
+ * is rendered with `expo-image` (which picks among the widths by the cover's
30
+ * laid-out size) — NOT through `ImageResolver` / `Avatar`, which resolve bare
31
+ * Oxy file IDs.
31
32
  */
32
- import React, { memo, useCallback, useMemo } from 'react';
33
- import { Image, Linking, StyleSheet, Text, View } from 'react-native';
33
+ import type React from 'react';
34
+ import { memo, useCallback, useMemo } from 'react';
35
+ import { Image } from 'expo-image';
36
+ import { Linking, StyleSheet, Text, View } from 'react-native';
34
37
 
35
38
  import { Card } from '../card';
36
39
  import { useTheme } from '../theme/use-theme';
37
40
  import { fontSize, space } from '../styles/tokens';
38
- import type { LinkPreviewCardProps } from './types';
41
+ import type { LinkPreviewCardProps, LinkPreviewImageSource } from './types';
39
42
 
40
43
  /** Height (px) of the optional cover image at the top of the card. */
41
44
  const COVER_IMAGE_HEIGHT = 160;
@@ -65,6 +68,18 @@ function hostnameOf(url: string): string | undefined {
65
68
  }
66
69
  }
67
70
 
71
+ /**
72
+ * `image` as `expo-image` takes it, or `undefined` when there is nothing to
73
+ * show. An empty list counts as no image, so the card never reserves a blank
74
+ * cover.
75
+ */
76
+ function coverSource(
77
+ image: string | readonly LinkPreviewImageSource[] | undefined,
78
+ ): string | LinkPreviewImageSource[] | undefined {
79
+ if (typeof image === 'string') return image || undefined;
80
+ return image && image.length > 0 ? [...image] : undefined;
81
+ }
82
+
68
83
  const LinkPreviewCardComponent: React.FC<LinkPreviewCardProps> = ({
69
84
  url,
70
85
  title,
@@ -86,6 +101,11 @@ const LinkPreviewCardComponent: React.FC<LinkPreviewCardProps> = ({
86
101
  };
87
102
  }, [url, siteName, title]);
88
103
 
104
+ const cover = useMemo(() => coverSource(image), [image]);
105
+ // Stable across re-renders and rendition lists alike: recycled list cells
106
+ // must not flash the previous card's image while the next one loads.
107
+ const coverKey = typeof cover === 'string' ? cover : cover?.[0]?.uri;
108
+
89
109
  const handlePress = useCallback(() => {
90
110
  if (onPress) {
91
111
  onPress();
@@ -109,10 +129,12 @@ const LinkPreviewCardComponent: React.FC<LinkPreviewCardProps> = ({
109
129
  accessibilityRole="link"
110
130
  accessibilityLabel={displayTitle}
111
131
  >
112
- {image ? (
132
+ {cover ? (
113
133
  <Image
114
- source={{ uri: image }}
115
- resizeMode="cover"
134
+ source={cover}
135
+ recyclingKey={coverKey}
136
+ contentFit="cover"
137
+ cachePolicy="memory-disk"
116
138
  style={[
117
139
  styles.cover,
118
140
  // Fill-height mode: flex into the card's bounding height (supplied
@@ -1,2 +1,2 @@
1
1
  export { LinkPreviewCard } from './LinkPreviewCard';
2
- export type { LinkPreviewCardProps } from './types';
2
+ export type { LinkPreviewCardProps, LinkPreviewImageSource } from './types';
@@ -1,5 +1,15 @@
1
1
  import type { StyleProp, ViewStyle } from 'react-native';
2
2
 
3
+ /**
4
+ * One rendition of the cover image and the pixel width it was rendered at —
5
+ * the shape `@oxy.so/utils/image` `contentImageSources` returns. Given several,
6
+ * the card loads the smallest one that covers the space it is laid out in.
7
+ */
8
+ export interface LinkPreviewImageSource {
9
+ uri: string;
10
+ width: number;
11
+ }
12
+
3
13
  /**
4
14
  * Props for {@link LinkPreviewCard}.
5
15
  *
@@ -16,11 +26,14 @@ export interface LinkPreviewCardProps {
16
26
  /** OpenGraph / meta description. */
17
27
  description?: string;
18
28
  /**
19
- * Absolute cover-image URL (e.g. a `cloud.oxy.so` OG image). Rendered directly
20
- * with the RN `Image` primitive — NOT through `ImageResolver` / `Avatar`, which
21
- * are for bare Oxy file IDs.
29
+ * The cover image: one absolute URL, or the same image at several widths
30
+ * (e.g. `contentImageSources(url)` from `@oxy.so/utils/image`). With several,
31
+ * `expo-image` loads the smallest that covers the cover's rendered size — a
32
+ * `srcset` on web, the view's size × pixel ratio on native — so a card in a
33
+ * narrow row never downloads the full-width rendition. Rendered directly, NOT
34
+ * through `ImageResolver` / `Avatar`, which are for bare Oxy file IDs.
22
35
  */
23
- image?: string;
36
+ image?: string | readonly LinkPreviewImageSource[];
24
37
  /** Site / brand name shown above the title. Falls back to the URL hostname. */
25
38
  siteName?: string;
26
39
  /**