@flamingo-stack/openframe-frontend-core 0.0.643 → 0.0.644-2208.6319.1

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 (156) hide show
  1. package/dist/chat-protocol/index.cjs +20 -3
  2. package/dist/chat-protocol/index.cjs.map +1 -1
  3. package/dist/chat-protocol/index.js +20 -3
  4. package/dist/chat-protocol/index.js.map +1 -1
  5. package/dist/chat-protocol/source-metadata.d.ts +7 -1
  6. package/dist/chat-protocol/source-metadata.d.ts.map +1 -1
  7. package/dist/{chunk-B42INNRA.cjs → chunk-2UA3DT5O.cjs} +199 -199
  8. package/dist/{chunk-B42INNRA.cjs.map → chunk-2UA3DT5O.cjs.map} +1 -1
  9. package/dist/{chunk-KX2FT7AS.cjs → chunk-2ZGEXLQW.cjs} +28 -28
  10. package/dist/{chunk-KX2FT7AS.cjs.map → chunk-2ZGEXLQW.cjs.map} +1 -1
  11. package/dist/{chunk-2NRLRRMR.cjs → chunk-3HSRNCDV.cjs} +226 -203
  12. package/dist/chunk-3HSRNCDV.cjs.map +1 -0
  13. package/dist/{chunk-64KDKDYC.js → chunk-5ELZ2NQ5.js} +6 -6
  14. package/dist/{chunk-2DJH6KHA.cjs → chunk-B46Q4DTN.cjs} +382 -386
  15. package/dist/chunk-B46Q4DTN.cjs.map +1 -0
  16. package/dist/{chunk-N7UYD57Q.js → chunk-C7RU466R.js} +3 -3
  17. package/dist/{chunk-2NODQ7FO.js → chunk-DSJZYRS6.js} +17 -21
  18. package/dist/{chunk-2NODQ7FO.js.map → chunk-DSJZYRS6.js.map} +1 -1
  19. package/dist/{chunk-26D6FM6L.cjs → chunk-EKSCVXA3.cjs} +6 -6
  20. package/dist/{chunk-26D6FM6L.cjs.map → chunk-EKSCVXA3.cjs.map} +1 -1
  21. package/dist/{chunk-7HL2PNQ3.js → chunk-GEGE3JXC.js} +5 -5
  22. package/dist/{chunk-7T673MHJ.cjs → chunk-GUB6BR26.cjs} +22 -22
  23. package/dist/{chunk-7T673MHJ.cjs.map → chunk-GUB6BR26.cjs.map} +1 -1
  24. package/dist/{chunk-3IPL6G7S.js → chunk-GXNQPCL4.js} +164 -141
  25. package/dist/chunk-GXNQPCL4.js.map +1 -0
  26. package/dist/{chunk-D6TWJEFW.cjs → chunk-GZXW5QWQ.cjs} +15 -15
  27. package/dist/{chunk-D6TWJEFW.cjs.map → chunk-GZXW5QWQ.cjs.map} +1 -1
  28. package/dist/{chunk-4TE53O6U.js → chunk-HAQRGJFL.js} +4 -4
  29. package/dist/{chunk-TIOHTWDA.js → chunk-INISTVWK.js} +6 -6
  30. package/dist/{chunk-IU3IYXMM.js → chunk-IRV2W7GN.js} +7 -7
  31. package/dist/{chunk-R2IU2Y2O.cjs → chunk-JWCAWGLG.cjs} +33 -33
  32. package/dist/{chunk-R2IU2Y2O.cjs.map → chunk-JWCAWGLG.cjs.map} +1 -1
  33. package/dist/{chunk-77EO26XV.cjs → chunk-LNLNPCII.cjs} +5 -5
  34. package/dist/{chunk-77EO26XV.cjs.map → chunk-LNLNPCII.cjs.map} +1 -1
  35. package/dist/{chunk-42NXGOTG.cjs → chunk-N3M56EE5.cjs} +3 -3
  36. package/dist/{chunk-42NXGOTG.cjs.map → chunk-N3M56EE5.cjs.map} +1 -1
  37. package/dist/{chunk-O7JMF5OT.js → chunk-O47SGDBV.js} +3 -3
  38. package/dist/{chunk-EWQI5MV6.cjs → chunk-OANRA5ML.cjs} +20 -20
  39. package/dist/{chunk-EWQI5MV6.cjs.map → chunk-OANRA5ML.cjs.map} +1 -1
  40. package/dist/{chunk-NCHLLTAR.js → chunk-PR6IR22M.js} +3 -3
  41. package/dist/{chunk-6MQBLFUM.js → chunk-Q7JDIDE2.js} +5 -5
  42. package/dist/{chunk-YG7KLZE7.js → chunk-R5EIFOW2.js} +4 -4
  43. package/dist/{chunk-5E6Y6766.cjs → chunk-S2E4I3WP.cjs} +29 -29
  44. package/dist/{chunk-5E6Y6766.cjs.map → chunk-S2E4I3WP.cjs.map} +1 -1
  45. package/dist/{chunk-SE6YRE3R.cjs → chunk-SAD5IUSO.cjs} +32 -32
  46. package/dist/{chunk-SE6YRE3R.cjs.map → chunk-SAD5IUSO.cjs.map} +1 -1
  47. package/dist/{chunk-3LXJEXPH.js → chunk-TAP4MJPF.js} +2 -2
  48. package/dist/{chunk-M3W5Y5DK.cjs → chunk-TEKH3J65.cjs} +11 -11
  49. package/dist/{chunk-M3W5Y5DK.cjs.map → chunk-TEKH3J65.cjs.map} +1 -1
  50. package/dist/{chunk-HA2U7WHU.js → chunk-TXNWDP3M.js} +3 -3
  51. package/dist/{chunk-IIZX3K2R.js → chunk-URGDDCJL.js} +2 -2
  52. package/dist/{chunk-TQ7KTANJ.js → chunk-V52INSJH.js} +3 -3
  53. package/dist/{chunk-FO7SD2IQ.cjs → chunk-VA6N7IVZ.cjs} +6 -6
  54. package/dist/{chunk-FO7SD2IQ.cjs.map → chunk-VA6N7IVZ.cjs.map} +1 -1
  55. package/dist/{chunk-CWHLVXUW.cjs → chunk-WYS66RIO.cjs} +10 -10
  56. package/dist/{chunk-CWHLVXUW.cjs.map → chunk-WYS66RIO.cjs.map} +1 -1
  57. package/dist/{chunk-XJLWGYL4.cjs → chunk-XVGWYNRY.cjs} +81 -81
  58. package/dist/{chunk-XJLWGYL4.cjs.map → chunk-XVGWYNRY.cjs.map} +1 -1
  59. package/dist/{chunk-ZU2JBBOE.cjs → chunk-XYJ3URIN.cjs} +59 -59
  60. package/dist/{chunk-ZU2JBBOE.cjs.map → chunk-XYJ3URIN.cjs.map} +1 -1
  61. package/dist/{chunk-FVIT23I5.js → chunk-Z5KAIEZ4.js} +3 -3
  62. package/dist/{chunk-YT6RGA3X.js → chunk-ZPLT4XLC.js} +3 -3
  63. package/dist/components/case-studies/index.cjs +16 -16
  64. package/dist/components/case-studies/index.js +4 -4
  65. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  66. package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
  67. package/dist/components/chat/index.cjs +3 -9
  68. package/dist/components/chat/index.cjs.map +1 -1
  69. package/dist/components/chat/index.js +2 -8
  70. package/dist/components/chat/types/entities/program-types.d.ts +29 -18
  71. package/dist/components/chat/types/entities/program-types.d.ts.map +1 -1
  72. package/dist/components/chat/utils/compact-card-classes.d.ts.map +1 -1
  73. package/dist/components/contact/index.cjs +5 -5
  74. package/dist/components/contact/index.js +4 -4
  75. package/dist/components/docs/index.cjs +8 -8
  76. package/dist/components/docs/index.js +7 -7
  77. package/dist/components/embeds/index.cjs +5 -5
  78. package/dist/components/embeds/index.js +4 -4
  79. package/dist/components/faq/index.cjs +5 -5
  80. package/dist/components/faq/index.js +4 -4
  81. package/dist/components/features/index.cjs +4 -4
  82. package/dist/components/features/index.js +3 -3
  83. package/dist/components/help-center-pages/index.cjs +24 -24
  84. package/dist/components/help-center-pages/index.js +15 -15
  85. package/dist/components/index.cjs +53 -59
  86. package/dist/components/index.cjs.map +1 -1
  87. package/dist/components/index.js +15 -21
  88. package/dist/components/index.js.map +1 -1
  89. package/dist/components/meeting-scheduler/index.cjs +34 -34
  90. package/dist/components/meeting-scheduler/index.js +3 -3
  91. package/dist/components/navigation/index.cjs +7 -7
  92. package/dist/components/navigation/index.js +6 -6
  93. package/dist/components/onboarding-guides/index.cjs +7 -7
  94. package/dist/components/onboarding-guides/index.js +6 -6
  95. package/dist/components/related-content/index.cjs +3 -3
  96. package/dist/components/related-content/index.js +2 -2
  97. package/dist/components/tickets/index.cjs +8 -8
  98. package/dist/components/tickets/index.js +7 -7
  99. package/dist/components/ui/index.cjs +4 -10
  100. package/dist/components/ui/index.cjs.map +1 -1
  101. package/dist/components/ui/index.js +3 -9
  102. package/dist/index.cjs +24 -8
  103. package/dist/index.cjs.map +1 -1
  104. package/dist/index.js +30 -14
  105. package/dist/index.js.map +1 -1
  106. package/dist/utils/format.d.ts +127 -4
  107. package/dist/utils/format.d.ts.map +1 -1
  108. package/dist/utils/index.cjs +113 -5
  109. package/dist/utils/index.cjs.map +1 -1
  110. package/dist/utils/index.d.ts +4 -1
  111. package/dist/utils/index.d.ts.map +1 -1
  112. package/dist/utils/index.js +103 -6
  113. package/dist/utils/index.js.map +1 -1
  114. package/dist/utils/program-instant.d.ts +171 -0
  115. package/dist/utils/program-instant.d.ts.map +1 -0
  116. package/dist/utils/program-meta-renderers.d.ts +3 -0
  117. package/dist/utils/program-meta-renderers.d.ts.map +1 -0
  118. package/dist/utils/url-safety.d.ts +35 -0
  119. package/dist/utils/url-safety.d.ts.map +1 -0
  120. package/package.json +1 -1
  121. package/src/chat-protocol/__tests__/source-metadata.test.ts +76 -0
  122. package/src/chat-protocol/source-metadata.ts +40 -6
  123. package/src/components/chat/entity-cards/.program-card.md +1 -1
  124. package/src/components/chat/entity-cards/dispatch.tsx +9 -27
  125. package/src/components/chat/entity-cards/program-card.tsx +42 -81
  126. package/src/components/chat/types/entities/program-types.ts +29 -89
  127. package/src/components/chat/utils/.compact-card-classes.md +1 -1
  128. package/src/components/chat/utils/compact-card-classes.ts +5 -3
  129. package/src/utils/.format.md +5 -2
  130. package/src/utils/__tests__/format-program-dates.test.ts +180 -0
  131. package/src/utils/__tests__/program-instant.test.ts +170 -0
  132. package/src/utils/__tests__/url-safety.test.ts +44 -0
  133. package/src/utils/format.ts +228 -13
  134. package/src/utils/index.ts +22 -0
  135. package/src/utils/program-instant.ts +211 -0
  136. package/src/utils/program-meta-renderers.ts +18 -0
  137. package/src/utils/url-safety.ts +45 -0
  138. package/dist/chunk-2DJH6KHA.cjs.map +0 -1
  139. package/dist/chunk-2NRLRRMR.cjs.map +0 -1
  140. package/dist/chunk-3IPL6G7S.js.map +0 -1
  141. /package/dist/{chunk-64KDKDYC.js.map → chunk-5ELZ2NQ5.js.map} +0 -0
  142. /package/dist/{chunk-N7UYD57Q.js.map → chunk-C7RU466R.js.map} +0 -0
  143. /package/dist/{chunk-7HL2PNQ3.js.map → chunk-GEGE3JXC.js.map} +0 -0
  144. /package/dist/{chunk-4TE53O6U.js.map → chunk-HAQRGJFL.js.map} +0 -0
  145. /package/dist/{chunk-TIOHTWDA.js.map → chunk-INISTVWK.js.map} +0 -0
  146. /package/dist/{chunk-IU3IYXMM.js.map → chunk-IRV2W7GN.js.map} +0 -0
  147. /package/dist/{chunk-O7JMF5OT.js.map → chunk-O47SGDBV.js.map} +0 -0
  148. /package/dist/{chunk-NCHLLTAR.js.map → chunk-PR6IR22M.js.map} +0 -0
  149. /package/dist/{chunk-6MQBLFUM.js.map → chunk-Q7JDIDE2.js.map} +0 -0
  150. /package/dist/{chunk-YG7KLZE7.js.map → chunk-R5EIFOW2.js.map} +0 -0
  151. /package/dist/{chunk-3LXJEXPH.js.map → chunk-TAP4MJPF.js.map} +0 -0
  152. /package/dist/{chunk-HA2U7WHU.js.map → chunk-TXNWDP3M.js.map} +0 -0
  153. /package/dist/{chunk-IIZX3K2R.js.map → chunk-URGDDCJL.js.map} +0 -0
  154. /package/dist/{chunk-TQ7KTANJ.js.map → chunk-V52INSJH.js.map} +0 -0
  155. /package/dist/{chunk-FVIT23I5.js.map → chunk-Z5KAIEZ4.js.map} +0 -0
  156. /package/dist/{chunk-YT6RGA3X.js.map → chunk-ZPLT4XLC.js.map} +0 -0
@@ -0,0 +1,211 @@
1
+ /**
2
+ * "Which instant does a program render, in which zone, and does it have a clock
3
+ * at all" — ONE owner, shared by every surface that shows a webinar, event or
4
+ * podcast, in this package AND in the hub.
5
+ *
6
+ * WHY THIS EXISTS. A card must render every part of ONE timestamp in ONE zone.
7
+ * The date used to come from `item.date` while the time beside it came from
8
+ * `start_at` in the event's own IANA zone, so a webinar at
9
+ * `2026-03-20T01:18Z` / `America/New_York` read "Mar 20, 2026 · 9:18 PM" — a
10
+ * date and a time that never coexisted. That was fixed on the public card and
11
+ * then, because the chat card is a SEPARATE component that merely mirrors it in
12
+ * a comment, the chat card kept the bug — and rendered the date in the
13
+ * VIEWER's zone besides, which is also a React #418 hydration mismatch.
14
+ *
15
+ * Two components describing the same rule in prose is how that happens. They
16
+ * now call this. It lives in `utils/` rather than beside the chat cards
17
+ * because it is not chat-specific and because the hub's own program surfaces
18
+ * must be able to import it — while it sat unexported next to the cards, the
19
+ * hub re-derived it by hand and the copies drifted again, which is the third
20
+ * time this one rule has been re-stated.
21
+ *
22
+ * THE RULE:
23
+ *
24
+ * - `item.date` IS the instant to render. The host resolves it once, applying
25
+ * any admin display override, and hands the same value to the card, the
26
+ * model's context and the API wire. Preferring `start_at` looks like it buys
27
+ * intra-card coherence — it does, by disagreeing with everything else.
28
+ * - `start_at` / `end_at` remain the source for DURATION, which is elapsed time
29
+ * rather than a display date.
30
+ * - A DISPLAY OVERRIDE is a chosen date, not a moment. An admin backdating in a
31
+ * `datetime-local` control gets `00:00`, so "show this as March 19" is stored
32
+ * at UTC midnight; rendering that in a west-of-UTC zone shows March 18 at
33
+ * 8 PM — a day early, at a time nobody chose. Such a value renders UTC-pinned
34
+ * with no clock and WITHOUT A ZONE LABEL.
35
+ *
36
+ * The discriminator is "did an override supply this", NOT the value's
37
+ * precision. The override column is `timestamptz` and the host normalizes it
38
+ * through `toISOString()`, so it is always a full instant — an earlier
39
+ * attempt keyed on precision and could therefore never fire.
40
+ *
41
+ * THE ZONE IS NULLED RATHER THAN FLAGGED, deliberately. `timezone` here is "the
42
+ * zone this value renders in and may be labelled with", so a day-valued row
43
+ * carries none and a consumer CANNOT print `America/New_York` under a clock the
44
+ * rule just suppressed. Three surfaces had to remember that gate; two forgot,
45
+ * and one of them rendered a bare IANA string under an empty heading. A rule
46
+ * enforced by the shape of the data cannot be forgotten by the next call site.
47
+ *
48
+ * There is deliberately NO escape hatch back to the un-nulled zone. One was
49
+ * added ("for the rare consumer that needs it as data") and no consumer ever
50
+ * wanted it — an un-nulled copy hanging off the resolved value is just the
51
+ * mistake again, one property away.
52
+ */
53
+
54
+ /** Read a string field off an item type that does not declare it. */
55
+ export const programStr = (value: unknown): string | null => (typeof value === 'string' && value ? value : null);
56
+
57
+ export interface ProgramInstant {
58
+ /** The instant both the date and the time render from, or null to fall back
59
+ * to `utcDate`. */
60
+ instant: string | null;
61
+ /** The zone this value RENDERS IN and may be LABELLED with. Null when the row
62
+ * declares none, and null when the value is day-valued — see the note above
63
+ * on why this is nulled rather than flagged. */
64
+ timezone: string | null;
65
+ /** True when an admin display override supplied the value: render the day
66
+ * UTC-pinned, with no clock. */
67
+ dateOnly: boolean;
68
+ /** The row's canonical date string, used when there is no zone to render in.
69
+ * Kept on the resolved value so the UTC fallback is not re-derived (and
70
+ * re-formatted differently) at each call site. */
71
+ utcDate: string | null;
72
+ }
73
+
74
+ /**
75
+ * The columns this rule reads. Declared structurally rather than as a
76
+ * `Record<string, unknown>` so a caller holding a real `BaseProgramItem` can
77
+ * pass it straight in: while the parameter was a bare record, every one of the
78
+ * four call sites wrote `as unknown as Record<string, unknown>`, and a cast at
79
+ * every call site is how a producer that forgets to set the flag goes
80
+ * unnoticed by the compiler.
81
+ */
82
+ export interface ProgramDateFields {
83
+ date?: unknown;
84
+ start_at?: unknown;
85
+ end_at?: unknown;
86
+ timezone?: unknown;
87
+ date_is_display_override?: unknown;
88
+ }
89
+
90
+ /** Resolve what a program item should render. */
91
+ export function programDateInstant(item: ProgramDateFields): ProgramInstant {
92
+ const declaredZone = programStr(item.timezone);
93
+ const dateOnly = item.date_is_display_override === true;
94
+ const date = programStr(item.date);
95
+ const startAt = programStr(item.start_at);
96
+
97
+ // A day-valued row has no zone to render in, and a row that declares none
98
+ // keeps the caller's UTC pin — which is the React #418 fix and must not be
99
+ // "fixed" into a viewer-local render.
100
+ const timezone = dateOnly ? null : declaredZone;
101
+ return {
102
+ instant: timezone ? (date ?? startAt) : null,
103
+ timezone,
104
+ dateOnly,
105
+ utcDate: date ?? startAt,
106
+ };
107
+ }
108
+
109
+ /**
110
+ * The scheduling columns the DURATION is measured from — the pair that rides
111
+ * beside a resolved instant.
112
+ *
113
+ * Here rather than at each surface because five call sites projected these two
114
+ * columns in four different shapes (`programStr`, raw reads, `?? null`, and an
115
+ * `in`-guarded cast), which is the same defect one field-pair down from the one
116
+ * this module exists to fix. They are read off the row, never off the resolved
117
+ * instant, because elapsed time is not a display date: an override moves the
118
+ * day shown, and a webinar still runs for 45 minutes.
119
+ */
120
+ export function webinarTiming(item: ProgramDateFields): {
121
+ startAt: string | null;
122
+ endAt: string | null;
123
+ } {
124
+ // No `timezone` here on purpose: it would be a second derivation of what
125
+ // `programDateInstant` already resolved (and the UN-NULLED one, so a call
126
+ // site could reintroduce a zone the day-valued rule just dropped).
127
+ return { startAt: programStr(item.start_at), endAt: programStr(item.end_at) };
128
+ }
129
+
130
+ /**
131
+ * THE compact meta line a program renders under its title:
132
+ * `"<day> · <type-specific>"` — podcast duration, event location, or webinar
133
+ * time + duration.
134
+ *
135
+ * The public card and the chat card built this separately, under a comment
136
+ * saying the second "mirrors" the first. That is the arrangement this module
137
+ * exists to end: the mirror drifted twice (the chat card rendered the day in
138
+ * the VIEWER's zone, and the two disagreed about labelling the zone on a
139
+ * zoneless row), each time only on the copy nobody was looking at.
140
+ *
141
+ * `kind` rather than the caller's config object, because the two callers key
142
+ * off differently-shaped configs for the same three types.
143
+ */
144
+ export function programMetaLine(
145
+ item: ProgramDateFields & {
146
+ status?: unknown;
147
+ duration_seconds?: unknown;
148
+ location_name?: unknown;
149
+ },
150
+ kind: 'podcast' | 'event' | 'webinar' | (string & {}),
151
+ fmt: {
152
+ date: (at: ProgramInstant) => string;
153
+ duration: (seconds: number) => string;
154
+ webinarMeta: (at: ProgramInstant, opts: { startAt: string | null; endAt: string | null }) => string;
155
+ },
156
+ ): { at: ProgramInstant; typeMeta: string | null; line: string } {
157
+ const at = programDateInstant(item);
158
+ // A scheduled podcast has not aired, so its stored duration is not elapsed
159
+ // time yet and must not be shown as one.
160
+ const isScheduled = item.status === 'scheduled';
161
+ let typeMeta: string | null = null;
162
+ if (kind === 'podcast' && typeof item.duration_seconds === 'number' && item.duration_seconds > 0 && !isScheduled) {
163
+ typeMeta = fmt.duration(item.duration_seconds);
164
+ } else if (kind === 'event' && typeof item.location_name === 'string' && item.location_name.trim().length > 0) {
165
+ typeMeta = item.location_name;
166
+ } else if (kind === 'webinar' && programStr(item.start_at)) {
167
+ typeMeta = fmt.webinarMeta(at, webinarTiming(item)) || null;
168
+ }
169
+ return { at, typeMeta, line: [fmt.date(at), typeMeta].filter(Boolean).join(' · ') };
170
+ }
171
+
172
+ /** The shape `programMetaFormatters` adapts — the three renderers a program
173
+ * meta line is built from, supplied by the caller so this leaf stays free of
174
+ * `./format`. */
175
+ export interface ProgramMetaRenderers {
176
+ date: (at: ProgramInstant, style: 'medium' | 'weekday') => string;
177
+ duration: (seconds: number | null) => string;
178
+ webinarMeta: (
179
+ at: ProgramInstant,
180
+ opts: { startAt: string | null; endAt: string | null; withZoneLabel?: boolean },
181
+ ) => string;
182
+ }
183
+
184
+ /**
185
+ * The formatter set `programMetaLine` needs, built once.
186
+ *
187
+ * `programMetaLine` unified the DISPATCH; the three formatters passed into it
188
+ * were then mirrored byte-for-byte across the two components the function
189
+ * exists to keep in sync, plus a second `withZoneLabel: false` variant in two
190
+ * more. A mirrored block in exactly those files is the arrangement this module
191
+ * documents as the cause of the original drift.
192
+ *
193
+ * `withZoneLabel` is the only axis: a compact density joins plain strings so
194
+ * the zone rides inline, while the default density renders it as its own styled
195
+ * span and asks for the value without it.
196
+ *
197
+ * Takes its formatters as arguments rather than importing them, so this leaf
198
+ * stays free of `./format` and the two can be tree-shaken apart.
199
+ */
200
+ export function programMetaFormatters(fmt: ProgramMetaRenderers, opts: { withZoneLabel?: boolean } = {}) {
201
+ const withZoneLabel = opts.withZoneLabel !== false;
202
+ return {
203
+ // The meta line always renders the compact day; the one surface that wants
204
+ // the weekday form renders it in its own slot, so a `dateStyle` option here
205
+ // would exist for no caller.
206
+ date: (at: ProgramInstant) => fmt.date(at, 'medium'),
207
+ duration: fmt.duration,
208
+ webinarMeta: (at: ProgramInstant, o: { startAt: string | null; endAt: string | null }) =>
209
+ fmt.webinarMeta(at, { ...o, withZoneLabel }),
210
+ };
211
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * THE three renderers a program meta line is built from.
3
+ *
4
+ * `programMetaFormatters` adapts them (zone label, date style); this is the set
5
+ * itself. It lives here rather than beside either card because the triple was
6
+ * mirrored byte-for-byte in the two components `programMetaLine` exists to keep
7
+ * in sync, and a third copy sat in the host app's page header — unifying the
8
+ * dispatch and leaving the renderer set mirrored in exactly those files is the
9
+ * arrangement this package documents as the cause of the original drift.
10
+ */
11
+ import { formatDurationCompact, formatProgramDate, formatWebinarTimeMeta } from './format';
12
+ import type { ProgramMetaRenderers } from './program-instant';
13
+
14
+ export const PROGRAM_META_RENDERERS: ProgramMetaRenderers = {
15
+ date: formatProgramDate,
16
+ duration: formatDurationCompact,
17
+ webinarMeta: formatWebinarTimeMeta,
18
+ };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * URL-safety primitives shared by the wire DECODER and the render-time guard.
3
+ *
4
+ * Both layers ask the same two questions — "does this string carry characters
5
+ * that have no business in an href" and "does this path stay on our origin" —
6
+ * and both used to answer them with their own copy. A security predicate kept
7
+ * in sync by a comment saying "same set the other one rejects" is a predicate
8
+ * that drifts: the copies already differed on the backslash case, which is how
9
+ * a path resolving to a third-party origin reached an anchor tag.
10
+ *
11
+ * Pure and dependency-free, so the server-safe `chat-protocol` leaf and the
12
+ * client-side card utils can both import it directly.
13
+ *
14
+ * What is NOT shared, deliberately: which SCHEMES each layer allows. The
15
+ * decoder is stricter (https only) because it ingests a remote MCP server's
16
+ * output; the renderer also permits http and mailto. That difference is a
17
+ * policy choice each layer states for itself.
18
+ */
19
+
20
+ /** Control, zero-width and line-separator characters. Never legitimate in a URL
21
+ * we are about to render, and the classic way a payload smuggles one href past
22
+ * a reader's eye. */
23
+ export const UNSAFE_URL_CHARS = /[\u0000-\u001f\u007f\u200b-\u200d\u2028\u2029\ufeff]/;
24
+
25
+ /** Opaque base used only to ask the parser which origin a path lands on. */
26
+ const SAME_ORIGIN_PROBE = 'https://_sameorigin_.invalid';
27
+
28
+ /**
29
+ * Does this candidate stay on the CURRENT origin?
30
+ *
31
+ * Decided by RESOLVING it, never by inspecting the prefix. A prefix test is
32
+ * what a reader reaches for — `startsWith('//')` — and it is not sufficient:
33
+ * the URL parser treats a backslash as a slash in the authority position, so a
34
+ * single-slash path can still resolve to a third-party host while passing every
35
+ * "starts with exactly one slash" check. Any future parser quirk falls to the
36
+ * same class. Asking the parser cannot disagree with what the browser will
37
+ * actually do with the href.
38
+ */
39
+ export function isSameOriginPath(candidate: string): boolean {
40
+ try {
41
+ return new URL(candidate, SAME_ORIGIN_PROBE).origin === SAME_ORIGIN_PROBE;
42
+ } catch {
43
+ return false;
44
+ }
45
+ }