@flamingo-stack/openframe-frontend-core 0.0.406-snapshot.20260711131925 → 0.0.406
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/{chunk-2B6773QM.cjs → chunk-3KEBI6TP.cjs} +1 -1
- package/dist/chunk-3KEBI6TP.cjs.map +1 -0
- package/dist/{chunk-HJIRG7R6.js → chunk-3KZXOLFK.js} +4 -4
- package/dist/{chunk-43H2WOAW.js → chunk-6WMVBCNA.js} +3 -3
- package/dist/{chunk-XFP43YKG.js → chunk-7RVSGGO6.js} +6 -6
- package/dist/{chunk-KLBEIJVZ.js → chunk-AYFWYOL6.js} +7 -7
- package/dist/{chunk-GMZL4T7C.js → chunk-C3NPMZBI.js} +3 -3
- package/dist/{chunk-STGWQFYT.cjs → chunk-CCIBZ7TO.cjs} +5 -5
- package/dist/chunk-CCIBZ7TO.cjs.map +1 -0
- package/dist/{chunk-Q2MC3CBI.cjs → chunk-CF3LBCNI.cjs} +35 -35
- package/dist/{chunk-Q2MC3CBI.cjs.map → chunk-CF3LBCNI.cjs.map} +1 -1
- package/dist/{chunk-DOBNDDNE.cjs → chunk-COERBDG4.cjs} +75 -75
- package/dist/{chunk-DOBNDDNE.cjs.map → chunk-COERBDG4.cjs.map} +1 -1
- package/dist/{chunk-7Q52HP45.js → chunk-E6YHDT3D.js} +2 -2
- package/dist/chunk-E6YHDT3D.js.map +1 -0
- package/dist/{chunk-74FWQI73.cjs → chunk-GNS65HNC.cjs} +18 -18
- package/dist/{chunk-74FWQI73.cjs.map → chunk-GNS65HNC.cjs.map} +1 -1
- package/dist/{chunk-WCPUJA3Y.cjs → chunk-HJJXNMM7.cjs} +7 -7
- package/dist/{chunk-WCPUJA3Y.cjs.map → chunk-HJJXNMM7.cjs.map} +1 -1
- package/dist/{chunk-R4MXLJUS.cjs → chunk-ISYVNPRT.cjs} +42 -42
- package/dist/{chunk-R4MXLJUS.cjs.map → chunk-ISYVNPRT.cjs.map} +1 -1
- package/dist/{chunk-YX7C5JD7.cjs → chunk-JAPP2F4M.cjs} +77 -77
- package/dist/{chunk-YX7C5JD7.cjs.map → chunk-JAPP2F4M.cjs.map} +1 -1
- package/dist/{chunk-GGDM5J4B.cjs → chunk-LL4QQSAD.cjs} +322 -331
- package/dist/chunk-LL4QQSAD.cjs.map +1 -0
- package/dist/{chunk-GJSLKATJ.js → chunk-LSPBPUQM.js} +2 -2
- package/dist/{chunk-KFQXO7QB.js → chunk-NA7XJRWB.js} +1 -1
- package/dist/chunk-NA7XJRWB.js.map +1 -0
- package/dist/{chunk-H66L2265.js → chunk-OATWTTCI.js} +6 -6
- package/dist/{chunk-LPC3C7MG.cjs → chunk-P43ZHPM6.cjs} +40 -40
- package/dist/{chunk-LPC3C7MG.cjs.map → chunk-P43ZHPM6.cjs.map} +1 -1
- package/dist/{chunk-NO2KT42M.js → chunk-PNJ5LMVK.js} +10 -9
- package/dist/{chunk-NO2KT42M.js.map → chunk-PNJ5LMVK.js.map} +1 -1
- package/dist/{chunk-NSF7JUXF.js → chunk-PQN5R5II.js} +7 -7
- package/dist/{chunk-CUN4CJUN.cjs → chunk-QAFRLO5N.cjs} +11 -10
- package/dist/chunk-QAFRLO5N.cjs.map +1 -0
- package/dist/{chunk-LC6RRLFA.cjs → chunk-SF4G7M6U.cjs} +15 -15
- package/dist/{chunk-LC6RRLFA.cjs.map → chunk-SF4G7M6U.cjs.map} +1 -1
- package/dist/{chunk-CVYSW33D.js → chunk-SOK32D6C.js} +189 -198
- package/dist/chunk-SOK32D6C.js.map +1 -0
- package/dist/{chunk-4UZH3MT2.js → chunk-TFDNJTBX.js} +4 -4
- package/dist/{chunk-5M5W6XDY.cjs → chunk-VANFD4FX.cjs} +7 -7
- package/dist/{chunk-5M5W6XDY.cjs.map → chunk-VANFD4FX.cjs.map} +1 -1
- package/dist/{chunk-PRKMOF2U.cjs → chunk-VIB4SGCD.cjs} +14 -14
- package/dist/{chunk-PRKMOF2U.cjs.map → chunk-VIB4SGCD.cjs.map} +1 -1
- package/dist/{chunk-SY3QS2E5.cjs → chunk-VZGU4BV6.cjs} +29 -29
- package/dist/{chunk-SY3QS2E5.cjs.map → chunk-VZGU4BV6.cjs.map} +1 -1
- package/dist/{chunk-7XVFSGQA.js → chunk-XXG2Z2JT.js} +3 -3
- package/dist/{chunk-HB63TQQO.js → chunk-ZVUR3A33.js} +2 -2
- package/dist/components/announcement-bar.d.ts.map +1 -1
- package/dist/components/case-studies/index.cjs +10 -10
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/index.cjs +4 -4
- package/dist/components/chat/index.js +3 -3
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +6 -6
- package/dist/components/faq/index.js +5 -5
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +23 -23
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +179 -185
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +32 -38
- package/dist/components/index.js.map +1 -1
- package/dist/components/navigation/index.cjs +4 -4
- package/dist/components/navigation/index.js +3 -3
- package/dist/components/onboarding-guides/index.cjs +8 -8
- package/dist/components/onboarding-guides/index.js +7 -7
- package/dist/components/related-content/index.cjs +6 -6
- package/dist/components/related-content/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/index.cjs +4 -4
- package/dist/components/ui/index.js +3 -3
- package/dist/contexts/endpoints-runtime-context.d.ts +1 -1
- package/dist/contexts/endpoints-runtime-context.d.ts.map +1 -1
- package/dist/contexts/index.cjs +2 -2
- package/dist/contexts/index.js +1 -1
- package/dist/hooks/index.cjs +3 -3
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/use-self-fetch.d.ts.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/types/announcement.cjs.map +1 -1
- package/dist/types/announcement.d.ts +6 -0
- package/dist/types/announcement.d.ts.map +1 -1
- package/dist/types/announcement.js.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/announcement-storage.d.ts +0 -3
- package/dist/utils/announcement-storage.d.ts.map +1 -1
- package/dist/utils/app-config.d.ts.map +1 -1
- package/dist/utils/color-analysis.d.ts +4 -0
- package/dist/utils/color-analysis.d.ts.map +1 -1
- package/dist/utils/index.cjs +177 -186
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +176 -185
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/ods-color-utils.d.ts +1 -2
- package/dist/utils/ods-color-utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/announcement-bar.tsx +21 -38
- package/src/contexts/endpoints-runtime-context.tsx +1 -1
- package/src/hooks/use-self-fetch.ts +9 -10
- package/src/stories/AnnouncementBar.stories.tsx +14 -8
- package/src/types/announcement.ts +8 -0
- package/src/utils/announcement-storage.ts +0 -17
- package/src/utils/app-config.ts +2 -3
- package/src/utils/color-analysis.ts +2 -5
- package/src/utils/ods-color-utils.ts +7 -4
- package/dist/chunk-2B6773QM.cjs.map +0 -1
- package/dist/chunk-7Q52HP45.js.map +0 -1
- package/dist/chunk-CUN4CJUN.cjs.map +0 -1
- package/dist/chunk-CVYSW33D.js.map +0 -1
- package/dist/chunk-GGDM5J4B.cjs.map +0 -1
- package/dist/chunk-KFQXO7QB.js.map +0 -1
- package/dist/chunk-STGWQFYT.cjs.map +0 -1
- /package/dist/{chunk-HJIRG7R6.js.map → chunk-3KZXOLFK.js.map} +0 -0
- /package/dist/{chunk-43H2WOAW.js.map → chunk-6WMVBCNA.js.map} +0 -0
- /package/dist/{chunk-XFP43YKG.js.map → chunk-7RVSGGO6.js.map} +0 -0
- /package/dist/{chunk-KLBEIJVZ.js.map → chunk-AYFWYOL6.js.map} +0 -0
- /package/dist/{chunk-GMZL4T7C.js.map → chunk-C3NPMZBI.js.map} +0 -0
- /package/dist/{chunk-GJSLKATJ.js.map → chunk-LSPBPUQM.js.map} +0 -0
- /package/dist/{chunk-H66L2265.js.map → chunk-OATWTTCI.js.map} +0 -0
- /package/dist/{chunk-NSF7JUXF.js.map → chunk-PQN5R5II.js.map} +0 -0
- /package/dist/{chunk-4UZH3MT2.js.map → chunk-TFDNJTBX.js.map} +0 -0
- /package/dist/{chunk-7XVFSGQA.js.map → chunk-XXG2Z2JT.js.map} +0 -0
- /package/dist/{chunk-HB63TQQO.js.map → chunk-ZVUR3A33.js.map} +0 -0
|
@@ -75,8 +75,7 @@ export declare function usePlatformColors(platform?: Platform): {
|
|
|
75
75
|
};
|
|
76
76
|
/**
|
|
77
77
|
* Picks a near-black or near-white text color with adequate contrast on `hex`.
|
|
78
|
-
*
|
|
79
|
-
* light-or-dark decision formula (WCAG relative luminance) for the whole lib.
|
|
78
|
+
* Uses Rec. 601 luminance.
|
|
80
79
|
*/
|
|
81
80
|
export declare function getReadableTextColor(hex: string): string;
|
|
82
81
|
export declare const HEX_PATTERN: RegExp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ods-color-utils.d.ts","sourceRoot":"","sources":["../../src/utils/ods-color-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"ods-color-utils.d.ts","sourceRoot":"","sources":["../../src/utils/ods-color-utils.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useMemo,
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { X } from 'lucide-react';
|
|
5
5
|
import { Button } from './ui/button';
|
|
6
6
|
import { EntityIcon } from './icon-display';
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
isAnnouncementDismissed,
|
|
10
10
|
clearLegacyAnnouncementCache,
|
|
11
11
|
} from '../utils/announcement-storage';
|
|
12
|
-
import type {
|
|
12
|
+
import type { AnnouncementBarProps, AnnouncementResponse } from '../types/announcement';
|
|
13
13
|
import { getAppType } from '../utils/app-config';
|
|
14
14
|
import { useEndpointsRuntime } from '../contexts/endpoints-runtime-context';
|
|
15
15
|
import { useSelfFetch } from '../hooks/use-self-fetch';
|
|
@@ -71,15 +71,6 @@ export function AnnouncementBar({
|
|
|
71
71
|
});
|
|
72
72
|
const announcement = data?.announcement ?? null;
|
|
73
73
|
|
|
74
|
-
// Hold the last non-null announcement so DEACTIVATION (a revalidation that
|
|
75
|
-
// returns null) collapses with the same 1fr->0fr animation as dismissal
|
|
76
|
-
// instead of unmounting in place (a hard 44px jump).
|
|
77
|
-
const lastAnnouncementRef = useRef<Announcement | null>(initialAnnouncement ?? null);
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (announcement) lastAnnouncementRef.current = announcement;
|
|
80
|
-
}, [announcement]);
|
|
81
|
-
const displayAnnouncement = announcement ?? lastAnnouncementRef.current;
|
|
82
|
-
|
|
83
74
|
// Expanded (height) state — initial value is a pure function of props so
|
|
84
75
|
// the SSR HTML and the hydration render agree for every cohort.
|
|
85
76
|
const [expandedState, setExpandedState] = useState<boolean>(() => initialAnnouncement != null);
|
|
@@ -118,10 +109,6 @@ export function AnnouncementBar({
|
|
|
118
109
|
const handleDismiss = () => {
|
|
119
110
|
if (previewMode || !announcement) return;
|
|
120
111
|
dismissAnnouncement(platform, announcement.id);
|
|
121
|
-
// Release focus BEFORE the wrapper goes aria-hidden — a focused descendant
|
|
122
|
-
// inside an aria-hidden subtree strands screen-reader focus (and Chrome
|
|
123
|
-
// refuses to apply the attribute).
|
|
124
|
-
(document.activeElement as HTMLElement | null)?.blur?.();
|
|
125
112
|
setExpandedState(false);
|
|
126
113
|
};
|
|
127
114
|
|
|
@@ -132,9 +119,7 @@ export function AnnouncementBar({
|
|
|
132
119
|
// via location.href / window.open (stored XSS).
|
|
133
120
|
let safeUrl: string;
|
|
134
121
|
try {
|
|
135
|
-
|
|
136
|
-
// fragment CTAs keep their pre-guard semantics.
|
|
137
|
-
const parsed = new URL(announcement.cta_url, window.location.href);
|
|
122
|
+
const parsed = new URL(announcement.cta_url, window.location.origin);
|
|
138
123
|
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return;
|
|
139
124
|
safeUrl = parsed.href;
|
|
140
125
|
} catch {
|
|
@@ -145,10 +130,10 @@ export function AnnouncementBar({
|
|
|
145
130
|
: (window.location.href = safeUrl);
|
|
146
131
|
};
|
|
147
132
|
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
if (!
|
|
133
|
+
// Nothing to show (and nothing to animate around): render nothing. The
|
|
134
|
+
// dismissed/deactivated case keeps the element mounted at 0fr so the
|
|
135
|
+
// collapse animates.
|
|
136
|
+
if (!announcement) return null;
|
|
152
137
|
|
|
153
138
|
// Contrast is solved with the ODS THEME system, not color literals: the
|
|
154
139
|
// admin background's tone selects which ODS theme scopes the bar's content
|
|
@@ -156,7 +141,7 @@ export function AnnouncementBar({
|
|
|
156
141
|
// dark-toned needs the dark theme's). `.theme-light` / `.theme-dark` are
|
|
157
142
|
// the design system's own scoping classes (ods-colors.css) and flip every
|
|
158
143
|
// Tier-1 `--ods-*` primitive for descendants.
|
|
159
|
-
const themeScope = pickReadableTextColor(
|
|
144
|
+
const themeScope = pickReadableTextColor(announcement.background_color) === 'dark' ? 'theme-light' : 'theme-dark';
|
|
160
145
|
|
|
161
146
|
// Inside the scope, colors reference Tier-1 theme primitives directly
|
|
162
147
|
// (Tier-2 `--color-*` aliases resolve once at :root and do NOT re-resolve
|
|
@@ -167,7 +152,7 @@ export function AnnouncementBar({
|
|
|
167
152
|
const barButtonClasses =
|
|
168
153
|
'text-[color:var(--ods-system-greys-white)] hover:bg-[var(--ods-system-greys-black-hover)] active:bg-[var(--ods-system-greys-black-action)]';
|
|
169
154
|
|
|
170
|
-
const hasCta = Boolean(
|
|
155
|
+
const hasCta = Boolean(announcement.cta_enabled && announcement.cta_url);
|
|
171
156
|
|
|
172
157
|
return (
|
|
173
158
|
<div
|
|
@@ -186,11 +171,9 @@ export function AnnouncementBar({
|
|
|
186
171
|
compact CTA on the right, and a ghost-icon dismiss (design-system
|
|
187
172
|
icon-sm: 32px target, >= the 24px WCAG 2.2 SC 2.5.8 AA floor).
|
|
188
173
|
*/}
|
|
189
|
-
<div className={`min-h-0 overflow-hidden ${themeScope}`} style={{ backgroundColor:
|
|
174
|
+
<div className={`min-h-0 overflow-hidden ${themeScope}`} style={{ backgroundColor: announcement.background_color }}>
|
|
190
175
|
<div className="flex items-center w-full max-w-full min-h-11 text-[color:var(--ods-system-greys-white)]">
|
|
191
|
-
{/* Mobile:
|
|
192
|
-
Button below is the keyboard/AT path and is CSS-hidden < md —
|
|
193
|
-
known tradeoff carried from the original bar). */}
|
|
176
|
+
{/* Mobile: Clickable content area, Desktop: Regular content */}
|
|
194
177
|
<div
|
|
195
178
|
className={`flex flex-row gap-2 md:gap-3 items-center pl-4 md:pl-6 py-1.5 flex-1 min-w-0 ${
|
|
196
179
|
hasCta ? 'md:cursor-default cursor-pointer' : ''
|
|
@@ -207,9 +190,9 @@ export function AnnouncementBar({
|
|
|
207
190
|
wins, else a library glyph by name (+ props), via <EntityIcon>. */}
|
|
208
191
|
<EntityIcon
|
|
209
192
|
icon={{
|
|
210
|
-
name:
|
|
211
|
-
url:
|
|
212
|
-
props:
|
|
193
|
+
name: announcement.icon_name || 'openframe-logo',
|
|
194
|
+
url: announcement.icon_url,
|
|
195
|
+
props: announcement.icon_props,
|
|
213
196
|
}}
|
|
214
197
|
size={24}
|
|
215
198
|
className="relative shrink-0 w-5 h-5 md:w-6 md:h-6"
|
|
@@ -219,9 +202,9 @@ export function AnnouncementBar({
|
|
|
219
202
|
truncating as one unit. Separator is a middot (house rule: no
|
|
220
203
|
en/em dashes in copy). */}
|
|
221
204
|
<p className="font-body flex-1 min-w-0 max-w-full text-[13px] md:text-sm leading-snug truncate mb-0">
|
|
222
|
-
<span className="font-semibold">{
|
|
223
|
-
{
|
|
224
|
-
<span className="hidden sm:inline opacity-80"> · {
|
|
205
|
+
<span className="font-semibold">{announcement.title}</span>
|
|
206
|
+
{announcement.description && (
|
|
207
|
+
<span className="hidden sm:inline opacity-80"> · {announcement.description}</span>
|
|
225
208
|
)}
|
|
226
209
|
</p>
|
|
227
210
|
|
|
@@ -231,7 +214,7 @@ export function AnnouncementBar({
|
|
|
231
214
|
admin color. The admin cta_button_* colors are NOT applied:
|
|
232
215
|
they were designed for the legacy bespoke treatment. Hidden
|
|
233
216
|
on mobile, where the whole bar is the tap target. */}
|
|
234
|
-
{hasCta &&
|
|
217
|
+
{hasCta && announcement.cta_text && (
|
|
235
218
|
<div className="hidden md:flex flex-shrink-0 ml-1">
|
|
236
219
|
<Button
|
|
237
220
|
onClick={handleCtaClick}
|
|
@@ -240,10 +223,10 @@ export function AnnouncementBar({
|
|
|
240
223
|
className={barButtonClasses}
|
|
241
224
|
tabIndex={expanded ? 0 : -1}
|
|
242
225
|
leftIcon={
|
|
243
|
-
|
|
226
|
+
announcement.cta_show_icon && announcement.cta_icon_name
|
|
244
227
|
? (
|
|
245
228
|
<EntityIcon
|
|
246
|
-
icon={{ name:
|
|
229
|
+
icon={{ name: announcement.cta_icon_name, props: announcement.cta_icon_props }}
|
|
247
230
|
size={14}
|
|
248
231
|
className="w-3.5 h-3.5"
|
|
249
232
|
/>
|
|
@@ -251,7 +234,7 @@ export function AnnouncementBar({
|
|
|
251
234
|
: undefined
|
|
252
235
|
}
|
|
253
236
|
>
|
|
254
|
-
{
|
|
237
|
+
{announcement.cta_text}
|
|
255
238
|
</Button>
|
|
256
239
|
</div>
|
|
257
240
|
)}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
import { createContext, useContext } from 'react'
|
|
25
25
|
|
|
26
26
|
export interface EndpointsRuntime {
|
|
27
|
-
/** GET active announcement (used by `<AnnouncementBar>`
|
|
27
|
+
/** GET active announcement (used by `<AnnouncementBar>` polling). */
|
|
28
28
|
announcementsUrl: string
|
|
29
29
|
accessCode: {
|
|
30
30
|
/** POST validate access code. */
|
|
@@ -112,13 +112,6 @@ export function useSelfFetch<T>(
|
|
|
112
112
|
// `url` folds in every query param; `reloadKey` drives retry.
|
|
113
113
|
}, [url, reloadKey])
|
|
114
114
|
|
|
115
|
-
// ONE force-refetch mechanic shared by reload() and the visibility
|
|
116
|
-
// revalidation: clear the held-url skip, bump the effect key.
|
|
117
|
-
const forceReload = () => {
|
|
118
|
-
dataUrlRef.current = null
|
|
119
|
-
setReloadKey((k) => k + 1)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
115
|
// Opt-in visibility-driven revalidation. Registered only when the option is
|
|
123
116
|
// set and fetching is enabled; SSR-safe (effects don't run on the server)
|
|
124
117
|
// and StrictMode-safe (idempotent listener, cleaned up per mount cycle).
|
|
@@ -127,7 +120,9 @@ export function useSelfFetch<T>(
|
|
|
127
120
|
const onVisible = () => {
|
|
128
121
|
if (document.visibilityState !== 'visible') return
|
|
129
122
|
if (Date.now() - dataAtRef.current < revalidateOnVisibleAfterMs) return
|
|
130
|
-
|
|
123
|
+
// Same mechanics as reload(): clear the held-url skip, bump the key.
|
|
124
|
+
dataUrlRef.current = null
|
|
125
|
+
setReloadKey((k) => k + 1)
|
|
131
126
|
}
|
|
132
127
|
document.addEventListener('visibilitychange', onVisible)
|
|
133
128
|
return () => document.removeEventListener('visibilitychange', onVisible)
|
|
@@ -138,7 +133,11 @@ export function useSelfFetch<T>(
|
|
|
138
133
|
setData,
|
|
139
134
|
isLoading,
|
|
140
135
|
error,
|
|
141
|
-
// Force a re-fetch of the current url
|
|
142
|
-
|
|
136
|
+
// Force a re-fetch of the current url: clear the held-url ref so the skip above
|
|
137
|
+
// doesn't short-circuit, then bump the effect key.
|
|
138
|
+
reload: () => {
|
|
139
|
+
dataUrlRef.current = null
|
|
140
|
+
setReloadKey((k) => k + 1)
|
|
141
|
+
},
|
|
143
142
|
}
|
|
144
143
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/nextjs-vite'
|
|
2
2
|
import type { Announcement } from '../types/announcement'
|
|
3
3
|
import { AnnouncementBar } from '../components/announcement-bar'
|
|
4
|
-
import {
|
|
4
|
+
import { announcementDismissCookieName } from '../utils/announcement-storage'
|
|
5
5
|
import { getAppType } from '../utils/app-config'
|
|
6
6
|
import { EndpointsRuntimeContext, type EndpointsRuntime } from '../contexts/endpoints-runtime-context'
|
|
7
7
|
|
|
@@ -12,7 +12,13 @@ import { EndpointsRuntimeContext, type EndpointsRuntime } from '../contexts/endp
|
|
|
12
12
|
* by a previous interaction so every story starts visible.
|
|
13
13
|
*/
|
|
14
14
|
function clearDismissals() {
|
|
15
|
-
|
|
15
|
+
const platform = getAppType()
|
|
16
|
+
document.cookie = `${announcementDismissCookieName(platform)}=; path=/; max-age=0`
|
|
17
|
+
Object.keys(localStorage).forEach((key) => {
|
|
18
|
+
if (key.includes('-announcement-') && key.endsWith('-dismissed')) {
|
|
19
|
+
localStorage.removeItem(key)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
const now = new Date().toISOString()
|
|
@@ -104,7 +110,7 @@ export const WithCTASameTab: Story = {
|
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
/**
|
|
107
|
-
* Dark background
|
|
113
|
+
* Dark background — text flips to the light shade via pickReadableTextColor.
|
|
108
114
|
*/
|
|
109
115
|
export const DarkBackground: Story = {
|
|
110
116
|
args: {
|
|
@@ -211,7 +217,7 @@ export const LongContent: Story = {
|
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
/**
|
|
214
|
-
* previewMode
|
|
220
|
+
* previewMode — the admin live-preview path: render-only, inert dismiss,
|
|
215
221
|
* no fetch and no storage side effects.
|
|
216
222
|
*/
|
|
217
223
|
export const PreviewMode: Story = {
|
|
@@ -227,7 +233,7 @@ export const PreviewMode: Story = {
|
|
|
227
233
|
}
|
|
228
234
|
|
|
229
235
|
/**
|
|
230
|
-
* No active announcement
|
|
236
|
+
* No active announcement — the bar renders nothing.
|
|
231
237
|
*/
|
|
232
238
|
export const NoAnnouncement: Story = {
|
|
233
239
|
args: { initialAnnouncement: null },
|
|
@@ -235,8 +241,8 @@ export const NoAnnouncement: Story = {
|
|
|
235
241
|
(Story) => (
|
|
236
242
|
<div>
|
|
237
243
|
<Story />
|
|
238
|
-
<p className="p-4 text-sm text-
|
|
239
|
-
No announcement is active
|
|
244
|
+
<p className="p-4 text-sm text-gray-500">
|
|
245
|
+
No announcement is active — the bar renders nothing above this text.
|
|
240
246
|
</p>
|
|
241
247
|
</div>
|
|
242
248
|
),
|
|
@@ -244,7 +250,7 @@ export const NoAnnouncement: Story = {
|
|
|
244
250
|
}
|
|
245
251
|
|
|
246
252
|
/**
|
|
247
|
-
* Client-only mode (no SSR)
|
|
253
|
+
* Client-only mode (no SSR) — the react-embedding-example structure: the
|
|
248
254
|
* embedder mounts an EndpointsRuntime provider (announcementsUrl is a fixed
|
|
249
255
|
* suffix under its one content base) and drops in a PROP-LESS bar. No
|
|
250
256
|
* platform knob anywhere on the client: the proxied server resolves its own
|
|
@@ -220,6 +220,14 @@ export interface AnnouncementValidation {
|
|
|
220
220
|
// Import unified platform configuration (removed duplicate definition)
|
|
221
221
|
export type { PlatformConfig } from './platform';
|
|
222
222
|
|
|
223
|
+
// Admin Dashboard Types
|
|
224
|
+
export interface AnnouncementStats {
|
|
225
|
+
total_announcements: number;
|
|
226
|
+
active_announcements: number;
|
|
227
|
+
announcements_by_platform: Record<LegacyPlatform, number>;
|
|
228
|
+
recent_announcements: Announcement[];
|
|
229
|
+
}
|
|
230
|
+
|
|
223
231
|
// Component Props Types
|
|
224
232
|
export interface AnnouncementBarProps {
|
|
225
233
|
/**
|
|
@@ -70,23 +70,6 @@ export function isAnnouncementDismissed(platform: string, id: string): boolean {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/** Remove ALL dismissal state for a platform (cookie + legacy localStorage
|
|
74
|
-
* keys) — test/story helper so callers never restate the key encoding. */
|
|
75
|
-
export function clearAnnouncementDismissals(platform: string): void {
|
|
76
|
-
if (typeof document === 'undefined') return
|
|
77
|
-
document.cookie = `${announcementDismissCookieName(platform)}=; path=/; max-age=0`
|
|
78
|
-
try {
|
|
79
|
-
const prefix = `${platform}-announcement-`
|
|
80
|
-
Object.keys(localStorage).forEach((key) => {
|
|
81
|
-
if (key.startsWith(prefix) && key.endsWith('-dismissed')) {
|
|
82
|
-
localStorage.removeItem(key)
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
} catch {
|
|
86
|
-
// ignore storage errors
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
73
|
/** One-time cleanup of pre-refactor storage: the orphaned announcement cache
|
|
91
74
|
* (the old "instant paint" blob) — called from the bar's mount effect. */
|
|
92
75
|
export function clearLegacyAnnouncementCache(platform: string): void {
|
package/src/utils/app-config.ts
CHANGED
|
@@ -19,9 +19,8 @@ export function getAppType() {
|
|
|
19
19
|
// The exact `process.env.NEXT_PUBLIC_APP_TYPE` member expression is kept so
|
|
20
20
|
// Next/webpack can statically inline it. The try/catch makes the call safe
|
|
21
21
|
// in non-Next React hosts (Vite/CRA embeds) where `process` does not exist
|
|
22
|
-
// at runtime — those hosts
|
|
23
|
-
//
|
|
24
|
-
// one platform's announcements.
|
|
22
|
+
// at runtime — those hosts fall back to 'openmsp' or pass an explicit
|
|
23
|
+
// platform where it matters (e.g. AnnouncementBar's `platform` prop).
|
|
25
24
|
try {
|
|
26
25
|
return process.env.NEXT_PUBLIC_APP_TYPE || 'openmsp';
|
|
27
26
|
} catch {
|
|
@@ -17,10 +17,7 @@ export const DESIGN_PALETTE: ColorPalette[] = [
|
|
|
17
17
|
* Convert hex color to RGB
|
|
18
18
|
*/
|
|
19
19
|
export function hexToRgb(hex: string): [number, number, number] {
|
|
20
|
-
|
|
21
|
-
// by their real color instead of falling through to black.
|
|
22
|
-
const normalized = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (_, r, g, b) => `${r}${r}${g}${g}${b}${b}`);
|
|
23
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(normalized);
|
|
20
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
24
21
|
return result
|
|
25
22
|
? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)]
|
|
26
23
|
: [0, 0, 0];
|
|
@@ -29,7 +26,7 @@ export function hexToRgb(hex: string): [number, number, number] {
|
|
|
29
26
|
/**
|
|
30
27
|
* Calculate relative luminance for contrast calculations
|
|
31
28
|
*/
|
|
32
|
-
function getLuminance(rgb: [number, number, number]): number {
|
|
29
|
+
export function getLuminance(rgb: [number, number, number]): number {
|
|
33
30
|
const [r, g, b] = rgb.map(c => {
|
|
34
31
|
c = c / 255;
|
|
35
32
|
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Provides runtime utilities for working with ODS color tokens
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { pickReadableTextColor } from './color-analysis';
|
|
8
7
|
import { colorTokens as odsTokens } from './ods-color-tokens-stub';
|
|
9
8
|
|
|
10
9
|
export type Platform = 'openmsp' | 'openframe' | 'flamingo';
|
|
@@ -293,11 +292,15 @@ export function usePlatformColors(platform?: Platform) {
|
|
|
293
292
|
|
|
294
293
|
/**
|
|
295
294
|
* Picks a near-black or near-white text color with adequate contrast on `hex`.
|
|
296
|
-
*
|
|
297
|
-
* light-or-dark decision formula (WCAG relative luminance) for the whole lib.
|
|
295
|
+
* Uses Rec. 601 luminance.
|
|
298
296
|
*/
|
|
299
297
|
export function getReadableTextColor(hex: string): string {
|
|
300
|
-
|
|
298
|
+
const n = parseInt(hex.replace('#', ''), 16)
|
|
299
|
+
const r = (n >> 16) & 0xff
|
|
300
|
+
const g = (n >> 8) & 0xff
|
|
301
|
+
const b = n & 0xff
|
|
302
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
|
|
303
|
+
return luminance > 0.5 ? '#212121' : '#fafafa'
|
|
301
304
|
}
|
|
302
305
|
|
|
303
306
|
// Hex <-> RGB <-> HSL. Hex is #rrggbb lowercase; hexToRgb returns null on invalid.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-2B6773QM.cjs","../src/contexts/endpoints-runtime-context.tsx","../src/contexts/chat-runtime-context.tsx"],"names":["createContext","useContext"],"mappings":"AAAA,qFAAY;AACZ;AACA;ACqBA,8BAA0C;AAenC,IAAM,wBAAA,EAA0B,kCAAA,IAA2C,CAAA;AAO3E,SAAS,mBAAA,CAAA,EAA+C;AAC7D,EAAA,OAAO,+BAAA,uBAAkC,CAAA;AAC3C;AASO,SAAS,2BAAA,CAAA,EAAgD;AAC9D,EAAA,MAAM,EAAA,EAAI,+BAAA,uBAAkC,CAAA;AAC5C,EAAA,GAAA,CAAI,CAAC,CAAA,EAAG;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,IAIF,CAAA;AAAA,EACF;AACA,EAAA,OAAO,CAAA;AACT;ADlDA;AACA;AEiBA;AA0MO,IAAM,mBAAA,EAAqBA,kCAAAA,IAAsC,CAAA;AAQjE,SAAS,cAAA,CAAA,EAAqC;AACnD,EAAA,OAAOC,+BAAAA,kBAA6B,CAAA;AACtC;AAUO,SAAS,sBAAA,CAAA,EAAsC;AACpD,EAAA,MAAM,EAAA,EAAIA,+BAAAA,kBAA6B,CAAA;AACvC,EAAA,GAAA,CAAI,CAAC,CAAA,EAAG;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,IAMF,CAAA;AAAA,EACF;AACA,EAAA,OAAO,CAAA;AACT;AF7OA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,mUAAC","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-2B6773QM.cjs","sourcesContent":[null,"'use client'\n\n/**\n * Endpoints runtime — sibling of ChatRuntime. Carries the API path\n * literals consumed by oss-lib components/hooks/utils so a host\n * application can override them (e.g. when running behind a reverse\n * proxy as `user1.openframe.ai` → `/api/mingo-guide/*`).\n *\n * The hub mounts `<HubRuntimeProvider>` at root with the\n * canonical hub paths; an embedded app mounts its own provider with\n * remapped paths. The pattern mirrors ChatRuntimeContext exactly:\n *\n * - `useEndpointsRuntime()` returns null when no provider is mounted.\n * For optional consumers that should gracefully no-op without one.\n * - `useRequiredEndpointsRuntime()` throws on missing provider — for\n * hooks/components that cannot function without endpoints.\n *\n * IMPORTANT for embedders: memoize the value passed to\n * `<EndpointsRuntimeContext.Provider value={...}>` (e.g. React.useMemo).\n * Reference changes invalidate downstream effect dependency arrays and\n * trigger unnecessary re-fetches.\n */\n\nimport { createContext, useContext } from 'react'\n\nexport interface EndpointsRuntime {\n /** GET active announcement (used by `<AnnouncementBar>` mount fetch + refocus revalidation). */\n announcementsUrl: string\n accessCode: {\n /** POST validate access code. */\n validateUrl: string\n /** POST consume / redeem access code after registration. */\n consumeUrl: string\n }\n /** POST contact-form submission. */\n contactUrl: string\n}\n\nexport const EndpointsRuntimeContext = createContext<EndpointsRuntime | null>(null)\n\n/**\n * Optional read — returns null when no provider is mounted. Use for\n * surfaces that should silently skip the fetch (e.g. announcement\n * polling on a page rendered outside the provider tree).\n */\nexport function useEndpointsRuntime(): EndpointsRuntime | null {\n return useContext(EndpointsRuntimeContext)\n}\n\n/**\n * Strict variant — throws on missing provider. Use for consumers that\n * cannot function without an endpoint (form submission, code\n * validation). In tests/Storybook, wrap with the hub's\n * `<HubRuntimeProvider>` or a stub\n * `<EndpointsRuntimeContext.Provider value={mockedEndpoints}>`.\n */\nexport function useRequiredEndpointsRuntime(): EndpointsRuntime {\n const v = useContext(EndpointsRuntimeContext)\n if (!v) {\n throw new Error(\n '[endpoints-runtime] hook called outside an <EndpointsRuntimeContext.Provider>. ' +\n 'Hub: mount <HubRuntimeProvider> in your providers tree. ' +\n 'Embedded app: mount your own provider with proxied URLs at the tree root. ' +\n 'Tests/Storybook: wrap render() in <EndpointsRuntimeContext.Provider value={mocked}>.',\n )\n }\n return v\n}\n","'use client'\n\n/**\n * Chat runtime context — single seam for embedding the chat panel in a\n * different host (e.g. user1.openframe.ai reverse-proxying API calls\n * under /api/mingo-guide/* to hub.openframe.ai/api/*).\n *\n * Three concerns, one context:\n * 1. API endpoints: chatStreamUrl / approvalToolUrl / commandsUrl /\n * buildListUrl + attachment endpoints + chat-identity. The chat\n * reads them from runtime; hub vs embedded app supply different\n * strings via different providers.\n * 2. Navigation mode + callbacks: 'host' or 'embed' mode. Host wires\n * its own router/docNav via the optional `navigate` callback\n * (plain function, NOT a hook); embed forces new-tab via\n * `defaultContentOrigin` + lib's `resolveExternalNavigation`.\n * 3. Identity context: only `source` (required for localStorage\n * namespacing). The display identity (greeting first-name etc.)\n * comes from the server via `useChatIdentity()` — never injected\n * client-side, so it always matches the server-resolved auth.\n *\n * Sibling of EndpointsRuntimeContext (announcement bar, contact form,\n * access codes). Each runtime stays an independent React context so\n * embedders can opt into either feature without forcing the other.\n *\n * IMPORTANT for embedders: memoize the value passed to\n * `<ChatRuntimeContext.Provider value={...}>` (e.g. via React.useMemo).\n * Every change to its reference identity invalidates downstream\n * `useMemo` consumers (the chat input's slash-commands binding,\n * useNavLink's embed-resolution memo, useDocChat's streamFn factory).\n * The hub's `<HubRuntimeProvider>` already memoizes correctly with\n * stable deps. Embedded apps that build the value inline on each render\n * will pay an avoidable re-render cost across the entire chat tree.\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\n\nimport type { ComposeContentUrl } from '../utils/content-href'\n\n/**\n * Runtime config consumed by the chat panel.\n */\nexport interface ChatRuntime {\n endpoints: {\n /** POST streaming chat. Hub: '/api/docs/chat'. */\n chatStreamUrl: string\n /** POST agent approve/reject. Hub: '/api/chat/agent/confirm-tool'. */\n approvalToolUrl: string\n /** Customer-ticket agent endpoints (Help Center). OPTIONAL — when unset,\n * the ticket hooks fall back to the bare hub paths\n * (`/api/chat/agent/{find-ticket,ticket-action,list-engagements}`).\n * Embedders behind a reverse proxy set these to their proxied paths\n * (e.g. `/content/api/chat/agent/...`) so tickets route through the SAME\n * endpoint config + proxy as every other endpoint. */\n findTicketUrl?: string\n ticketActionUrl?: string\n listEngagementsUrl?: string\n /** GET slash-command catalog. Hub: '/api/docs/commands'. */\n commandsUrl: string\n /** GET RAG-search endpoint behind `<DocSearchBar>` (the in-source search\n * bar mounted by `<DocViewer>` / `<DocsHubPage>` when `showAIChat` is on).\n * Hub: '/api/docs/search'. OPTIONAL — falls back to the hub path so\n * same-origin Next.js hosts don't need to set it. Cross-origin embedders\n * set their proxied path so the search bar routes through the same\n * reverse proxy as everything else. Same pattern as `findTicketUrl`. */\n docsSearchUrl?: string\n /** POST internal-link resolver. The in-source markdown renderer (lib or\n * custom) calls `<DocViewer>`'s `handlers.onResolveLink(href, currentPath)`\n * for relative hrefs like `./getting-started/intro.md` — that callback\n * posts to this URL with `{ link, currentPath, source }` and expects a\n * `ResolveLinkResult` back. Hub: '/api/docs/resolve-link'. OPTIONAL — same\n * fall-back chain as `docsSearchUrl`: prop override → runtime → default. */\n docsResolveLinkUrl?: string\n /** GET per-platform empty-state config (admin-edited in\n * `/admin/chat-config`): `{ greeting, enabledRagTableIds, suggestedQueries }`.\n * Hub: '/api/docs/empty-state'. OPTIONAL — the in-app (host-mode) chat\n * injects these values as SSR props instead, so it leaves this unset.\n * Cross-origin EMBEDDERS (no server hop) set it to their proxied path\n * (e.g. '/content/api/docs/empty-state') so `<EmbeddableChat>` can fetch\n * the greeting / quick-action chips / RAG-source filter at runtime. When\n * unset, the chat falls back to the explicit `emptyStateGreeting` /\n * `suggestedQueries` / `enabledRagTableIds` props (or in-code defaults). */\n emptyStateUrl?: string\n /** Build the per-agent display-config URL for an OpenFrame AI agent\n * (Fae/Mingo). OPTIONAL. The returned endpoint MUST be byte-compatible\n * with the empty-state wire shape ({ greeting, suggestedQueries,\n * enabledRagTableIds }). When set AND `EmbeddableChat` receives an\n * `activeAgentSlug` in embed mode, the chat fetches THIS url instead of\n * `emptyStateUrl` to render the selected agent's greeting + suggested\n * prompts (the \"agent mode\" URL override). Hub: `(slug) =>\n * '/api/ai-agents/' + encodeURIComponent(slug)`. */\n aiAgentConfigUrl?: (slug: string) => string\n /** Build entity-card list URL for a content type + ids. Hub delegates\n * to the rag-table-config registry; embedded app provides its own\n * per-type URL builder against the reverse proxy. Returns null when\n * the type has no list endpoint (caller skips rendering). */\n buildListUrl: (type: string, ids: string[]) => string | null\n /** Chat-attachment endpoints — added for the v2 attachment feature.\n *\n * Three concerns:\n * - `attachmentUploadUrl` — POSTed by the chat-attachment hook\n * to mint a Supabase signed-upload-URL + HMAC view token.\n * - `attachmentViewUrlPrefix` — embedded in markdown URLs the\n * chat hosts in user message bubbles (`![]()` / `[Attached]`).\n * Stored in chat history; chosen at SEND time. In host mode the\n * relative `/api/storage/view/chat-attachments/` is sufficient\n * (same-origin); embedders supply an absolute hub URL so the\n * browser can fetch cross-origin.\n * - `identityUrl` — GET endpoint the `useChatIdentity` hook\n * hits to learn the `{authTier, source, attachmentsEnabled}`\n * capability bag for the current session. Used beyond chat\n * (tickets / contact form / any embedded surface that needs\n * to identify the proxied customer), so the name has no\n * \"chat\" prefix even though the consuming hook still does. */\n attachmentUploadUrl: string\n attachmentViewUrlPrefix: string\n identityUrl: string\n /** Optional URL prefix for the image proxy (`<prefix>?url=<external>`).\n * When unset, lib's `getProxiedImageUrl` returns the original URL\n * unchanged. Hub default: '/api/image-proxy'. Embedders that don't\n * host an image-proxy route leave this undefined → images load\n * directly cross-origin (CORS-permitting). */\n imageProxyUrlPrefix?: string\n /** Optional list of hostnames that should bypass the image proxy\n * (rendered direct). Hub uses ['openmsp.ai']; embedders typically\n * leave it unset. Matches the `skipDomains` parameter of\n * `getProxiedImageUrl`. */\n imageProxySkipDomains?: string[]\n /** Optional base URL for the branded og-placeholder image route — the\n * DEFAULT cover-image fallback for entity cards with no image. The lib\n * appends `?title=…` (+ `w`/`h` for square slots) itself, so this is\n * the base, NOT a full URL: relative (`/api/og-placeholder`) for same-\n * origin hosts, or the proxied path (`/content/api/og-placeholder`) for\n * cross-origin embedders. May carry baked-in query params (preserved when\n * the lib layers `title`/dimensions on top) — but per-platform brand\n * colors are NO LONGER baked here; the `/api/og-placeholder` route\n * resolves them server-side from the platform. Most hosts leave this unset\n * and let the lib derive the base from `imageProxyUrlPrefix`.\n *\n * OPTIONAL — when unset the lib derives the base from the sibling\n * `imageProxyUrlPrefix` (same API base, route name swapped), then falls\n * back to the relative `/api/og-placeholder`. So an embedder that already\n * proxies images needs NO og-placeholder wiring. See\n * `resolveOgPlaceholderBase` / `buildOgPlaceholderUrl` in `../utils`. */\n ogPlaceholderUrl?: string\n /** Supabase storage origin (e.g. `https://xyz.supabase.co`) — used\n * by `useVideoWarmup` to scope the `<link rel=\"preload\" as=\"video\">`\n * hint to MP4s the deployment actually hosts. Hub wires it via\n * `getSupabaseStorageOrigin()`; embedders without a Supabase\n * storage origin leave it unset (preload is then skipped; Mux/\n * YouTube preconnect still fires). */\n supabaseStorageOrigin?: string\n }\n navigation: {\n /** ONE knob, two behaviors:\n * - 'host' = use the host page's existing click-routing untouched.\n * The chat panel calls `navigate?.()` for in-app routing.\n * - 'embed' = guest inside another app: short-circuit at the top\n * of click handlers to force new-tab + absolutize via\n * resolveExternalNavigation. */\n mode: 'host' | 'embed'\n /** Embed-only fallback origin for relative URLs whose target platform\n * can't be inferred. Used by resolveExternalNavigation when\n * `targetPlatform` is null — without this, a relative `/foo` href would\n * window.open against the embedder's origin, which is WRONG.\n * Set to your content host (e.g. 'https://hub.openframe.ai').\n * Required by the embedded app whenever mode='embed'. */\n defaultContentOrigin?: string\n /** Override for opening external URLs. MUST BE SYNCHRONOUS —\n * Safari/Firefox block popups opened outside a direct user gesture.\n * Default: window.open(href, '_blank', 'noopener,noreferrer'). */\n openExternal?: (href: string) => void\n /** Optional in-app navigation callback (host-mode only).\n * Returns `true` if the host handled the click in-app\n * (router.push + docNav.navigate); returns `false`, `undefined`,\n * or `void` → lib falls back to window.location.assign(href).\n * Hub wires this via HubRuntimeProvider's HubNavigationWiring;\n * embedders not in Next.js leave it undefined. */\n navigate?: (input: { href: string; path?: string | null; targetPlatform?: string | null }) => boolean | void\n /** Optional new-tab decision callback. Returns true → lib opens in\n * new tab; false → same tab via `navigate`. Hub wires the existing\n * `decideNewTab` logic from use-nav-link.tsx (re-imports the pure\n * helper from lib). Embedders may omit; lib defaults to:\n * same-origin/same-platform → same tab, else new tab. */\n decideNewTab?: (args: { href: string; targetPlatform?: string | null }) => boolean\n }\n /** Optional content-URL composer. Returns the platform-aware href +\n * target-platform tuple for a content entity. Hub wires this to its\n * `buildContentURL(type, slug, extractPrimaryPlatform(platforms))`\n * pipeline so the lib catalog/detail views can derive cross-\n * platform hrefs without knowing the hub's platform topology\n * (openmsp.ai / openframe.app / flamingo.run / tmcg).\n *\n * THE single content-href authority for every embeddable surface — page\n * views (onboarding catalog/detail, releases) AND chat cards / chips /\n * search results all resolve content links through this one seam, so a\n * given type lands in the SAME place regardless of where it's rendered.\n * Embedders wire `makeComposeContentUrl({ hostedTypes, contentOrigin })`;\n * omit it and lib views fall back to a same-origin relative path\n * (`buildDefaultHref`).\n *\n * Takes a single `ComposeContentUrlInput`: `type` + `identifier` (page\n * views pass the slug; chat rows pass the id + `externalUrl`, whose path\n * yields the slug for in-app routing) + optional `platforms` /\n * `externalUrl` / `targetPlatform`. */\n composeContentUrl?: ComposeContentUrl\n /** Per-`documentType` doc-viewer targets — the UNIFIED, DYNAMIC replacement for\n * the single `chipBasePlatform` prop. Maps a doc-table documentType\n * (`'markdown'`, `'data_room_doc'`, …) → `{ platform, basePath }` for the PUBLIC\n * doc viewer that hosts it. Doc chips with no `externalUrl` resolve PER ROW to\n * `getBaseUrl(platform)/<basePath>/<path>`, so a chat mixing several doc sources\n * sends EACH to its own home (markdown→flamingo/knowledge-base,\n * data_room_doc→company-hub/data-room) instead of one static fallback. The hub\n * may keep using `chipBasePlatform` (one doc source per platform); embedders that\n * surface multiple doc sources wire this. Threaded into `resolveSourceRowCTA`. */\n docPlatformTargets?: Record<string, { platform: string; basePath: string }>\n /** Chat source / platform identifier — OPTIONAL. The hub sets it from\n * `currentPlatform()`; EMBEDDERS leave it unset and stay platform-agnostic.\n *\n * It is NOT required for chat to work. The wire resolves source server-side\n * (`/docs/chat|search|commands` reject any client `source`); the\n * same-tab-vs-new-tab link decision falls back to an origin comparison when\n * it's absent (`decideNewTab` → `isCrossOriginUrl`); and the localStorage\n * history namespace falls back to a stable constant. Set it only where the\n * client legitimately needs to know its platform a priori — i.e. the hub,\n * where several platforms share related origins so \"same platform\" can't be\n * inferred from a URL alone. */\n source?: string\n // NOTE: No `user` field. The chat's display identity (greeting\n // first-name, etc.) comes from the SERVER-resolved auth via\n // `useChatIdentity()` — the same identity the server uses to\n // authorize requests. Letting embedders pass a client-side `user`\n // would let it desync from the actual auth tier, causing greetings\n // like \"Hey Bob\" while the server treats the session as\n // alice@example.com. Single source of truth: the server.\n}\n\nexport const ChatRuntimeContext = createContext<ChatRuntime | null>(null)\n\n/**\n * Returns the active runtime, or null when no provider is mounted.\n * NULL is a first-class value — it signals \"no chat runtime configured.\"\n * Optional consumers fall back to no-op behavior; strict consumers\n * use `useRequiredChatRuntime` (below).\n */\nexport function useChatRuntime(): ChatRuntime | null {\n return useContext(ChatRuntimeContext)\n}\n\n/**\n * Strict variant used INSIDE the chat panel. Throws if no provider.\n * The hub guarantees one exists by mounting `<HubRuntimeProvider>` at\n * root; the embedded app mounts its own `<ChatRuntimeContext.Provider>`\n * at the tree root. In Jest / Storybook tests that render chat\n * internals directly, wrap with `<HubRuntimeProvider>` (hub defaults)\n * or supply `<ChatRuntimeContext.Provider value={mockedRuntime}>`.\n */\nexport function useRequiredChatRuntime(): ChatRuntime {\n const v = useContext(ChatRuntimeContext)\n if (!v) {\n throw new Error(\n '[chat-runtime] hook called outside a <ChatRuntimeContext.Provider>. ' +\n 'The hub mounts <HubRuntimeProvider> at root — this only fires when ' +\n 'chat internals are rendered above the provider tree. ' +\n 'Fix: ensure the rendering subtree descends from the runtime provider. ' +\n 'In tests/Storybook: wrap with <HubRuntimeProvider> or supply ' +\n 'a <ChatRuntimeContext.Provider value={mockedRuntime}>.',\n )\n }\n return v\n}\n"]}
|