@flamingo-stack/openframe-frontend-core 0.0.642 → 0.0.643-snapshot.20260916153353

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 (201) hide show
  1. package/dist/chat-protocol/index.cjs +6 -3
  2. package/dist/chat-protocol/index.cjs.map +1 -1
  3. package/dist/chat-protocol/index.js +6 -3
  4. package/dist/chat-protocol/index.js.map +1 -1
  5. package/dist/chat-protocol/source-metadata.d.ts +16 -1
  6. package/dist/chat-protocol/source-metadata.d.ts.map +1 -1
  7. package/dist/{chunk-YM6L3WM5.js → chunk-27RD5XTP.js} +3 -3
  8. package/dist/{chunk-POPL3W2S.js → chunk-3DGRXC74.js} +3 -3
  9. package/dist/{chunk-2Z5FPHOL.cjs → chunk-3UBT2OIX.cjs} +20 -20
  10. package/dist/{chunk-2Z5FPHOL.cjs.map → chunk-3UBT2OIX.cjs.map} +1 -1
  11. package/dist/{chunk-6GY6DFIH.js → chunk-4WVWRFGP.js} +6 -6
  12. package/dist/{chunk-OYI3K5R6.cjs → chunk-65EVGKFV.cjs} +8 -14
  13. package/dist/chunk-65EVGKFV.cjs.map +1 -0
  14. package/dist/{chunk-6NHLZORM.js → chunk-7Q5XXPCB.js} +6 -6
  15. package/dist/{chunk-2NRLRRMR.cjs → chunk-7R2DIGG4.cjs} +319 -293
  16. package/dist/chunk-7R2DIGG4.cjs.map +1 -0
  17. package/dist/{chunk-3LXJEXPH.js → chunk-B3Z3RJRW.js} +2 -2
  18. package/dist/{chunk-N5C5P2LM.cjs → chunk-B5IFXCRF.cjs} +22 -22
  19. package/dist/{chunk-N5C5P2LM.cjs.map → chunk-B5IFXCRF.cjs.map} +1 -1
  20. package/dist/{chunk-YRSRP4U3.cjs → chunk-C5Y5T6GC.cjs} +15 -15
  21. package/dist/{chunk-YRSRP4U3.cjs.map → chunk-C5Y5T6GC.cjs.map} +1 -1
  22. package/dist/{chunk-VHB3I6F3.cjs → chunk-CBXZSTAG.cjs} +419 -445
  23. package/dist/chunk-CBXZSTAG.cjs.map +1 -0
  24. package/dist/{chunk-VKPTN5MT.cjs → chunk-DCCY54LU.cjs} +6 -6
  25. package/dist/{chunk-VKPTN5MT.cjs.map → chunk-DCCY54LU.cjs.map} +1 -1
  26. package/dist/{chunk-WL3PNUNY.cjs → chunk-FAD5WURS.cjs} +81 -81
  27. package/dist/{chunk-WL3PNUNY.cjs.map → chunk-FAD5WURS.cjs.map} +1 -1
  28. package/dist/{chunk-3IPL6G7S.js → chunk-FOSIR4QF.js} +260 -234
  29. package/dist/chunk-FOSIR4QF.js.map +1 -0
  30. package/dist/{chunk-MJ424FEC.js → chunk-HOGOQA2X.js} +2 -2
  31. package/dist/{chunk-SDGMLXIP.js → chunk-HPWLIYRL.js} +12 -25
  32. package/dist/chunk-HPWLIYRL.js.map +1 -0
  33. package/dist/{chunk-3I6XHQUD.js → chunk-I57XLISO.js} +54 -80
  34. package/dist/chunk-I57XLISO.js.map +1 -0
  35. package/dist/{chunk-FRCUUK5X.cjs → chunk-IIXB5REN.cjs} +3 -3
  36. package/dist/{chunk-FRCUUK5X.cjs.map → chunk-IIXB5REN.cjs.map} +1 -1
  37. package/dist/{chunk-HW7BLVQH.js → chunk-IXD6SHQ6.js} +4 -4
  38. package/dist/{chunk-XFLJC2WR.cjs → chunk-LZYPSDFE.cjs} +59 -59
  39. package/dist/{chunk-XFLJC2WR.cjs.map → chunk-LZYPSDFE.cjs.map} +1 -1
  40. package/dist/{chunk-QY25ZP2V.cjs → chunk-MCQAOIUK.cjs} +28 -28
  41. package/dist/{chunk-QY25ZP2V.cjs.map → chunk-MCQAOIUK.cjs.map} +1 -1
  42. package/dist/{chunk-S254VEDE.js → chunk-MRIOYSXH.js} +3 -3
  43. package/dist/{chunk-OOOOC5O5.cjs → chunk-OMSUWB6A.cjs} +29 -29
  44. package/dist/{chunk-OOOOC5O5.cjs.map → chunk-OMSUWB6A.cjs.map} +1 -1
  45. package/dist/{chunk-GEIHTN6J.cjs → chunk-OVXYX47B.cjs} +10 -10
  46. package/dist/{chunk-GEIHTN6J.cjs.map → chunk-OVXYX47B.cjs.map} +1 -1
  47. package/dist/{chunk-XWGHLSAL.js → chunk-PFV4DAX5.js} +4 -4
  48. package/dist/{chunk-O4LL7RQV.cjs → chunk-RB6L5EGM.cjs} +208 -221
  49. package/dist/chunk-RB6L5EGM.cjs.map +1 -0
  50. package/dist/{chunk-M4PJVFBF.cjs → chunk-RFFF2EYD.cjs} +11 -11
  51. package/dist/{chunk-M4PJVFBF.cjs.map → chunk-RFFF2EYD.cjs.map} +1 -1
  52. package/dist/{chunk-UFBWNVZZ.js → chunk-RNMGKAS6.js} +7 -7
  53. package/dist/{chunk-SE6YRE3R.cjs → chunk-RWURXICE.cjs} +32 -32
  54. package/dist/{chunk-SE6YRE3R.cjs.map → chunk-RWURXICE.cjs.map} +1 -1
  55. package/dist/{chunk-ZAIYD3MZ.js → chunk-S2KMNFFN.js} +3 -3
  56. package/dist/{chunk-ZGPJ3NVF.js → chunk-SKABQX44.js} +3 -3
  57. package/dist/{chunk-YE3TFNW6.cjs → chunk-TGUA3C4U.cjs} +5 -5
  58. package/dist/{chunk-YE3TFNW6.cjs.map → chunk-TGUA3C4U.cjs.map} +1 -1
  59. package/dist/{chunk-ORFJVMAL.js → chunk-TTVOBWAH.js} +5 -11
  60. package/dist/chunk-TTVOBWAH.js.map +1 -0
  61. package/dist/{chunk-M7QROULE.js → chunk-UEXIMEVU.js} +5 -5
  62. package/dist/{chunk-EW3MSJOE.cjs → chunk-UKV52KAP.cjs} +33 -33
  63. package/dist/{chunk-EW3MSJOE.cjs.map → chunk-UKV52KAP.cjs.map} +1 -1
  64. package/dist/{chunk-J4RZVLLQ.js → chunk-VE52MSYC.js} +5 -5
  65. package/dist/components/case-studies/index.cjs +16 -16
  66. package/dist/components/case-studies/index.js +4 -4
  67. package/dist/components/chat/chat-sidebar.d.ts.map +1 -1
  68. package/dist/components/chat/entity-cards/blog-card.d.ts.map +1 -1
  69. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  70. package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
  71. package/dist/components/chat/index.cjs +3 -9
  72. package/dist/components/chat/index.cjs.map +1 -1
  73. package/dist/components/chat/index.js +2 -8
  74. package/dist/components/chat/types/entities/investor-update.d.ts.map +1 -1
  75. package/dist/components/chat/types/entities/program-types.d.ts +8 -18
  76. package/dist/components/chat/types/entities/program-types.d.ts.map +1 -1
  77. package/dist/components/chat/utils/compact-card-classes.d.ts.map +1 -1
  78. package/dist/components/contact/index.cjs +5 -5
  79. package/dist/components/contact/index.js +4 -4
  80. package/dist/components/docs/index.cjs +8 -8
  81. package/dist/components/docs/index.js +7 -7
  82. package/dist/components/embeds/index.cjs +5 -5
  83. package/dist/components/embeds/index.js +4 -4
  84. package/dist/components/faq/index.cjs +5 -5
  85. package/dist/components/faq/index.js +4 -4
  86. package/dist/components/features/index.cjs +4 -4
  87. package/dist/components/features/index.js +3 -3
  88. package/dist/components/help-center-pages/index.cjs +24 -24
  89. package/dist/components/help-center-pages/index.js +15 -15
  90. package/dist/components/index.cjs +53 -59
  91. package/dist/components/index.cjs.map +1 -1
  92. package/dist/components/index.js +15 -21
  93. package/dist/components/index.js.map +1 -1
  94. package/dist/components/logs-list.d.ts.map +1 -1
  95. package/dist/components/meeting-scheduler/confirmation.d.ts.map +1 -1
  96. package/dist/components/meeting-scheduler/directory.d.ts.map +1 -1
  97. package/dist/components/meeting-scheduler/index.cjs +47 -72
  98. package/dist/components/meeting-scheduler/index.cjs.map +1 -1
  99. package/dist/components/meeting-scheduler/index.d.ts.map +1 -1
  100. package/dist/components/meeting-scheduler/index.js +16 -41
  101. package/dist/components/meeting-scheduler/index.js.map +1 -1
  102. package/dist/components/meeting-scheduler/slot-picker.d.ts.map +1 -1
  103. package/dist/components/navigation/index.cjs +7 -7
  104. package/dist/components/navigation/index.js +6 -6
  105. package/dist/components/onboarding-guides/index.cjs +7 -7
  106. package/dist/components/onboarding-guides/index.js +6 -6
  107. package/dist/components/related-content/index.cjs +3 -3
  108. package/dist/components/related-content/index.js +2 -2
  109. package/dist/components/shared/article-author-byline.d.ts.map +1 -1
  110. package/dist/components/tickets/index.cjs +8 -8
  111. package/dist/components/tickets/index.js +7 -7
  112. package/dist/components/ui/date-picker.d.ts.map +1 -1
  113. package/dist/components/ui/device-card.d.ts.map +1 -1
  114. package/dist/components/ui/drawer.d.ts +19 -5
  115. package/dist/components/ui/drawer.d.ts.map +1 -1
  116. package/dist/components/ui/index.cjs +4 -10
  117. package/dist/components/ui/index.cjs.map +1 -1
  118. package/dist/components/ui/index.js +3 -9
  119. package/dist/components/ui/table/table-timestamp-cell.d.ts.map +1 -1
  120. package/dist/index.cjs +29 -17
  121. package/dist/index.cjs.map +1 -1
  122. package/dist/index.js +35 -23
  123. package/dist/index.js.map +1 -1
  124. package/dist/utils/date-formatters.d.ts +7 -2
  125. package/dist/utils/date-formatters.d.ts.map +1 -1
  126. package/dist/utils/date-utils.d.ts +4 -1
  127. package/dist/utils/date-utils.d.ts.map +1 -1
  128. package/dist/utils/format-date.d.ts.map +1 -1
  129. package/dist/utils/format.d.ts +155 -11
  130. package/dist/utils/format.d.ts.map +1 -1
  131. package/dist/utils/index.cjs +223 -109
  132. package/dist/utils/index.cjs.map +1 -1
  133. package/dist/utils/index.d.ts +4 -1
  134. package/dist/utils/index.d.ts.map +1 -1
  135. package/dist/utils/index.js +211 -110
  136. package/dist/utils/index.js.map +1 -1
  137. package/dist/utils/program-instant.d.ts +145 -0
  138. package/dist/utils/program-instant.d.ts.map +1 -0
  139. package/dist/utils/program-meta-renderers.d.ts +3 -0
  140. package/dist/utils/program-meta-renderers.d.ts.map +1 -0
  141. package/dist/utils/url-safety.d.ts +33 -0
  142. package/dist/utils/url-safety.d.ts.map +1 -0
  143. package/package.json +1 -1
  144. package/src/chat-protocol/__tests__/source-metadata.test.ts +70 -3
  145. package/src/chat-protocol/source-metadata.ts +22 -6
  146. package/src/components/chat/chat-sidebar.tsx +4 -11
  147. package/src/components/chat/entity-cards/.program-card.md +1 -1
  148. package/src/components/chat/entity-cards/blog-card.tsx +4 -24
  149. package/src/components/chat/entity-cards/dispatch.tsx +9 -27
  150. package/src/components/chat/entity-cards/program-card.tsx +42 -81
  151. package/src/components/chat/types/entities/investor-update.ts +4 -6
  152. package/src/components/chat/types/entities/program-types.ts +8 -89
  153. package/src/components/chat/utils/.compact-card-classes.md +1 -1
  154. package/src/components/chat/utils/compact-card-classes.ts +5 -3
  155. package/src/components/logs-list.tsx +4 -13
  156. package/src/components/meeting-scheduler/confirmation.tsx +6 -10
  157. package/src/components/meeting-scheduler/directory.tsx +2 -12
  158. package/src/components/meeting-scheduler/index.tsx +3 -11
  159. package/src/components/meeting-scheduler/slot-picker.tsx +4 -7
  160. package/src/components/shared/article-author-byline.tsx +4 -13
  161. package/src/components/ui/.drawer.md +1 -0
  162. package/src/components/ui/__tests__/drawer-size.test.tsx +38 -0
  163. package/src/components/ui/date-picker.tsx +6 -13
  164. package/src/components/ui/device-card.tsx +4 -10
  165. package/src/components/ui/drawer.tsx +44 -9
  166. package/src/components/ui/table/table-timestamp-cell.tsx +8 -2
  167. package/src/utils/.format.md +5 -2
  168. package/src/utils/__tests__/date-rendering.test.ts +118 -0
  169. package/src/utils/__tests__/format-program-dates.test.ts +148 -0
  170. package/src/utils/__tests__/program-instant.test.ts +125 -0
  171. package/src/utils/__tests__/url-safety.test.ts +44 -0
  172. package/src/utils/date-formatters.ts +18 -29
  173. package/src/utils/date-utils.ts +27 -40
  174. package/src/utils/format-date.ts +14 -16
  175. package/src/utils/format.ts +367 -66
  176. package/src/utils/index.ts +24 -0
  177. package/src/utils/program-instant.ts +180 -0
  178. package/src/utils/program-meta-renderers.ts +18 -0
  179. package/src/utils/url-safety.ts +43 -0
  180. package/dist/chunk-2NRLRRMR.cjs.map +0 -1
  181. package/dist/chunk-3I6XHQUD.js.map +0 -1
  182. package/dist/chunk-3IPL6G7S.js.map +0 -1
  183. package/dist/chunk-O4LL7RQV.cjs.map +0 -1
  184. package/dist/chunk-ORFJVMAL.js.map +0 -1
  185. package/dist/chunk-OYI3K5R6.cjs.map +0 -1
  186. package/dist/chunk-SDGMLXIP.js.map +0 -1
  187. package/dist/chunk-VHB3I6F3.cjs.map +0 -1
  188. /package/dist/{chunk-YM6L3WM5.js.map → chunk-27RD5XTP.js.map} +0 -0
  189. /package/dist/{chunk-POPL3W2S.js.map → chunk-3DGRXC74.js.map} +0 -0
  190. /package/dist/{chunk-6GY6DFIH.js.map → chunk-4WVWRFGP.js.map} +0 -0
  191. /package/dist/{chunk-6NHLZORM.js.map → chunk-7Q5XXPCB.js.map} +0 -0
  192. /package/dist/{chunk-3LXJEXPH.js.map → chunk-B3Z3RJRW.js.map} +0 -0
  193. /package/dist/{chunk-MJ424FEC.js.map → chunk-HOGOQA2X.js.map} +0 -0
  194. /package/dist/{chunk-HW7BLVQH.js.map → chunk-IXD6SHQ6.js.map} +0 -0
  195. /package/dist/{chunk-S254VEDE.js.map → chunk-MRIOYSXH.js.map} +0 -0
  196. /package/dist/{chunk-XWGHLSAL.js.map → chunk-PFV4DAX5.js.map} +0 -0
  197. /package/dist/{chunk-UFBWNVZZ.js.map → chunk-RNMGKAS6.js.map} +0 -0
  198. /package/dist/{chunk-ZAIYD3MZ.js.map → chunk-S2KMNFFN.js.map} +0 -0
  199. /package/dist/{chunk-ZGPJ3NVF.js.map → chunk-SKABQX44.js.map} +0 -0
  200. /package/dist/{chunk-M7QROULE.js.map → chunk-UEXIMEVU.js.map} +0 -0
  201. /package/dist/{chunk-J4RZVLLQ.js.map → chunk-VE52MSYC.js.map} +0 -0
@@ -0,0 +1,180 @@
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 and hands
25
+ * the same value to the card, the model's context and the API wire.
26
+ * Preferring `start_at` looks like it buys intra-card coherence — it does, by
27
+ * 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
+ *
31
+ * `timezone` here is "the zone this value renders in and may be labelled with".
32
+ * A row that declares none keeps the UTC pin (the React #418 fix).
33
+ *
34
+ */
35
+
36
+ /** Read a string field off an item type that does not declare it. */
37
+ export const programStr = (value: unknown): string | null => (typeof value === 'string' && value ? value : null);
38
+
39
+ export interface ProgramInstant {
40
+ /** The instant both the date and the time render from, or null to fall back
41
+ * to `utcDate`. */
42
+ instant: string | null;
43
+ /** The zone this value RENDERS IN and may be LABELLED with. Null when the row
44
+ * declares none. */
45
+ timezone: string | null;
46
+ /** The row's canonical date string, used when there is no zone to render in.
47
+ * Kept on the resolved value so the UTC fallback is not re-derived (and
48
+ * re-formatted differently) at each call site. */
49
+ utcDate: string | null;
50
+ }
51
+
52
+ /**
53
+ * The columns this rule reads. Declared structurally rather than as a
54
+ * `Record<string, unknown>` so a caller holding a real `BaseProgramItem` can
55
+ * pass it straight in: while the parameter was a bare record, every one of the
56
+ * four call sites wrote `as unknown as Record<string, unknown>`.
57
+ */
58
+ export interface ProgramDateFields {
59
+ date?: unknown;
60
+ start_at?: unknown;
61
+ end_at?: unknown;
62
+ timezone?: unknown;
63
+ }
64
+
65
+ /** Resolve what a program item should render. */
66
+ export function programDateInstant(item: ProgramDateFields): ProgramInstant {
67
+ const timezone = programStr(item.timezone);
68
+ const date = programStr(item.date);
69
+ const startAt = programStr(item.start_at);
70
+
71
+ // A row that declares no zone keeps the caller's UTC pin — which is the
72
+ // React #418 fix and must not be "fixed" into a viewer-local render.
73
+ return {
74
+ instant: timezone ? (date ?? startAt) : null,
75
+ timezone,
76
+ utcDate: date ?? startAt,
77
+ };
78
+ }
79
+
80
+ /**
81
+ * The scheduling columns the DURATION is measured from — the pair that rides
82
+ * beside a resolved instant.
83
+ *
84
+ * Here rather than at each surface because five call sites projected these two
85
+ * columns in four different shapes (`programStr`, raw reads, `?? null`, and an
86
+ * `in`-guarded cast), which is the same defect one field-pair down from the one
87
+ * this module exists to fix. They are read off the row, never off the resolved
88
+ * instant, because elapsed time is not a display date.
89
+ */
90
+ export function webinarTiming(item: ProgramDateFields): {
91
+ startAt: string | null;
92
+ endAt: string | null;
93
+ } {
94
+ // No `timezone` here on purpose: it would be a second derivation of what
95
+ // `programDateInstant` already resolved.
96
+ return { startAt: programStr(item.start_at), endAt: programStr(item.end_at) };
97
+ }
98
+
99
+ /**
100
+ * THE compact meta line a program renders under its title:
101
+ * `"<day> · <type-specific>"` — podcast duration, event location, or webinar
102
+ * time + duration.
103
+ *
104
+ * The public card and the chat card built this separately, under a comment
105
+ * saying the second "mirrors" the first. That is the arrangement this module
106
+ * exists to end: the mirror drifted twice (the chat card rendered the day in
107
+ * the VIEWER's zone, and the two disagreed about labelling the zone on a
108
+ * zoneless row), each time only on the copy nobody was looking at.
109
+ *
110
+ * `kind` rather than the caller's config object, because the two callers key
111
+ * off differently-shaped configs for the same three types.
112
+ */
113
+ export function programMetaLine(
114
+ item: ProgramDateFields & {
115
+ status?: unknown;
116
+ duration_seconds?: unknown;
117
+ location_name?: unknown;
118
+ },
119
+ kind: 'podcast' | 'event' | 'webinar' | (string & {}),
120
+ fmt: {
121
+ date: (at: ProgramInstant) => string;
122
+ duration: (seconds: number) => string;
123
+ webinarMeta: (at: ProgramInstant, opts: { startAt: string | null; endAt: string | null }) => string;
124
+ },
125
+ ): { at: ProgramInstant; typeMeta: string | null; line: string } {
126
+ const at = programDateInstant(item);
127
+ // A scheduled podcast has not aired, so its stored duration is not elapsed
128
+ // time yet and must not be shown as one.
129
+ const isScheduled = item.status === 'scheduled';
130
+ let typeMeta: string | null = null;
131
+ if (kind === 'podcast' && typeof item.duration_seconds === 'number' && item.duration_seconds > 0 && !isScheduled) {
132
+ typeMeta = fmt.duration(item.duration_seconds);
133
+ } else if (kind === 'event' && typeof item.location_name === 'string' && item.location_name.trim().length > 0) {
134
+ typeMeta = item.location_name;
135
+ } else if (kind === 'webinar' && programStr(item.start_at)) {
136
+ typeMeta = fmt.webinarMeta(at, webinarTiming(item)) || null;
137
+ }
138
+ return { at, typeMeta, line: [fmt.date(at), typeMeta].filter(Boolean).join(' · ') };
139
+ }
140
+
141
+ /** The shape `programMetaFormatters` adapts — the three renderers a program
142
+ * meta line is built from, supplied by the caller so this leaf stays free of
143
+ * `./format`. */
144
+ export interface ProgramMetaRenderers {
145
+ date: (at: ProgramInstant, style: 'medium' | 'weekday') => string;
146
+ duration: (seconds: number | null) => string;
147
+ webinarMeta: (
148
+ at: ProgramInstant,
149
+ opts: { startAt: string | null; endAt: string | null; withZoneLabel?: boolean },
150
+ ) => string;
151
+ }
152
+
153
+ /**
154
+ * The formatter set `programMetaLine` needs, built once.
155
+ *
156
+ * `programMetaLine` unified the DISPATCH; the three formatters passed into it
157
+ * were then mirrored byte-for-byte across the two components the function
158
+ * exists to keep in sync, plus a second `withZoneLabel: false` variant in two
159
+ * more. A mirrored block in exactly those files is the arrangement this module
160
+ * documents as the cause of the original drift.
161
+ *
162
+ * `withZoneLabel` is the only axis: a compact density joins plain strings so
163
+ * the zone rides inline, while the default density renders it as its own styled
164
+ * span and asks for the value without it.
165
+ *
166
+ * Takes its formatters as arguments rather than importing them, so this leaf
167
+ * stays free of `./format` and the two can be tree-shaken apart.
168
+ */
169
+ export function programMetaFormatters(fmt: ProgramMetaRenderers, opts: { withZoneLabel?: boolean } = {}) {
170
+ const withZoneLabel = opts.withZoneLabel !== false;
171
+ return {
172
+ // The meta line always renders the compact day; the one surface that wants
173
+ // the weekday form renders it in its own slot, so a `dateStyle` option here
174
+ // would exist for no caller.
175
+ date: (at: ProgramInstant) => fmt.date(at, 'medium'),
176
+ duration: fmt.duration,
177
+ webinarMeta: (at: ProgramInstant, o: { startAt: string | null; endAt: string | null }) =>
178
+ fmt.webinarMeta(at, { ...o, withZoneLabel }),
179
+ };
180
+ }
@@ -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,43 @@
1
+ /**
2
+ * URL-safety primitives for the wire DECODER and the render-time guard.
3
+ *
4
+ * `UNSAFE_URL_CHARS` is shared by both: "does this string carry characters that
5
+ * have no business in an href" had two copies once, and a security predicate
6
+ * kept in sync by a comment drifts.
7
+ *
8
+ * `isSameOriginPath` answers "does this path stay on our origin" for the
9
+ * render-time `safeHref` — the ONE gate every chat href passes. The wire decoder
10
+ * does not judge links at all: it carries them, because resolving a link is a
11
+ * client decision (only the rendering page knows where it is embedded), and a
12
+ * second, stricter gate there only dropped links it could not resolve itself.
13
+ *
14
+ * Pure and dependency-free, so the server-safe `chat-protocol` leaf and the
15
+ * client-side card utils can both import it directly.
16
+ */
17
+
18
+ /** Control, zero-width and line-separator characters. Never legitimate in a URL
19
+ * we are about to render, and the classic way a payload smuggles one href past
20
+ * a reader's eye. */
21
+ export const UNSAFE_URL_CHARS = /[\u0000-\u001f\u007f\u200b-\u200d\u2028\u2029\ufeff]/;
22
+
23
+ /** Opaque base used only to ask the parser which origin a path lands on. */
24
+ const SAME_ORIGIN_PROBE = 'https://_sameorigin_.invalid';
25
+
26
+ /**
27
+ * Does this candidate stay on the CURRENT origin?
28
+ *
29
+ * Decided by RESOLVING it, never by inspecting the prefix. A prefix test is
30
+ * what a reader reaches for — `startsWith('//')` — and it is not sufficient:
31
+ * the URL parser treats a backslash as a slash in the authority position, so a
32
+ * single-slash path can still resolve to a third-party host while passing every
33
+ * "starts with exactly one slash" check. Any future parser quirk falls to the
34
+ * same class. Asking the parser cannot disagree with what the browser will
35
+ * actually do with the href.
36
+ */
37
+ export function isSameOriginPath(candidate: string): boolean {
38
+ try {
39
+ return new URL(candidate, SAME_ORIGIN_PROBE).origin === SAME_ORIGIN_PROBE;
40
+ } catch {
41
+ return false;
42
+ }
43
+ }