@linktr.ee/messaging-react 3.31.2-rc-1785926144 → 3.31.2-rc-1785926721

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-BKkCNnea.js";
1
+ import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-ilHx7pIO.js";
2
2
  export {
3
3
  e as ActionButton,
4
4
  t as Avatar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/messaging-react",
3
- "version": "3.31.2-rc-1785926144",
3
+ "version": "3.31.2-rc-1785926721",
4
4
  "description": "React messaging components built on messaging-core for web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@linktr.ee/component-library": "11.8.6",
53
- "@linktr.ee/messaging-core": "2.4.0-rc-1785926144",
53
+ "@linktr.ee/messaging-core": "2.4.0-rc-1785926721",
54
54
  "@linktr.ee/messaging-taxonomy": "^0.5.1",
55
55
  "@phosphor-icons/react": "^2.1.10"
56
56
  },
@@ -461,8 +461,8 @@ AccentWithoutVisibleHero.parameters = { chromatic: { disableSnapshot: false } }
461
461
 
462
462
  /**
463
463
  * Max-chroma sRGB colour for a hue — three phase-shifted cosines, so stepping
464
- * the hue walks the wheel at the most saturated triple each hue has. These are
465
- * the out-of-gamut extremes where the CSS derivation and the old JS one diverge.
464
+ * the hue walks the wheel at the most saturated triple each hue has. Many of
465
+ * these sit outside sRGB at the surface stops, where the browser gamut-maps.
466
466
  */
467
467
  const vividHex = (hue: number): string =>
468
468
  `#${[0, 120, 240]
@@ -506,10 +506,9 @@ const FALLBACK_BG_CLASS: Record<LinkAttachmentVariant, string> = {
506
506
  /**
507
507
  * One derivation cell driven by the *same* CSS the card uses: a
508
508
  * `.messaging-link-card` publishing `--accent`, so `styles.css` derives the
509
- * surface via `oklch(from …)`. No JS colour maths — this is exactly the render
510
- * path a colour-library swap moves. A refused accent (`none` / `malformed`)
511
- * publishes nothing and shows the fallback fill. The resolved surface hex is
512
- * the browser's now, not JS's, so only the input is labelled.
509
+ * surface via `oklch(from …)`. A refused accent (`none` / `malformed`) publishes
510
+ * nothing and shows the fallback fill. The resolved surface hex lives only in
511
+ * the browser, so the cell labels its input.
513
512
  */
514
513
  const DerivedSwatch = ({
515
514
  accentColor,
@@ -547,9 +546,8 @@ const GridHead = ({ children }: { children: React.ReactNode }) => (
547
546
  * Isolates the accent-chin surface: for every hue at maximum chroma and every
548
547
  * neutral/edge input, the `dark` (Sent) and `light` (Received) surfaces CSS
549
548
  * derives from the published `--accent`. One snapshot, no hero pixels — the
550
- * dense diff target for the MES-1412 culori→CSS swap. In-gamut inputs match the
551
- * old JS output exactly; the max-chroma hue-sweep rows are where the browser's
552
- * gamut clip diverges from culori's `clampChroma`, and will visibly diff.
549
+ * dense diff target for the derivation. In-gamut inputs (the neutral/edge rows)
550
+ * are stable; the max-chroma hue-sweep rows depend on the browser's gamut map.
553
551
  */
554
552
  export const AccentDerivation: StoryFn = () => (
555
553
  <div className="min-h-screen w-full bg-[#F9F7F4] p-8">
@@ -120,10 +120,9 @@ describe('LinkAttachment accent chin (MES-1349, MES-1388)', () => {
120
120
  }
121
121
 
122
122
  // The colour derivation itself is CSS (`oklch(from …)` in styles.css) and is
123
- // not computed by jsdom, so the unit tests assert the *contract* React owns:
124
- // the raw extracted hex is published as `--accent` (and dropped when there is
125
- // no visible hero), leaving the surface derivation to the browser. Pixel
126
- // parity is covered by the `AccentDerivation` Chromatic story (MES-1412).
123
+ // not computed by jsdom, so these tests assert the contract React owns: the
124
+ // raw extracted hex is published as `--accent` (and dropped when there is no
125
+ // visible hero), leaving the surface derivation to the browser.
127
126
  const accentOf = (element: HTMLElement) =>
128
127
  element.style.getPropertyValue('--accent')
129
128
 
@@ -133,8 +132,8 @@ describe('LinkAttachment accent chin (MES-1349, MES-1388)', () => {
133
132
  )
134
133
  const root = await screen.findByRole('link')
135
134
  expect(accentOf(root)).toBe(ACCENT)
136
- // No inline background: the surface is derived from `--accent` in CSS, not
137
- // painted verbatim (painting the raw accent is what MES-1388 reported).
135
+ // No inline background: the surface is derived from `--accent` in CSS, the
136
+ // raw accent is never painted verbatim.
138
137
  expect(root.style.backgroundColor).toBe('')
139
138
  expect(screen.getByText(CARD_PROPS.title)).toHaveStyle({ color: '#FFFFFF' })
140
139
  })
@@ -295,8 +294,8 @@ describe('LinkAttachment accent chin (MES-1349, MES-1388)', () => {
295
294
 
296
295
  it('normalizes a hashless accent so the derivation actually resolves', async () => {
297
296
  // The extractor returns a bare hex often enough that dropping it would lose
298
- // the colour silently — `oklch(from 7008E7 …)` never resolves (MES-1349), so
299
- // the published `--accent` must carry the `#`.
297
+ // the colour silently — `oklch(from 7008E7 …)` never resolves, so the
298
+ // published `--accent` must carry the `#`.
300
299
  const hashless = renderWithProviders(
301
300
  <LinkAttachment.Sent {...CARD_PROPS} accentColor="7008E7" />
302
301
  )
@@ -4,10 +4,10 @@ import React from 'react'
4
4
  export interface BubbleTailProps {
5
5
  /**
6
6
  * Raw extracted accent colour, published as `--accent` so the tail derives
7
- * the same surface as the card in CSS (`styles.css`). `undefined` falls the
8
- * tail back to this side's plain bubble fill. The tail paints outside the
9
- * shell's box, so it can't inherit the shell's computed background — it runs
10
- * the derivation itself off its own `--accent` (MES-1412).
7
+ * the same surface as the card in CSS (`styles.css`), or `undefined` to fall
8
+ * back to this side's plain bubble fill. The tail paints outside the shell's
9
+ * box and can't inherit its background, so it runs the derivation off its own
10
+ * `--accent`.
11
11
  */
12
12
  accentHex?: string
13
13
  /** Sender tails hang off the right edge, receiver tails mirror to the left. */
@@ -18,7 +18,7 @@ export interface CardBodyProps {
18
18
  * Ink for both chin lines, from `useChinPalette` — fixed per surface (white on
19
19
  * the dark stop, near-black on the pale stop and the audio strip). Replaces the
20
20
  * variant's own `text-*` classes (including their opacity) on both lines, so a
21
- * card whose surface is not the variant default still reads (MES-1388).
21
+ * card whose surface is not the variant default still reads.
22
22
  */
23
23
  chinTextColor?: string
24
24
  /**
@@ -36,9 +36,9 @@ export interface CardShellProps {
36
36
  bgClassName?: string
37
37
  /**
38
38
  * Raw extracted accent colour, published as the `--accent` custom property.
39
- * `styles.css` derives the card surface from it in CSS (`oklch(from …)`) and
40
- * paints it over the `bg-[…]` fallback where the browser supports it —
41
- * MES-1412. `undefined` keeps the variant / `bgClassName` fill.
39
+ * `styles.css` derives the card surface from it (`oklch(from …)`) and paints
40
+ * it over the `bg-[…]` fallback where the browser supports it. `undefined`
41
+ * keeps the variant / `bgClassName` fill.
42
42
  */
43
43
  accentHex?: string
44
44
  /**
@@ -101,25 +101,20 @@ const CardShell: React.FC<CardShellProps> = ({
101
101
  fixedHeight ? FIXED_HEIGHT_CLASS : 'block',
102
102
  // The plain fallback fill, kept underneath the `--accent` derivation: the
103
103
  // `.messaging-link-card[style*='--accent']` rule in `styles.css` outranks
104
- // this single class, so a published accent paints over it where the browser
105
- // resolves `oklch(from …)`, and an accent that can't (or was never set)
106
- // lands on this sane surface.
104
+ // this single class, so a published accent paints over it and an unset one
105
+ // lands on this surface.
107
106
  //
108
- // MUST be an arbitrary value, not a theme token. This package ships no
109
- // Tailwind utilities — `dist/assets/index.css` is only the hand-written
110
- // `.str-chat`/`.mes-*` CSS — so consumers generate our classes by scanning
111
- // `messaging-react/dist` against *their own* theme. `shade` comes from the
112
- // component-library preset that this package builds with; frontyard builds
113
- // on the Arbor preset and has no such colour, so `bg-shade` was silently
114
- // dropped, the chin rendered transparent, and the own-message `color: white`
115
- // left the title and URL invisible (MES-1388). An arbitrary value is
116
- // generated from the class name alone and cannot depend on consumer theme.
107
+ // Must be an arbitrary value, not a theme token: this package ships no
108
+ // Tailwind utilities, so consumers generate our classes by scanning
109
+ // `messaging-react/dist` against their own theme. A theme colour a consumer
110
+ // lacks compiles to nothing and leaves the chin transparent; an arbitrary
111
+ // value is generated from the class name alone.
117
112
  //
118
113
  // Both values are the plain message bubble's own fill, so a card with no
119
114
  // usable accent matches the text bubbles around it: `#1e2330` is
120
115
  // `--str-chat__own-message-bubble-background-color` and `#f1f0ee` is
121
- // `--str-chat__message-bubble-background-color`. Mirrored in
122
- // and mirrored by the bubble tail's own fills in `styles.css`.
116
+ // `--str-chat__message-bubble-background-color`, mirrored by the bubble
117
+ // tail's own fills in `styles.css`.
123
118
  bgClassName ?? (variant === 'dark' ? 'bg-[#1e2330]' : 'bg-[#f1f0ee]'),
124
119
  // `focus-ring` is a design-system utility from the component-library
125
120
  // tailwind preset — outline-none + a black 2px focus-visible ring
@@ -11,11 +11,9 @@
11
11
  /**
12
12
  * `#abc`, `#aabbcc`, or either without the leading `#`.
13
13
  *
14
- * The missing hash is deliberate: the extractor returns bare hexes often enough
15
- * that rejecting them would silently drop the colour. It is also why `toCssHex`
16
- * exists — `background-color: 738883` is invalid and the DOM drops it, which is
17
- * how a card once rendered unaccented while every calculation behind it had
18
- * succeeded (MES-1349).
14
+ * The optional hash is deliberate: the extractor returns bare hexes often
15
+ * enough that rejecting them would drop the colour. It is also why `toCssHex`
16
+ * exists — `738883` without the `#` is not a valid CSS colour.
19
17
  */
20
18
  export const HEX_PATTERN = /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i
21
19
 
@@ -42,13 +42,13 @@ export interface ChinPalette {
42
42
  /**
43
43
  * Raw extracted colour to publish as the `--accent` custom property on the
44
44
  * shell and the tail, or `undefined` when there is no paintable accent. The
45
- * hue-preserving lightness swap is done in CSS (`styles.css`) — see MES-1412.
45
+ * card keeps its hue and swaps the lightness in CSS (`styles.css`).
46
46
  */
47
47
  accentHex?: string
48
48
  /**
49
49
  * Ink for both chin lines: white on the sender's dark stop, near-black on the
50
- * receiver's pale stop and on the audio strip. Fixed per surface, so no
51
- * runtime contrast measurement is needed (the stops clear AA by construction).
50
+ * receiver's pale stop and on the audio strip. Fixed per surface — the stops
51
+ * clear AA at every hue.
52
52
  */
53
53
  chinTextColor: string
54
54
  /** True while the card renders as a skeleton. */
@@ -58,33 +58,25 @@ export interface ChinPalette {
58
58
  }
59
59
 
60
60
  /**
61
- * Resolves a link card's accent-derived colours and tracks hero-image failure.
61
+ * Resolves the accent a link card publishes and tracks hero-image failure.
62
62
  *
63
63
  * The accent is a claim about an image the viewer can see, so it only paints
64
- * when `CardThumbnail` actually mounts that image. Mirroring its branches
65
- * (`CardThumbnail.tsx:98-160`), the hero is *not* the accent's source when:
64
+ * when `CardThumbnail` actually mounts that image. Mirroring its branches, the
65
+ * hero is *not* the accent's source when:
66
66
  *
67
67
  * - `layout: 'classic'` — there is no hero region at all;
68
- * - `status` is not `'ready'` — the hero is the pulsing skeleton and there is
69
- * no image yet;
68
+ * - `status` is not `'ready'` — the hero is the pulsing skeleton, no image yet;
70
69
  * - `thumbnailUrl` is absent — the hero is the type-icon placeholder, or for a
71
70
  * playable video a bare `bg-black` box with no poster;
72
71
  * - the attachment is playable audio — the hero collapses to the native
73
- * `<audio>` player and the `<img>` never mounts *even though `thumbnailUrl`
74
- * is set*, so `onImageError` can never rescue this one. Left ungated, an
75
- * artwork-backed audio link preview shipped a coloured card with no visible
76
- * source image, and the accent beat `AUDIO_BG_CLASS` on Sent / Received
77
- * because `CardShell` applies it as an inline `style`, which outranks any
78
- * `bg-*` class. `ComposerCard` already dodged that by returning early before
79
- * it passes `accentStyle`; this is that same rule, stated once instead of
80
- * three times (MES-1349);
72
+ * `<audio>` player and the `<img>` never mounts even though `thumbnailUrl` is
73
+ * set, so `onImageError` can never rescue it and the gate has to be up front;
81
74
  * - the image 404s — an accent extracted from something the viewer cannot see.
82
75
  * `onImageError` covers both hero shapes: the `<img>` reports directly, and a
83
76
  * playable video's `poster` (which raises no event of its own) is verified by
84
77
  * the hidden probe image in `CardThumbnail`.
85
78
  *
86
- * Every case falls back to the variant's own fill, which already pairs with
87
- * the variant's own text colours.
79
+ * Every excluded case publishes no accent and keeps the variant's own fill.
88
80
  */
89
81
  export function useChinPalette({
90
82
  variant,
@@ -110,30 +102,26 @@ export function useChinPalette({
110
102
  // Truthiness rather than `!= null` so this tracks `CardThumbnail`'s own
111
103
  // `thumbnailUrl ?` branch, which renders the placeholder for `''` too.
112
104
  //
113
- // Playable audio stays excluded, as MES-1349 decided: its hero collapses to
114
- // the native `<audio>` player, so the artwork never appears and an accent
115
- // taken from it would be a claim about an image the viewer cannot see. The
116
- // `<img>` never mounts either, so `onImageError` could not withdraw the colour
117
- // if the artwork 404'd. Colouring audio cards from their artwork is a change
118
- // to the audio tickets (MES-1360 / MES-1361), not to this one.
105
+ // Playable audio stays excluded: its hero collapses to the native `<audio>`
106
+ // player, so the artwork never appears and an accent taken from it would claim
107
+ // an image the viewer cannot see. The `<img>` never mounts either, so
108
+ // `onImageError` could not withdraw the colour if the artwork 404'd.
119
109
  const isAudio = isPlayableAudio(mimeType, sourceUrl)
120
110
  const hasHero =
121
111
  layout === 'featured' && !!thumbnailUrl && !isAudio && !heroFailed
122
112
  const canDerive = hasHero && status === 'ready'
123
- // Only a validated hex is published: `accent_color` is always a hex from the
124
- // extractor, and CSS would resolve any colour name — narrowing keeps the input
125
- // contract the same one the old `accentSurface` enforced. The bare-hex case is
126
- // supported because the extractor omits the `#` often enough that dropping it
127
- // would silently lose the colour (MES-1349).
113
+ // Only a validated hex is published: the extracted `accent_color` is always a
114
+ // hex, and CSS would resolve any colour name, so narrow the input here. Bare
115
+ // hexes are accepted because the extractor omits the `#` often enough that
116
+ // rejecting them would silently lose the colour.
128
117
  const accentHex =
129
118
  canDerive && accentColor != null && HEX_PATTERN.test(accentColor.trim())
130
119
  ? toCssHex(accentColor)
131
120
  : undefined
132
121
 
133
122
  // The accent surface and the sender's dark fallback both take white ink; the
134
- // pale receiver fallback and the imposed audio strip both take near-black. So
135
- // the ink is fixed per surface and needs no runtime contrast — a sent audio
136
- // card put white ink on the strip's near-white at 1.13:1 before (MES-1388).
123
+ // pale receiver fallback and the imposed audio strip both take near-black — so
124
+ // the ink is fixed per surface.
137
125
  const chinTextColor = isAudio ? INK_ON_LIGHT : INK_BY_VARIANT[variant]
138
126
 
139
127
  return {
package/src/styles.css CHANGED
@@ -1101,13 +1101,12 @@
1101
1101
  }
1102
1102
  }
1103
1103
 
1104
- /* Derived accent surface for `LinkAttachment` cards (MES-1412). React publishes
1105
- the raw extracted colour as `--accent`; the hue-preserving lightness swap that
1106
- used to run in JS (culori) runs natively via relative colour syntax. Only
1107
- where the syntax resolves and an accent was published does the surface paint —
1108
- every other browser keeps the plain bubble fill from the card's `bg-[…]` class
1109
- (the same fallback the old JS guard degraded to). The `--surface-l` stops clear
1110
- 4.5:1 against each side's ink at every hue by construction. */
1104
+ /* Derived accent surface for `LinkAttachment` cards. `--accent` is the raw
1105
+ colour extracted from the attachment image; the card keeps its hue and swaps
1106
+ the lightness to this side's `--surface-l` stop. Only paints where the browser
1107
+ resolves relative colour syntax and an accent is set — otherwise the card's
1108
+ `bg-[…]` fallback fill shows through. The stops clear 4.5:1 against each side's
1109
+ ink at every hue. */
1111
1110
  .messaging-link-card[data-variant='dark'] {
1112
1111
  --surface-l: 0.3;
1113
1112
  }
@@ -1121,10 +1120,9 @@
1121
1120
  }
1122
1121
  }
1123
1122
 
1124
- /* Bubble tail for `LinkAttachment` cards (MES-1349). Same 20x23 geometry and
1125
- mask path as the text-bubble tails above — the difference is that the fill
1126
- arrives as an inline style, because it is a dominant colour extracted from
1127
- the attachment image at send time and Tailwind cannot express a runtime hex.
1123
+ /* Bubble tail for `LinkAttachment` cards. Same 20x23 geometry and mask path as
1124
+ the text-bubble tails above; the fill is the card's accent surface, derived
1125
+ below from its own `--accent`.
1128
1126
 
1129
1127
  Hand-written here rather than as a toolkit-only Tailwind utility on purpose:
1130
1128
  `styles.css` ships as a built stylesheet that every consumer imports, whereas