@flamingo-stack/openframe-frontend-core 0.0.644 → 0.0.645-snapshot.20260917103313

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 (215) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-RFFF2EYD.cjs → chunk-2KE2M67P.cjs} +15 -15
  3. package/dist/{chunk-RFFF2EYD.cjs.map → chunk-2KE2M67P.cjs.map} +1 -1
  4. package/dist/{chunk-PFV4DAX5.js → chunk-2ZLCQSG4.js} +10 -10
  5. package/dist/{chunk-FOSIR4QF.js → chunk-3DWDJ54N.js} +5 -5
  6. package/dist/{chunk-YB6FI2G3.js → chunk-3SMLYVM2.js} +1 -1
  7. package/dist/{chunk-YB6FI2G3.js.map → chunk-3SMLYVM2.js.map} +1 -1
  8. package/dist/{chunk-4EEUB62O.js → chunk-4HVWGYHI.js} +2 -2
  9. package/dist/{chunk-27RD5XTP.js → chunk-4TLGU2FT.js} +5 -5
  10. package/dist/{chunk-G5U4JP45.js → chunk-5ONM3FHQ.js} +4 -4
  11. package/dist/{chunk-MRIOYSXH.js → chunk-63RIPFJ4.js} +5 -5
  12. package/dist/{chunk-GELNUDBT.cjs → chunk-77BLJHKI.cjs} +10 -10
  13. package/dist/{chunk-GELNUDBT.cjs.map → chunk-77BLJHKI.cjs.map} +1 -1
  14. package/dist/{chunk-KJWPAJRT.js → chunk-7EI3NES7.js} +3 -3
  15. package/dist/{chunk-DCCY54LU.cjs → chunk-7HHVE7DC.cjs} +14 -14
  16. package/dist/{chunk-DCCY54LU.cjs.map → chunk-7HHVE7DC.cjs.map} +1 -1
  17. package/dist/{chunk-CBXZSTAG.cjs → chunk-7UWJMWDH.cjs} +1004 -794
  18. package/dist/chunk-7UWJMWDH.cjs.map +1 -0
  19. package/dist/{chunk-3DGRXC74.js → chunk-CH5E4GXC.js} +5 -5
  20. package/dist/{chunk-VE52MSYC.js → chunk-CJMWRV65.js} +8 -8
  21. package/dist/{chunk-65EVGKFV.cjs → chunk-CSZBFSYT.cjs} +14 -14
  22. package/dist/{chunk-65EVGKFV.cjs.map → chunk-CSZBFSYT.cjs.map} +1 -1
  23. package/dist/{chunk-TTVOBWAH.js → chunk-D5PU7K2W.js} +5 -5
  24. package/dist/{chunk-3IXDZI3R.cjs → chunk-DOVVKQMZ.cjs} +3 -3
  25. package/dist/{chunk-3IXDZI3R.cjs.map → chunk-DOVVKQMZ.cjs.map} +1 -1
  26. package/dist/{chunk-I57XLISO.js → chunk-DULSS7R6.js} +226 -16
  27. package/dist/chunk-DULSS7R6.js.map +1 -0
  28. package/dist/{chunk-KOQCA5X5.cjs → chunk-DWJREJRA.cjs} +5 -5
  29. package/dist/{chunk-KOQCA5X5.cjs.map → chunk-DWJREJRA.cjs.map} +1 -1
  30. package/dist/{chunk-7R2DIGG4.cjs → chunk-EX5PJGVA.cjs} +76 -76
  31. package/dist/{chunk-7R2DIGG4.cjs.map → chunk-EX5PJGVA.cjs.map} +1 -1
  32. package/dist/{chunk-GBEUGDZG.cjs → chunk-F6U2H42L.cjs} +23 -23
  33. package/dist/{chunk-GBEUGDZG.cjs.map → chunk-F6U2H42L.cjs.map} +1 -1
  34. package/dist/{chunk-3UBT2OIX.cjs → chunk-FMG2YUBW.cjs} +74 -74
  35. package/dist/{chunk-3UBT2OIX.cjs.map → chunk-FMG2YUBW.cjs.map} +1 -1
  36. package/dist/{chunk-KEKN76JR.js → chunk-FRQ2DE5Z.js} +5 -5
  37. package/dist/{chunk-JOV64HW5.js → chunk-GRBZC5N3.js} +3 -3
  38. package/dist/{chunk-CHIHYC7Q.cjs → chunk-GSD62VAY.cjs} +21 -21
  39. package/dist/{chunk-CHIHYC7Q.cjs.map → chunk-GSD62VAY.cjs.map} +1 -1
  40. package/dist/{chunk-LPMDCQLL.js → chunk-H3EJDISW.js} +2 -2
  41. package/dist/{chunk-HPWLIYRL.js → chunk-HT4B4NGI.js} +14 -14
  42. package/dist/{chunk-KOLVBEW5.js → chunk-IWISVG4P.js} +3 -3
  43. package/dist/{chunk-MCQAOIUK.cjs → chunk-JEH4PXJG.cjs} +37 -37
  44. package/dist/{chunk-MCQAOIUK.cjs.map → chunk-JEH4PXJG.cjs.map} +1 -1
  45. package/dist/{chunk-GNKM6R55.cjs → chunk-JH5P72AF.cjs} +25 -25
  46. package/dist/{chunk-GNKM6R55.cjs.map → chunk-JH5P72AF.cjs.map} +1 -1
  47. package/dist/{chunk-HOGOQA2X.js → chunk-JNOPOJHH.js} +3 -3
  48. package/dist/{chunk-LCK7T2RM.cjs → chunk-JU6SBF3C.cjs} +13 -13
  49. package/dist/{chunk-LCK7T2RM.cjs.map → chunk-JU6SBF3C.cjs.map} +1 -1
  50. package/dist/{chunk-F2KBCLUG.js → chunk-KKSSA4CS.js} +2 -2
  51. package/dist/{chunk-IXD6SHQ6.js → chunk-KMI4VAS2.js} +6 -6
  52. package/dist/{chunk-IIXB5REN.cjs → chunk-KNMCYCY3.cjs} +16 -16
  53. package/dist/{chunk-IIXB5REN.cjs.map → chunk-KNMCYCY3.cjs.map} +1 -1
  54. package/dist/{chunk-RNMGKAS6.js → chunk-KPEBCJIH.js} +15 -15
  55. package/dist/{chunk-OMSUWB6A.cjs → chunk-LPMW5CNR.cjs} +118 -118
  56. package/dist/{chunk-OMSUWB6A.cjs.map → chunk-LPMW5CNR.cjs.map} +1 -1
  57. package/dist/{chunk-FKBM6U43.js → chunk-LZLT67PE.js} +2 -2
  58. package/dist/{chunk-B3Z3RJRW.js → chunk-M4AD2PHE.js} +5 -5
  59. package/dist/{chunk-BVQEU5JB.js → chunk-MT5A25AX.js} +2 -2
  60. package/dist/chunk-OXB6LRBK.js +20 -0
  61. package/dist/chunk-OXB6LRBK.js.map +1 -0
  62. package/dist/{chunk-OVXYX47B.cjs → chunk-PP6RACFB.cjs} +19 -19
  63. package/dist/{chunk-OVXYX47B.cjs.map → chunk-PP6RACFB.cjs.map} +1 -1
  64. package/dist/{chunk-S2KMNFFN.js → chunk-RJUXSUSM.js} +7 -7
  65. package/dist/{chunk-TGUA3C4U.cjs → chunk-RKN3TM24.cjs} +9 -9
  66. package/dist/{chunk-TGUA3C4U.cjs.map → chunk-RKN3TM24.cjs.map} +1 -1
  67. package/dist/{chunk-C5Y5T6GC.cjs → chunk-SBJ7BWYG.cjs} +20 -20
  68. package/dist/{chunk-C5Y5T6GC.cjs.map → chunk-SBJ7BWYG.cjs.map} +1 -1
  69. package/dist/{chunk-UKV52KAP.cjs → chunk-SIXBT6BA.cjs} +44 -44
  70. package/dist/{chunk-UKV52KAP.cjs.map → chunk-SIXBT6BA.cjs.map} +1 -1
  71. package/dist/{chunk-SKABQX44.js → chunk-SKA27VLR.js} +7 -7
  72. package/dist/{chunk-UPKZU6QU.cjs → chunk-U2YLMFJK.cjs} +1 -1
  73. package/dist/{chunk-UPKZU6QU.cjs.map → chunk-U2YLMFJK.cjs.map} +1 -1
  74. package/dist/{chunk-B5IFXCRF.cjs → chunk-VJOZGHTK.cjs} +41 -41
  75. package/dist/{chunk-B5IFXCRF.cjs.map → chunk-VJOZGHTK.cjs.map} +1 -1
  76. package/dist/{chunk-UEXIMEVU.js → chunk-VK7YKTAL.js} +10 -10
  77. package/dist/{chunk-CCWI3622.cjs → chunk-VTYP25OW.cjs} +4 -4
  78. package/dist/{chunk-CCWI3622.cjs.map → chunk-VTYP25OW.cjs.map} +1 -1
  79. package/dist/{chunk-4WVWRFGP.js → chunk-W2HZUFVB.js} +9 -9
  80. package/dist/{chunk-T3C3JLGV.cjs → chunk-WKX7DYFM.cjs} +8 -8
  81. package/dist/{chunk-T3C3JLGV.cjs.map → chunk-WKX7DYFM.cjs.map} +1 -1
  82. package/dist/{chunk-RB6L5EGM.cjs → chunk-X2YUAHNR.cjs} +1131 -1131
  83. package/dist/{chunk-RB6L5EGM.cjs.map → chunk-X2YUAHNR.cjs.map} +1 -1
  84. package/dist/{chunk-LZYPSDFE.cjs → chunk-X5OMIX5I.cjs} +90 -90
  85. package/dist/{chunk-LZYPSDFE.cjs.map → chunk-X5OMIX5I.cjs.map} +1 -1
  86. package/dist/chunk-X7CEWD6V.cjs +20 -0
  87. package/dist/chunk-X7CEWD6V.cjs.map +1 -0
  88. package/dist/{chunk-5JUTGEZE.js → chunk-XBTZOO74.js} +2 -2
  89. package/dist/{chunk-RWURXICE.cjs → chunk-XGD6SCHN.cjs} +44 -44
  90. package/dist/{chunk-RWURXICE.cjs.map → chunk-XGD6SCHN.cjs.map} +1 -1
  91. package/dist/{chunk-EHAYNUOL.cjs → chunk-XOGD2AME.cjs} +3 -3
  92. package/dist/{chunk-EHAYNUOL.cjs.map → chunk-XOGD2AME.cjs.map} +1 -1
  93. package/dist/{chunk-FAD5WURS.cjs → chunk-YR5S7VBA.cjs} +124 -124
  94. package/dist/{chunk-FAD5WURS.cjs.map → chunk-YR5S7VBA.cjs.map} +1 -1
  95. package/dist/{chunk-N6HNK25A.cjs → chunk-YWUZL3RT.cjs} +11 -11
  96. package/dist/{chunk-N6HNK25A.cjs.map → chunk-YWUZL3RT.cjs.map} +1 -1
  97. package/dist/{chunk-7Q5XXPCB.js → chunk-Z3HJFVYS.js} +14 -14
  98. package/dist/components/calendar.cjs +10 -10
  99. package/dist/components/calendar.js +2 -2
  100. package/dist/components/case-studies/index.cjs +30 -30
  101. package/dist/components/case-studies/index.js +14 -14
  102. package/dist/components/chat/embeddable-chat.d.ts +14 -1
  103. package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
  104. package/dist/components/chat/index.cjs +9 -9
  105. package/dist/components/chat/index.d.ts +1 -1
  106. package/dist/components/chat/index.d.ts.map +1 -1
  107. package/dist/components/chat/index.js +8 -8
  108. package/dist/components/chat/utils/source-row-cta.d.ts +1 -1
  109. package/dist/components/command.d.ts +7 -7
  110. package/dist/components/contact/index.cjs +15 -15
  111. package/dist/components/contact/index.js +14 -14
  112. package/dist/components/docs/index.cjs +18 -18
  113. package/dist/components/docs/index.js +17 -17
  114. package/dist/components/embeds/index.cjs +15 -15
  115. package/dist/components/embeds/index.js +14 -14
  116. package/dist/components/faq/index.cjs +16 -16
  117. package/dist/components/faq/index.js +15 -15
  118. package/dist/components/features/index.cjs +14 -14
  119. package/dist/components/features/index.js +13 -13
  120. package/dist/components/help-center-pages/index.cjs +37 -37
  121. package/dist/components/help-center-pages/index.js +28 -28
  122. package/dist/components/icons/index.cjs +3 -3
  123. package/dist/components/icons/index.js +2 -2
  124. package/dist/components/index.cjs +115 -115
  125. package/dist/components/index.cjs.map +1 -1
  126. package/dist/components/index.js +31 -31
  127. package/dist/components/index.js.map +1 -1
  128. package/dist/components/meeting-scheduler/index.cjs +119 -119
  129. package/dist/components/meeting-scheduler/index.js +15 -15
  130. package/dist/components/navigation/index.cjs +17 -17
  131. package/dist/components/navigation/index.js +16 -16
  132. package/dist/components/onboarding-guides/index.cjs +18 -18
  133. package/dist/components/onboarding-guides/index.js +17 -17
  134. package/dist/components/related-content/index.cjs +10 -10
  135. package/dist/components/related-content/index.js +9 -9
  136. package/dist/components/resizable.d.ts +1 -1
  137. package/dist/components/tickets/index.cjs +19 -19
  138. package/dist/components/tickets/index.js +18 -18
  139. package/dist/components/ui/file-manager/index.cjs +57 -57
  140. package/dist/components/ui/file-manager/index.js +4 -4
  141. package/dist/components/ui/index.cjs +14 -14
  142. package/dist/components/ui/index.js +13 -13
  143. package/dist/contexts/chat-runtime-context.d.ts +1 -1
  144. package/dist/contexts/index.cjs +2 -2
  145. package/dist/contexts/index.js +1 -1
  146. package/dist/hooks/index.cjs +7 -7
  147. package/dist/hooks/index.js +6 -6
  148. package/dist/index.cjs +36 -28
  149. package/dist/index.cjs.map +1 -1
  150. package/dist/index.js +30 -22
  151. package/dist/index.js.map +1 -1
  152. package/dist/platform-domains.cjs +43 -0
  153. package/dist/platform-domains.cjs.map +1 -1
  154. package/dist/platform-domains.d.ts +62 -4
  155. package/dist/platform-domains.d.ts.map +1 -1
  156. package/dist/platform-domains.js +39 -1
  157. package/dist/platform-domains.js.map +1 -1
  158. package/dist/types/index.cjs +0 -104
  159. package/dist/types/index.cjs.map +1 -1
  160. package/dist/types/index.js +0 -104
  161. package/dist/types/index.js.map +1 -1
  162. package/dist/utils/cn.d.ts +0 -21
  163. package/dist/utils/cn.d.ts.map +1 -1
  164. package/dist/utils/index.cjs +53 -25
  165. package/dist/utils/index.cjs.map +1 -1
  166. package/dist/utils/index.d.ts +1 -2
  167. package/dist/utils/index.d.ts.map +1 -1
  168. package/dist/utils/index.js +49 -25
  169. package/dist/utils/index.js.map +1 -1
  170. package/package.json +1 -1
  171. package/src/__tests__/platform-domains.test.ts +124 -0
  172. package/src/components/chat/embeddable-chat.tsx +65 -3
  173. package/src/components/chat/index.ts +6 -1
  174. package/src/components/chat/utils/__tests__/source-row-cta.test.ts +2 -2
  175. package/src/components/chat/utils/source-row-cta.ts +4 -4
  176. package/src/components/made-with-love.tsx +2 -2
  177. package/src/contexts/chat-runtime-context.tsx +1 -1
  178. package/src/platform-domains.ts +99 -4
  179. package/src/utils/.cn.md +3 -23
  180. package/src/utils/cn.ts +0 -47
  181. package/src/utils/index.ts +9 -2
  182. package/dist/chunk-23V5BSHD.cjs +0 -169
  183. package/dist/chunk-23V5BSHD.cjs.map +0 -1
  184. package/dist/chunk-CBXZSTAG.cjs.map +0 -1
  185. package/dist/chunk-I57XLISO.js.map +0 -1
  186. package/dist/chunk-O4MCCKKN.js +0 -169
  187. package/dist/chunk-O4MCCKKN.js.map +0 -1
  188. /package/dist/{chunk-PFV4DAX5.js.map → chunk-2ZLCQSG4.js.map} +0 -0
  189. /package/dist/{chunk-FOSIR4QF.js.map → chunk-3DWDJ54N.js.map} +0 -0
  190. /package/dist/{chunk-4EEUB62O.js.map → chunk-4HVWGYHI.js.map} +0 -0
  191. /package/dist/{chunk-27RD5XTP.js.map → chunk-4TLGU2FT.js.map} +0 -0
  192. /package/dist/{chunk-G5U4JP45.js.map → chunk-5ONM3FHQ.js.map} +0 -0
  193. /package/dist/{chunk-MRIOYSXH.js.map → chunk-63RIPFJ4.js.map} +0 -0
  194. /package/dist/{chunk-KJWPAJRT.js.map → chunk-7EI3NES7.js.map} +0 -0
  195. /package/dist/{chunk-3DGRXC74.js.map → chunk-CH5E4GXC.js.map} +0 -0
  196. /package/dist/{chunk-VE52MSYC.js.map → chunk-CJMWRV65.js.map} +0 -0
  197. /package/dist/{chunk-TTVOBWAH.js.map → chunk-D5PU7K2W.js.map} +0 -0
  198. /package/dist/{chunk-KEKN76JR.js.map → chunk-FRQ2DE5Z.js.map} +0 -0
  199. /package/dist/{chunk-JOV64HW5.js.map → chunk-GRBZC5N3.js.map} +0 -0
  200. /package/dist/{chunk-LPMDCQLL.js.map → chunk-H3EJDISW.js.map} +0 -0
  201. /package/dist/{chunk-HPWLIYRL.js.map → chunk-HT4B4NGI.js.map} +0 -0
  202. /package/dist/{chunk-KOLVBEW5.js.map → chunk-IWISVG4P.js.map} +0 -0
  203. /package/dist/{chunk-HOGOQA2X.js.map → chunk-JNOPOJHH.js.map} +0 -0
  204. /package/dist/{chunk-F2KBCLUG.js.map → chunk-KKSSA4CS.js.map} +0 -0
  205. /package/dist/{chunk-IXD6SHQ6.js.map → chunk-KMI4VAS2.js.map} +0 -0
  206. /package/dist/{chunk-RNMGKAS6.js.map → chunk-KPEBCJIH.js.map} +0 -0
  207. /package/dist/{chunk-FKBM6U43.js.map → chunk-LZLT67PE.js.map} +0 -0
  208. /package/dist/{chunk-B3Z3RJRW.js.map → chunk-M4AD2PHE.js.map} +0 -0
  209. /package/dist/{chunk-BVQEU5JB.js.map → chunk-MT5A25AX.js.map} +0 -0
  210. /package/dist/{chunk-S2KMNFFN.js.map → chunk-RJUXSUSM.js.map} +0 -0
  211. /package/dist/{chunk-SKABQX44.js.map → chunk-SKA27VLR.js.map} +0 -0
  212. /package/dist/{chunk-UEXIMEVU.js.map → chunk-VK7YKTAL.js.map} +0 -0
  213. /package/dist/{chunk-4WVWRFGP.js.map → chunk-W2HZUFVB.js.map} +0 -0
  214. /package/dist/{chunk-5JUTGEZE.js.map → chunk-XBTZOO74.js.map} +0 -0
  215. /package/dist/{chunk-7Q5XXPCB.js.map → chunk-Z3HJFVYS.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flamingo-stack/openframe-frontend-core",
3
- "version": "0.0.644",
3
+ "version": "0.0.645-snapshot.20260917103313",
4
4
  "description": "Shared design system and components for all Flamingo platforms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -3,6 +3,11 @@ import {
3
3
  PLATFORM_DOMAINS,
4
4
  byKey,
5
5
  getPlatformProductionUrl,
6
+ getPlatformUrl,
7
+ getDeploymentUrl,
8
+ getRequestOrigin,
9
+ isLocalUrl,
10
+ resolveRedirectTarget,
6
11
  getPlatformByHostname,
7
12
  getAllPlatformBaseDomains,
8
13
  hostOf,
@@ -156,6 +161,125 @@ describe('env override path', () => {
156
161
  });
157
162
  });
158
163
 
164
+ describe('getPlatformUrl — the one platform-URL resolver', () => {
165
+ it('is the registry URL in a production build, with no trailing slash', () => {
166
+ vi.stubEnv('NODE_ENV', 'production');
167
+ expect(getPlatformUrl('flamingo')).toBe('https://www.flamingo.run');
168
+ expect(getPlatformUrl('openframe')).toBe(getPlatformProductionUrl('openframe').replace(/\/+$/, ''));
169
+ });
170
+
171
+ it("never reads Vercel's first-listed domain", () => {
172
+ vi.stubEnv('NODE_ENV', 'production');
173
+ vi.stubEnv('VERCEL_PROJECT_PRODUCTION_URL', 'flamingo.cx');
174
+ expect(getPlatformUrl('flamingo')).toBe('https://www.flamingo.run');
175
+ });
176
+
177
+ it('is the local dev URL outside a production build, unless production is asked for', () => {
178
+ vi.stubEnv('NODE_ENV', 'development');
179
+ vi.stubEnv('NEXT_PUBLIC_DEV_URL', '');
180
+ expect(getPlatformUrl('openmsp')).toBe('http://localhost:3000');
181
+ expect(getPlatformUrl('openmsp', { environment: 'production' })).toBe('https://www.openmsp.ai');
182
+ vi.stubEnv('NEXT_PUBLIC_DEV_URL', 'https://my-tunnel.example/');
183
+ expect(getPlatformUrl('openmsp')).toBe('https://my-tunnel.example');
184
+ });
185
+ });
186
+
187
+ describe('getDeploymentUrl — the one app-origin resolver', () => {
188
+ // Server-side cases: jsdom defines `window`, which is the browser branch.
189
+ const onServer = () => vi.stubGlobal('window', undefined);
190
+
191
+ it("is a Vercel preview's own immutable URL", () => {
192
+ onServer();
193
+ vi.stubEnv('VERCEL_ENV', 'preview');
194
+ vi.stubEnv('VERCEL_URL', 'flamingo-abc123-flamingocx.vercel.app');
195
+ expect(getDeploymentUrl({ platform: 'flamingo' })).toBe('https://flamingo-abc123-flamingocx.vercel.app');
196
+ });
197
+
198
+ it("is the platform's registry URL in production, whatever Vercel's first domain is", () => {
199
+ onServer();
200
+ vi.stubEnv('VERCEL_ENV', 'production');
201
+ vi.stubEnv('VERCEL_PROJECT_PRODUCTION_URL', 'flamingo.cx');
202
+ expect(getDeploymentUrl({ platform: 'flamingo' })).toBe('https://www.flamingo.run');
203
+ });
204
+
205
+ it('uses a runtime-configured app URL (a self-hosted install) over every default', () => {
206
+ onServer();
207
+ vi.stubEnv('VERCEL_ENV', 'production');
208
+ expect(getDeploymentUrl({ platform: 'openframe-dashboard', configuredUrl: 'frame.acme-msp.example/' })).toBe(
209
+ 'https://frame.acme-msp.example',
210
+ );
211
+ expect(getDeploymentUrl({ platform: 'openframe-dashboard', configuredUrl: ' ' })).toBe(
212
+ getPlatformUrl('openframe-dashboard', { environment: 'production' }),
213
+ );
214
+ });
215
+
216
+ it('is localhost on the running port in development', () => {
217
+ onServer();
218
+ vi.stubEnv('VERCEL_ENV', '');
219
+ vi.stubEnv('NODE_ENV', 'development');
220
+ vi.stubEnv('NEXT_PUBLIC_DEV_URL', '');
221
+ vi.stubEnv('PORT', '4000');
222
+ expect(getDeploymentUrl({ platform: 'openframe-dashboard' })).toBe('http://localhost:4000');
223
+ });
224
+
225
+ it("is the page's origin in the browser", () => {
226
+ vi.stubGlobal('window', { location: { origin: 'https://tenant.openframe.ai' } });
227
+ expect(getDeploymentUrl({ platform: 'openframe-dashboard', configuredUrl: 'https://ignored.example' })).toBe(
228
+ 'https://tenant.openframe.ai',
229
+ );
230
+ });
231
+ });
232
+
233
+ describe('getRequestOrigin / isLocalUrl / resolveRedirectTarget', () => {
234
+ const headers = (values: Record<string, string>) => ({ get: (name: string) => values[name] ?? null });
235
+
236
+ it('reads the host the request arrived on, https unless local, ignoring x-forwarded-host, else the app origin', () => {
237
+ expect(getRequestOrigin(headers({ host: 'www.flamingo.run' }), { platform: 'flamingo' })).toBe(
238
+ 'https://www.flamingo.run',
239
+ );
240
+ expect(getRequestOrigin(headers({ host: 'localhost:3000' }), { platform: 'flamingo' })).toBe(
241
+ 'http://localhost:3000',
242
+ );
243
+ expect(getRequestOrigin(headers({ host: '[::1]:3000' }), { platform: 'flamingo' })).toBe('http://[::1]:3000');
244
+ expect(
245
+ getRequestOrigin(headers({ host: 'x.vercel.app', 'x-forwarded-proto': 'https' }), { platform: 'flamingo' }),
246
+ ).toBe('https://x.vercel.app');
247
+ expect(
248
+ getRequestOrigin(headers({ host: 'www.flamingo.run', 'x-forwarded-host': 'evil.example' }), {
249
+ platform: 'flamingo',
250
+ }),
251
+ ).toBe('https://www.flamingo.run');
252
+ vi.stubGlobal('window', undefined);
253
+ vi.stubEnv('NEXT_PUBLIC_DEV_URL', 'http://localhost:4000');
254
+ expect(getRequestOrigin(headers({}), { platform: 'flamingo' })).toBe('http://localhost:4000');
255
+ });
256
+
257
+ it.each([
258
+ ['http://localhost:3000', true],
259
+ ['http://127.0.0.1:3000/x', true],
260
+ ['http://0.0.0.0', true],
261
+ ['http://[::1]:3000', true],
262
+ ['https://www.flamingo.run', false],
263
+ ['https://localhost.example.com', false],
264
+ ['http://127.evil.example', false],
265
+ ['not a url', false],
266
+ ])('isLocalUrl(%s) → %s', (url, local) => expect(isLocalUrl(url)).toBe(local));
267
+
268
+ it('resolves same-origin paths and passes explicit absolute URLs through', () => {
269
+ const origin = 'https://flamingo-abc123-flamingocx.vercel.app';
270
+ expect(resolveRedirectTarget(origin, '/admin/x?y=1').href).toBe(`${origin}/admin/x?y=1`);
271
+ expect(resolveRedirectTarget(origin, 'auth/callback-client').href).toBe(`${origin}/auth/callback-client`);
272
+ expect(resolveRedirectTarget(origin, 'https://www.flamingo.run/blog').href).toBe('https://www.flamingo.run/blog');
273
+ });
274
+
275
+ it.each(['//evil.example/path', '/\\evil.example/path', '\\\\evil.example', '\\/evil.example'])(
276
+ 'refuses %s, which would leave the origin',
277
+ target => {
278
+ expect(() => resolveRedirectTarget('https://www.flamingo.run', target)).toThrow('is not a same-origin path');
279
+ },
280
+ );
281
+ });
282
+
159
283
  describe('registry integrity', () => {
160
284
  it('byKey resolves every key and openframe-dashboard is pseudo', () => {
161
285
  expect(byKey('openframe-dashboard')?.pseudo).toBe(true);
@@ -154,7 +154,7 @@ export interface EmbeddableChatProps {
154
154
  baseRoute?: string;
155
155
  /** When the embedder doesn't host a `[...path]` route to render markdown
156
156
  * chips against, set this to a platform that does. Chips with
157
- * `externalUrl: null` resolve to `getBaseUrl(chipBasePlatform) +
157
+ * `externalUrl: null` resolve to `getPlatformUrl(chipBasePlatform) +
158
158
  * '/knowledge-base/' + path` and open in a new tab. */
159
159
  chipBasePlatform?: string;
160
160
  /** DB-driven list of enabled RAG table ids (chip catalog filter).
@@ -882,6 +882,12 @@ function SourceChips({
882
882
  * EmbeddableChat — the floating "Ask AI" button + Mingo chat panel.
883
883
  * Lib-portable port of the hub's `<GlobalAskAI>`.
884
884
  */
885
+ /** What a host hands `EmbeddableChatHandle.prefillDraft`: the composer text plus the context items to attach. */
886
+ export interface ChatPrefillDraft {
887
+ text: string;
888
+ mentions?: ChatContextItem[];
889
+ }
890
+
885
891
  /**
886
892
  * Imperative escape hatch for the ONE thing a host can't express as a prop:
887
893
  * "put the panel on a new chat, now". Everything else the host drives is state
@@ -899,6 +905,14 @@ export interface EmbeddableChatHandle {
899
905
  * the compose flag is inert.
900
906
  */
901
907
  startNewChat: () => void;
908
+ /**
909
+ * A new chat with the composer PREFILLED and nothing sent: the host has a
910
+ * suggested message (e.g. "Fix with Mingo" on an incident) and the user
911
+ * decides whether to send it. `mentions` are attached as context items up
912
+ * front, each committed as an inline `@marker:id` chip exactly as if picked
913
+ * from the `@` picker, and `text` follows them in the draft.
914
+ */
915
+ prefillDraft: (draft: ChatPrefillDraft) => void;
902
916
  }
903
917
 
904
918
  export const EmbeddableChat = React.forwardRef<EmbeddableChatHandle, EmbeddableChatProps>(
@@ -1439,7 +1453,7 @@ function EmbeddableChatInner({
1439
1453
  // doesn't host an in-app doc viewer should NOT pass an empty baseRoute (that just
1440
1454
  // falls back to the platform default here) — instead it sets a truthy baseRoute +
1441
1455
  // `chipBasePlatform` so doc chips with no externalUrl resolve cross-platform to that
1442
- // platform's public knowledge hub (`getBaseUrl(chipBasePlatform)/knowledge-base/…`),
1456
+ // platform's public knowledge hub (`getPlatformUrl(chipBasePlatform)/knowledge-base/…`),
1443
1457
  // exactly like the hub's openframe config (baseRoute:'/', chipBasePlatform:'openframe').
1444
1458
  const resolvedBaseRoute = baseRoute || (source === 'flamingo' ? '/knowledge-base' : '/data-room');
1445
1459
 
@@ -2025,6 +2039,43 @@ function EmbeddableChatInner({
2025
2039
  resetToNewChat();
2026
2040
  }, [resetToNewChat]);
2027
2041
 
2042
+ // Host prefill (`prefillDraft`) — staged, not written at once. The composer
2043
+ // it goes into may only mount on the commit `resetToNewChat` +
2044
+ // `setComposeOpen(true)` produce (narrow layout: list → compose; or the
2045
+ // archive closing), and those are ordinary updates React commits on its own
2046
+ // schedule — a frame-timed write raced them and lost on a phone. So the
2047
+ // draft waits in state: the context strip is seeded while rendering (AFTER
2048
+ // the dialog-change reset above, which would otherwise wipe it), and the
2049
+ // effect writes the chips + text once `chatInputRef` is attached, re-running
2050
+ // on each layout change until it is. `mentionKeysRef` is cleared by the
2051
+ // dialog-change effect above, so this one must stay declared after it.
2052
+ const [pendingDraft, setPendingDraft] = useState<Required<ChatPrefillDraft> | null>(null);
2053
+ const [seededDraft, setSeededDraft] = useState<Required<ChatPrefillDraft> | null>(null);
2054
+ if (pendingDraft && seededDraft !== pendingDraft) {
2055
+ setSeededDraft(pendingDraft);
2056
+ setContextItems(pendingDraft.mentions);
2057
+ }
2058
+ const appliedDraftRef = useRef<Required<ChatPrefillDraft> | null>(null);
2059
+ useEffect(() => {
2060
+ const draft = pendingDraft;
2061
+ if (!draft || appliedDraftRef.current === draft) return;
2062
+ const input = chatInputRef.current;
2063
+ if (!input) return;
2064
+ appliedDraftRef.current = draft;
2065
+ input.clear();
2066
+ for (const item of draft.mentions) {
2067
+ const key = `${item.type}:${item.id}`;
2068
+ input.commitMention(mentionTokenOf(key, mentionMarkerByType), {
2069
+ label: item.label,
2070
+ icon: resolveContextIcon(item),
2071
+ });
2072
+ mentionKeysRef.current.add(key);
2073
+ }
2074
+ // The text starts on its own line — its first line is a heading, not a
2075
+ // continuation of the chip run.
2076
+ if (draft.text) input.setValue(`${input.getValue()}${draft.mentions.length > 0 ? '\n' : ''}${draft.text}`);
2077
+ }, [pendingDraft, composeOpen, activeDialogId, activeMode, archiveOpen, mentionMarkerByType, resolveContextIcon]);
2078
+
2028
2079
  // Host-driven "Start New Chat" (see EmbeddableChatHandle). Same reset as the
2029
2080
  // rail button, plus the narrow layout's list→compose navigation that the
2030
2081
  // in-panel button gets from the list itself — a host has no other way in.
@@ -2035,8 +2086,19 @@ function EmbeddableChatInner({
2035
2086
  resetToNewChat();
2036
2087
  setComposeOpen(true);
2037
2088
  },
2089
+ prefillDraft: ({ text, mentions = [] }) => {
2090
+ resetToNewChat();
2091
+ setComposeOpen(true);
2092
+ // The effect below clears the draft, which invalidates every key held
2093
+ // here. Dropped now rather than there: with no dialog change nothing
2094
+ // else clears them, and a composer mounting on this commit reports
2095
+ // `onValueChange('')` before that effect runs — a stale key equal to
2096
+ // one of the new mentions would strip the freshly seeded item.
2097
+ mentionKeysRef.current.clear();
2098
+ setPendingDraft({ text, mentions: mentions.slice(0, contextMaxItems) });
2099
+ },
2038
2100
  }),
2039
- [resetToNewChat],
2101
+ [resetToNewChat, contextMaxItems],
2040
2102
  );
2041
2103
 
2042
2104
  // Desktop split header ⋯ menu (active, non-archived conversation only).
@@ -84,4 +84,9 @@ export * from './utils';
84
84
  // EmbeddableChat — full chat orchestrator (lib-portable port of hub's
85
85
  // `<GlobalAskAI>`). Hosts mount it once at the root after providing a
86
86
  // <ChatRuntimeContext.Provider>.
87
- export { EmbeddableChat, type EmbeddableChatHandle, type EmbeddableChatProps } from './embeddable-chat';
87
+ export {
88
+ type ChatPrefillDraft,
89
+ EmbeddableChat,
90
+ type EmbeddableChatHandle,
91
+ type EmbeddableChatProps,
92
+ } from './embeddable-chat';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { getBaseUrl } from '../../../../utils/cn';
2
+ import { getPlatformUrl } from '../../../../platform-domains';
3
3
  import { resolveSourceRowCTA } from '../source-row-cta';
4
4
 
5
5
  /**
@@ -28,7 +28,7 @@ describe('resolveSourceRowCTA — doc-chip platform routing', () => {
28
28
  };
29
29
 
30
30
  const expectHref = (platform: string, base: string, path: string) =>
31
- new URL(path, `${getBaseUrl(platform)}/${base}/`).toString();
31
+ new URL(path, `${getPlatformUrl(platform)}/${base}/`).toString();
32
32
 
33
33
  it('routes EACH doc source to its own platform from ONE shared context (mixed sources)', () => {
34
34
  const md = resolveSourceRowCTA(markdownRow, { docPlatformTargets });
@@ -23,7 +23,7 @@
23
23
 
24
24
  import { FileText } from 'lucide-react';
25
25
  import type React from 'react';
26
- import { getBaseUrl } from '../../../utils/cn';
26
+ import { getPlatformUrl } from '../../../platform-domains';
27
27
  import type { ComposeContentUrl } from '../../../utils/content-href';
28
28
  import { canonicalContentRefType } from '../../../utils/list-url';
29
29
  import type { ChatRef } from '../chat-ref.types';
@@ -93,7 +93,7 @@ export interface SourceRowContext {
93
93
  * replacement for the single `chipBasePlatform`. Maps a doc-table documentType
94
94
  * (`'markdown'`, `'data_room_doc'`, …) → the platform whose PUBLIC doc viewer
95
95
  * hosts it + that viewer's base path. A doc chip with no `externalUrl` resolves
96
- * to `getBaseUrl(platform)/<basePath>/<path>` PER ROW — so a chat mixing several
96
+ * to `getPlatformUrl(platform)/<basePath>/<path>` PER ROW — so a chat mixing several
97
97
  * doc sources sends EACH to its own home (markdown→flamingo/knowledge-base,
98
98
  * data_room_doc→company-hub/data-room) instead of one static fallback for all.
99
99
  * Wins over `chipBasePlatform` when a row's documentType has an entry.
@@ -212,11 +212,11 @@ export function resolveSourceRowCTA(row: SourceRowInput, ctx: SourceRowContext =
212
212
  // slash-stripping regex `/^\/+|\/+$/g` tripped CodeQL's js/polynomial-redos (high)
213
213
  // since `\/+$` backtracks on inputs with many '/'. split/filter/join is linear.
214
214
  const seg = docTarget.basePath.split('/').filter(Boolean).join('/');
215
- const base = `${getBaseUrl(docTarget.platform)}${seg ? `/${seg}` : ''}/`;
215
+ const base = `${getPlatformUrl(docTarget.platform)}${seg ? `/${seg}` : ''}/`;
216
216
  href = safeHref(new URL(safePath, base).toString()) ?? null;
217
217
  targetPlatform = docTarget.platform;
218
218
  } else if (ctx.chipBasePlatform) {
219
- const base = `${getBaseUrl(ctx.chipBasePlatform)}/knowledge-base/`;
219
+ const base = `${getPlatformUrl(ctx.chipBasePlatform)}/knowledge-base/`;
220
220
  href = safeHref(new URL(safePath, base).toString()) ?? null;
221
221
  targetPlatform = ctx.chipBasePlatform;
222
222
  } else if (ctx.baseRoute) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type React from 'react';
4
4
  import { useState, useEffect } from 'react';
5
- import { getBaseUrl } from '../utils';
5
+ import { getPlatformUrl } from '../platform-domains';
6
6
  import { FlamingoLogo } from './flamingo-logo';
7
7
 
8
8
  interface MadeWithLoveProps {
@@ -52,7 +52,7 @@ export function MadeWithLove({ className = '', size = 'md', showOnMobile = true
52
52
  };
53
53
 
54
54
  const config = sizeConfig[size];
55
- const flamingoUrl = getBaseUrl('flamingo');
55
+ const flamingoUrl = getPlatformUrl('flamingo');
56
56
 
57
57
  // Container styles using primitive CSS
58
58
  const containerStyle: React.CSSProperties = {
@@ -246,7 +246,7 @@ export interface ChatRuntime {
246
246
  * the single `chipBasePlatform` prop. Maps a doc-table documentType
247
247
  * (`'markdown'`, `'data_room_doc'`, …) → `{ platform, basePath }` for the PUBLIC
248
248
  * doc viewer that hosts it. Doc chips with no `externalUrl` resolve PER ROW to
249
- * `getBaseUrl(platform)/<basePath>/<path>`, so a chat mixing several doc sources
249
+ * `getPlatformUrl(platform)/<basePath>/<path>`, so a chat mixing several doc sources
250
250
  * sends EACH to its own home (markdown→flamingo/knowledge-base,
251
251
  * data_room_doc→company-hub/data-room) instead of one static fallback. The hub
252
252
  * may keep using `chipBasePlatform` (one doc source per platform); embedders that
@@ -115,9 +115,8 @@ function envOverrideFor(key: string): string | null {
115
115
  * base-domain derivation, CSP) receives a parseable URL. Full-URL inputs (the registry
116
116
  * `defaultUrl`s, any scheme'd override) pass through unchanged.
117
117
  *
118
- * EXPORTED as the single owner of the scheme-normalization rule (next.config.mjs keeps a
119
- * byte-identical local copy ONLY because Next evaluates its config outside the TS module
120
- * graph and cannot import this — see the comment there).
118
+ * EXPORTED as the single owner of the scheme-normalization rule. This subpath is pure ESM,
119
+ * so a consumer's next.config.mjs imports it directly rather than keeping a copy.
121
120
  *
122
121
  * Handles a (theoretical) protocol-relative `//host` too: strips the leading slashes so it
123
122
  * doesn't become `https:////host` (empty-host → hostOf null → silent platform drop).
@@ -133,7 +132,7 @@ export function ensureScheme(url: string): string {
133
132
  * NEVER throws / undefined — the default guarantees a host (this is what keeps the
134
133
  * cookie base-domains, the reverse map, and CSP intact even with every override unset).
135
134
  * The result ALWAYS carries a scheme (`ensureScheme`), so the scheme-less env overrides
136
- * resolve to valid URLs. Unknown-key fallback preserves cn.ts's flamingo.run default.
135
+ * resolve to valid URLs. Unknown-key fallback is flamingo's URL.
137
136
  */
138
137
  export function getPlatformProductionUrl(platform: string): string {
139
138
  const resolved =
@@ -141,6 +140,102 @@ export function getPlatformProductionUrl(platform: string): string {
141
140
  return ensureScheme(resolved);
142
141
  }
143
142
 
143
+ /**
144
+ * THE URL of a platform, for the environment the code is running in, no trailing slash.
145
+ * The one platform-URL resolver: consumers build every link to a platform from this.
146
+ *
147
+ * - `environment: 'current'` (default): the local dev URL (`NEXT_PUBLIC_DEV_URL`, else
148
+ * `http://localhost:3000`) outside a production build, the registry's production URL
149
+ * in any production build (a preview included — a preview never links to itself as
150
+ * canonical).
151
+ * - `environment: 'production'`: the registry's production URL everywhere, for links that
152
+ * leave the machine.
153
+ *
154
+ * `platform` is REQUIRED. The former `getBaseUrl()` accepted none and then returned
155
+ * `VERCEL_PROJECT_PRODUCTION_URL` — whichever domain Vercel lists first for a project
156
+ * (`flamingo.cx` on flamingo, a 308), and production on previews. A deployment's own
157
+ * origin is not a platform URL; consumers resolve it themselves.
158
+ */
159
+ export function getPlatformUrl(platform: string, options: { environment?: 'current' | 'production' } = {}): string {
160
+ const url =
161
+ options.environment !== 'production' && process.env.NODE_ENV !== 'production'
162
+ ? process.env.NEXT_PUBLIC_DEV_URL || 'http://localhost:3000'
163
+ : getPlatformProductionUrl(platform);
164
+ return url.replace(/\/+$/, '');
165
+ }
166
+
167
+ /**
168
+ * Where THIS app is reachable, no trailing slash: what anything outside the app must
169
+ * fetch from the code that is running (rendered images, provider callbacks, self-calls).
170
+ * The one app-origin resolver; each app only supplies its own platform and config.
171
+ *
172
+ * In order:
173
+ * 1. In the browser: the page's origin.
174
+ * 2. `configuredUrl`: an app whose URL is configured at runtime (a self-hosted OpenFrame
175
+ * install's `NEXT_PUBLIC_APP_URL`) — that install's address wins over any default.
176
+ * 3. On a Vercel preview: the deployment's immutable `VERCEL_URL` (not the branch alias,
177
+ * which moves to the next commit and would serve other code).
178
+ * 4. In any production build: the platform's registry URL.
179
+ * 5. In development: `NEXT_PUBLIC_DEV_URL`, else localhost on the running port.
180
+ */
181
+ export function getDeploymentUrl(options: { platform: string; configuredUrl?: string | null }): string {
182
+ if (typeof window !== 'undefined') return window.location.origin;
183
+ const configured = options.configuredUrl?.trim();
184
+ if (configured) return ensureScheme(configured).replace(/\/+$/, '');
185
+ if (process.env.VERCEL_ENV === 'preview' && process.env.VERCEL_URL) {
186
+ return ensureScheme(process.env.VERCEL_URL).replace(/\/+$/, '');
187
+ }
188
+ if (process.env.VERCEL_ENV === 'production' || process.env.NODE_ENV === 'production') {
189
+ return getPlatformUrl(options.platform, { environment: 'production' });
190
+ }
191
+ return (process.env.NEXT_PUBLIC_DEV_URL || `http://localhost:${process.env.PORT ?? 3000}`).replace(/\/+$/, '');
192
+ }
193
+
194
+ /** A hostname on the local machine, matched WHOLE: `localhost.example.com` and
195
+ * `127.evil.example` are public hosts. */
196
+ const LOCAL_HOSTNAME = /^(localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[::1\])$/i;
197
+
198
+ /** Is this URL on the local machine, where no external system (a webhook sender, an
199
+ * OAuth provider) can reach it? False for anything that is not a URL. */
200
+ export function isLocalUrl(url: string): boolean {
201
+ try {
202
+ return LOCAL_HOSTNAME.test(new URL(url).hostname);
203
+ } catch {
204
+ return false;
205
+ }
206
+ }
207
+
208
+ /**
209
+ * The origin a server request arrived on, from its `host` header only (what the edge set
210
+ * for this request — a client-writable `x-forwarded-host` never chooses where a flow
211
+ * returns). `http` for a local host unless the proxy says otherwise, else `https`.
212
+ * With no Host header, the app's own origin (`getDeploymentUrl` for `platform`).
213
+ */
214
+ export function getRequestOrigin(
215
+ headers: { get(name: string): string | null },
216
+ options: { platform: string; configuredUrl?: string | null },
217
+ ): string {
218
+ const host = headers.get('host');
219
+ if (!host) return getDeploymentUrl(options);
220
+ const local = LOCAL_HOSTNAME.test(host.replace(/:\d+$/, ''));
221
+ const proto = headers.get('x-forwarded-proto')?.split(',')[0].trim() || (local ? 'http' : 'https');
222
+ return `${proto}://${host}`;
223
+ }
224
+
225
+ /**
226
+ * Where a redirect goes: a path resolves against `origin`; an explicit absolute
227
+ * `http(s)://` URL is used as is. THROWS when a relative target resolves to another
228
+ * origin (`//evil.example`, `/\\evil.example`), so a shared redirect helper built on it
229
+ * can never be an open redirect.
230
+ */
231
+ export function resolveRedirectTarget(origin: string, target: string): URL {
232
+ const url = new URL(target, origin);
233
+ if (!/^https?:\/\//i.test(target) && url.origin !== new URL(origin).origin) {
234
+ throw new Error(`resolveRedirectTarget: "${target}" is not a same-origin path`);
235
+ }
236
+ return url;
237
+ }
238
+
144
239
  // ── Single-owner host primitives ──
145
240
 
146
241
  /** Canonical URL→host parser: `.hostname` (PORT-STRIPPED, lowercased), null on parse failure. */
package/src/utils/.cn.md CHANGED
@@ -1,12 +1,11 @@
1
1
  <!-- source-hash: 700d6c65ebfb65630e665b437acf4e83 -->
2
- Utility module providing two core helpers: a Tailwind-aware class name merger (`cn`) that correctly handles custom ODS typography utilities, and an environment-aware base URL resolver (`getBaseUrl`) that delegates platform canonical URLs to the SSOT in `platform-domains.ts`.
2
+ Utility module providing a Tailwind-aware class name merger (`cn`) that correctly handles custom ODS typography utilities. (Platform URLs are resolved by `getPlatformUrl` in `platform-domains.ts`, not here.)
3
3
 
4
4
  ## Key Components
5
5
 
6
6
  | Export | Type | Description |
7
7
  |--------|------|-------------|
8
8
  | `cn` | `function` | Combines class names using `clsx` + a custom `tailwind-merge` instance |
9
- | `getBaseUrl` | `function` | Returns the application base URL for the current environment |
10
9
  | `twMerge` | internal | Extended `tailwind-merge` instance with the `ods-typography` class group |
11
10
 
12
11
  ### `ods-typography` Class Group
@@ -22,7 +21,7 @@ Without this registration, `cn('text-badge', 'text-ods-text-on-accent')` would d
22
21
  ## Usage Example
23
22
 
24
23
  ```typescript
25
- import { cn, getBaseUrl } from '@/lib/cn'
24
+ import { cn } from '@/lib/cn'
26
25
 
27
26
  // Merge conditional classes safely — typography and colour both survive
28
27
  const className = cn(
@@ -31,25 +30,6 @@ const className = cn(
31
30
  isActive && 'bg-accent',
32
31
  )
33
32
 
34
- // Current deployment URL (dev → localhost, prod → Vercel/canonical domain)
35
- const currentUrl = getBaseUrl()
36
-
37
- // Specific platform URL (respects env override, falls back to canonical)
38
- const flamingoUrl = getBaseUrl('flamingo') // https://www.flamingo.run
39
- const openMspUrl = getBaseUrl('openmsp') // https://www.openmsp.ai
40
- ```
41
-
42
- ## `getBaseUrl` Resolution Order
43
-
44
- ```mermaid
45
- graph TD
46
- A[getBaseUrl called] --> B{NODE_ENV !== production?}
47
- B -->|Yes| C[NEXT_PUBLIC_DEV_URL or localhost:3000]
48
- B -->|No| D{platform arg provided?}
49
- D -->|Yes| E[getPlatformProductionUrl from SSOT]
50
- D -->|No| F{VERCEL_PROJECT_PRODUCTION_URL set?}
51
- F -->|Yes| G[https://vercel-domain]
52
- F -->|No| H[getPlatformProductionUrl via NEXT_PUBLIC_APP_TYPE]
53
33
  ```
54
34
 
55
- > Platform canonical URLs and their `NEXT_PUBLIC_*_URL` environment overrides are defined exclusively in [`src/platform-domains.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/platform-domains.ts).
35
+ > Platform URLs are resolved by `getPlatformUrl` (with the canonical URLs and their `NEXT_PUBLIC_*_URL` overrides) exclusively in [`src/platform-domains.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/platform-domains.ts).
package/src/utils/cn.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  import { clsx, type ClassValue } from 'clsx';
2
2
  import { extendTailwindMerge } from 'tailwind-merge';
3
- // Platform→domain resolution moved to the SSOT module `src/platform-domains.ts`.
4
- // `getPlatformProductionUrl` / `getAllPlatformBaseDomains` now live there (re-exported
5
- // via the utils barrel for existing callers); `getBaseUrl` stays here because it owns the
6
- // dev-localhost + Vercel-self-origin branches, and delegates its platform branch.
7
- import { getPlatformProductionUrl } from '../platform-domains';
8
3
 
9
4
  /**
10
5
  * EVERY custom `text-*` utility we add in `tailwind.config.ts` MUST be listed here.
@@ -37,45 +32,3 @@ const twMerge = extendTailwindMerge<'ods-typography'>({
37
32
  export function cn(...inputs: ClassValue[]) {
38
33
  return twMerge(clsx(inputs));
39
34
  }
40
-
41
- /**
42
- * Get the application base URL for the current environment
43
- *
44
- * @param platform - Optional platform name (openmsp, flamingo, tmcg, openframe, etc.)
45
- * @returns The base URL with protocol (https:// or http://)
46
- *
47
- * Priority order:
48
- * 1. Development (http://localhost:3000)
49
- * 2. Platform-specific URL via the SSOT (if `platform` provided) — env override ?? default
50
- * 3. VERCEL_PROJECT_PRODUCTION_URL (Vercel production domain)
51
- * 4. Production fallback: the DEPLOYING platform's canonical URL (NEXT_PUBLIC_APP_TYPE),
52
- * openmsp if unset — sourced from the SSOT, no hardcoded literal.
53
- *
54
- * The per-platform canonical URLs + their `NEXT_PUBLIC_*_URL` overrides are the single
55
- * source of truth in `src/platform-domains.ts` (`PLATFORM_DOMAINS`).
56
- *
57
- * @example
58
- * getBaseUrl() // Current deployment's URL
59
- * getBaseUrl('flamingo') // https://www.flamingo.run (prod) or http://localhost:3000 (dev)
60
- */
61
- export function getBaseUrl(platform?: string): string {
62
- // In development, always use localhost (regardless of platform)
63
- if (process.env.NODE_ENV !== 'production') {
64
- return process.env.NEXT_PUBLIC_DEV_URL || 'http://localhost:3000';
65
- }
66
-
67
- // If platform is specified, return its production URL (env override ?? default)
68
- if (platform) {
69
- return getPlatformProductionUrl(platform);
70
- }
71
-
72
- // Production: Use Vercel domain if available
73
- if (process.env.VERCEL_PROJECT_PRODUCTION_URL) {
74
- return `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`;
75
- }
76
-
77
- // Production fallback: the deploying platform's canonical www domain (avoids Google
78
- // "Page with redirect"). Derived from the SSOT for the current app type (openmsp when
79
- // unset → 'https://www.openmsp.ai', byte-identical to the old hardcoded fallback).
80
- return getPlatformProductionUrl(process.env.NEXT_PUBLIC_APP_TYPE || 'openmsp');
81
- }
@@ -4,7 +4,15 @@ export { cn } from './cn';
4
4
  // here so existing `/utils` callers keep working; the new resolver/helpers
5
5
  // (getPlatformByHostname/hostOf/expandWwwApex/…) are exposed via the `/platform-domains`
6
6
  // subpath ONLY (one import surface for the new API).
7
- export { getPlatformProductionUrl, getAllPlatformBaseDomains } from '../platform-domains';
7
+ export {
8
+ getPlatformUrl,
9
+ getPlatformProductionUrl,
10
+ getAllPlatformBaseDomains,
11
+ getDeploymentUrl,
12
+ getRequestOrigin,
13
+ isLocalUrl,
14
+ resolveRedirectTarget,
15
+ } from '../platform-domains';
8
16
  // Number / currency / byte / date formatters live in `./format` (single
9
17
  // source of truth). Re-exported here so existing callers that pull from
10
18
  // the barrel keep working without changing imports.
@@ -40,7 +48,6 @@ export {
40
48
  pick,
41
49
  NO_CLIENT_CACHE,
42
50
  } from './common';
43
- export { getBaseUrl } from '../utils/cn';
44
51
  // SEO title length budget — server-safe constant (SSOT). Consumed by the hub
45
52
  // (prompt guidance + DB check value) and by SEOEditorPreview (input maxLength).
46
53
  export { SEO_TITLE_MAX_LENGTH } from './seo-title';