@flamingo-stack/openframe-frontend-core 0.0.644 → 0.0.645-2219.6362.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-IXD6SHQ6.js → chunk-2SNL36JV.js} +6 -6
  3. package/dist/{chunk-FOSIR4QF.js → chunk-3DWDJ54N.js} +5 -5
  4. package/dist/{chunk-YB6FI2G3.js → chunk-3SMLYVM2.js} +1 -1
  5. package/dist/{chunk-YB6FI2G3.js.map → chunk-3SMLYVM2.js.map} +1 -1
  6. package/dist/{chunk-UKV52KAP.cjs → chunk-3WLHNR2G.cjs} +44 -44
  7. package/dist/{chunk-UKV52KAP.cjs.map → chunk-3WLHNR2G.cjs.map} +1 -1
  8. package/dist/{chunk-FAD5WURS.cjs → chunk-4GZZYHG5.cjs} +124 -124
  9. package/dist/{chunk-FAD5WURS.cjs.map → chunk-4GZZYHG5.cjs.map} +1 -1
  10. package/dist/{chunk-4EEUB62O.js → chunk-4HVWGYHI.js} +2 -2
  11. package/dist/{chunk-RFFF2EYD.cjs → chunk-5F5WKIDW.cjs} +15 -15
  12. package/dist/{chunk-RFFF2EYD.cjs.map → chunk-5F5WKIDW.cjs.map} +1 -1
  13. package/dist/{chunk-G5U4JP45.js → chunk-5ONM3FHQ.js} +4 -4
  14. package/dist/{chunk-GELNUDBT.cjs → chunk-77BLJHKI.cjs} +10 -10
  15. package/dist/{chunk-GELNUDBT.cjs.map → chunk-77BLJHKI.cjs.map} +1 -1
  16. package/dist/{chunk-KJWPAJRT.js → chunk-7EI3NES7.js} +3 -3
  17. package/dist/{chunk-C5Y5T6GC.cjs → chunk-AHC2CQDD.cjs} +20 -20
  18. package/dist/{chunk-C5Y5T6GC.cjs.map → chunk-AHC2CQDD.cjs.map} +1 -1
  19. package/dist/{chunk-MCQAOIUK.cjs → chunk-BH34E2RJ.cjs} +37 -37
  20. package/dist/{chunk-MCQAOIUK.cjs.map → chunk-BH34E2RJ.cjs.map} +1 -1
  21. package/dist/{chunk-TGUA3C4U.cjs → chunk-BWGV4TI5.cjs} +9 -9
  22. package/dist/{chunk-TGUA3C4U.cjs.map → chunk-BWGV4TI5.cjs.map} +1 -1
  23. package/dist/{chunk-I57XLISO.js → chunk-CLVJC6SI.js} +195 -15
  24. package/dist/chunk-CLVJC6SI.js.map +1 -0
  25. package/dist/{chunk-27RD5XTP.js → chunk-CYXV5HPV.js} +5 -5
  26. package/dist/{chunk-4WVWRFGP.js → chunk-DEIYPXGD.js} +9 -9
  27. package/dist/{chunk-3IXDZI3R.cjs → chunk-DOVVKQMZ.cjs} +3 -3
  28. package/dist/{chunk-3IXDZI3R.cjs.map → chunk-DOVVKQMZ.cjs.map} +1 -1
  29. package/dist/{chunk-KOQCA5X5.cjs → chunk-DWJREJRA.cjs} +5 -5
  30. package/dist/{chunk-KOQCA5X5.cjs.map → chunk-DWJREJRA.cjs.map} +1 -1
  31. package/dist/{chunk-TTVOBWAH.js → chunk-EADBLRNF.js} +5 -5
  32. package/dist/{chunk-MRIOYSXH.js → chunk-EBDCDHOT.js} +5 -5
  33. package/dist/{chunk-RNMGKAS6.js → chunk-EDNZ2HN3.js} +15 -15
  34. package/dist/{chunk-7R2DIGG4.cjs → chunk-EX5PJGVA.cjs} +76 -76
  35. package/dist/{chunk-7R2DIGG4.cjs.map → chunk-EX5PJGVA.cjs.map} +1 -1
  36. package/dist/{chunk-GBEUGDZG.cjs → chunk-F6U2H42L.cjs} +23 -23
  37. package/dist/{chunk-GBEUGDZG.cjs.map → chunk-F6U2H42L.cjs.map} +1 -1
  38. package/dist/{chunk-KEKN76JR.js → chunk-FRQ2DE5Z.js} +5 -5
  39. package/dist/{chunk-JOV64HW5.js → chunk-GRBZC5N3.js} +3 -3
  40. package/dist/{chunk-CHIHYC7Q.cjs → chunk-GSD62VAY.cjs} +21 -21
  41. package/dist/{chunk-CHIHYC7Q.cjs.map → chunk-GSD62VAY.cjs.map} +1 -1
  42. package/dist/{chunk-LPMDCQLL.js → chunk-H3EJDISW.js} +2 -2
  43. package/dist/{chunk-3DGRXC74.js → chunk-HQBC7YRF.js} +5 -5
  44. package/dist/{chunk-VE52MSYC.js → chunk-IERXOVIS.js} +8 -8
  45. package/dist/{chunk-KOLVBEW5.js → chunk-IWISVG4P.js} +3 -3
  46. package/dist/{chunk-GNKM6R55.cjs → chunk-JH5P72AF.cjs} +25 -25
  47. package/dist/{chunk-GNKM6R55.cjs.map → chunk-JH5P72AF.cjs.map} +1 -1
  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-OMSUWB6A.cjs → chunk-K72YMLCU.cjs} +118 -118
  51. package/dist/{chunk-OMSUWB6A.cjs.map → chunk-K72YMLCU.cjs.map} +1 -1
  52. package/dist/{chunk-CBXZSTAG.cjs → chunk-KHHFMHYE.cjs} +973 -793
  53. package/dist/chunk-KHHFMHYE.cjs.map +1 -0
  54. package/dist/{chunk-F2KBCLUG.js → chunk-KKSSA4CS.js} +2 -2
  55. package/dist/{chunk-IIXB5REN.cjs → chunk-KL3Z26IS.cjs} +16 -16
  56. package/dist/{chunk-IIXB5REN.cjs.map → chunk-KL3Z26IS.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-UEXIMEVU.js → chunk-N7IAE3DN.js} +10 -10
  61. package/dist/{chunk-DCCY54LU.cjs → chunk-O2SLSYJC.cjs} +14 -14
  62. package/dist/{chunk-DCCY54LU.cjs.map → chunk-O2SLSYJC.cjs.map} +1 -1
  63. package/dist/{chunk-3UBT2OIX.cjs → chunk-O3YNMOIS.cjs} +74 -74
  64. package/dist/{chunk-3UBT2OIX.cjs.map → chunk-O3YNMOIS.cjs.map} +1 -1
  65. package/dist/{chunk-HOGOQA2X.js → chunk-O7LA444D.js} +3 -3
  66. package/dist/{chunk-PFV4DAX5.js → chunk-OBBAT4AU.js} +10 -10
  67. package/dist/{chunk-B5IFXCRF.cjs → chunk-OPNEE5XD.cjs} +41 -41
  68. package/dist/{chunk-B5IFXCRF.cjs.map → chunk-OPNEE5XD.cjs.map} +1 -1
  69. package/dist/chunk-OXB6LRBK.js +20 -0
  70. package/dist/chunk-OXB6LRBK.js.map +1 -0
  71. package/dist/{chunk-SKABQX44.js → chunk-QP7Z4EN7.js} +7 -7
  72. package/dist/{chunk-HPWLIYRL.js → chunk-REDPQ7F6.js} +14 -14
  73. package/dist/{chunk-OVXYX47B.cjs → chunk-TIYVK2BE.cjs} +19 -19
  74. package/dist/{chunk-OVXYX47B.cjs.map → chunk-TIYVK2BE.cjs.map} +1 -1
  75. package/dist/{chunk-UPKZU6QU.cjs → chunk-U2YLMFJK.cjs} +1 -1
  76. package/dist/{chunk-UPKZU6QU.cjs.map → chunk-U2YLMFJK.cjs.map} +1 -1
  77. package/dist/{chunk-7Q5XXPCB.js → chunk-UF5VXOVZ.js} +14 -14
  78. package/dist/{chunk-65EVGKFV.cjs → chunk-UOOA73XL.cjs} +14 -14
  79. package/dist/{chunk-65EVGKFV.cjs.map → chunk-UOOA73XL.cjs.map} +1 -1
  80. package/dist/{chunk-CCWI3622.cjs → chunk-VTYP25OW.cjs} +4 -4
  81. package/dist/{chunk-CCWI3622.cjs.map → chunk-VTYP25OW.cjs.map} +1 -1
  82. package/dist/{chunk-RB6L5EGM.cjs → chunk-WDFDZSAK.cjs} +1131 -1131
  83. package/dist/{chunk-RB6L5EGM.cjs.map → chunk-WDFDZSAK.cjs.map} +1 -1
  84. package/dist/{chunk-T3C3JLGV.cjs → chunk-WKX7DYFM.cjs} +8 -8
  85. package/dist/{chunk-T3C3JLGV.cjs.map → chunk-WKX7DYFM.cjs.map} +1 -1
  86. package/dist/{chunk-S2KMNFFN.js → chunk-WWPANZTL.js} +7 -7
  87. package/dist/chunk-X7CEWD6V.cjs +20 -0
  88. package/dist/chunk-X7CEWD6V.cjs.map +1 -0
  89. package/dist/{chunk-5JUTGEZE.js → chunk-XBTZOO74.js} +2 -2
  90. package/dist/{chunk-RWURXICE.cjs → chunk-XGD6SCHN.cjs} +44 -44
  91. package/dist/{chunk-RWURXICE.cjs.map → chunk-XGD6SCHN.cjs.map} +1 -1
  92. package/dist/{chunk-EHAYNUOL.cjs → chunk-XOGD2AME.cjs} +3 -3
  93. package/dist/{chunk-EHAYNUOL.cjs.map → chunk-XOGD2AME.cjs.map} +1 -1
  94. package/dist/{chunk-N6HNK25A.cjs → chunk-YWUZL3RT.cjs} +11 -11
  95. package/dist/{chunk-N6HNK25A.cjs.map → chunk-YWUZL3RT.cjs.map} +1 -1
  96. package/dist/{chunk-LZYPSDFE.cjs → chunk-ZC7BVCDJ.cjs} +90 -90
  97. package/dist/{chunk-LZYPSDFE.cjs.map → chunk-ZC7BVCDJ.cjs.map} +1 -1
  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 +1 -1
  103. package/dist/components/chat/index.cjs +9 -9
  104. package/dist/components/chat/index.js +8 -8
  105. package/dist/components/chat/utils/source-row-cta.d.ts +1 -1
  106. package/dist/components/command.d.ts +7 -7
  107. package/dist/components/contact/index.cjs +15 -15
  108. package/dist/components/contact/index.js +14 -14
  109. package/dist/components/docs/index.cjs +18 -18
  110. package/dist/components/docs/index.js +17 -17
  111. package/dist/components/embeds/index.cjs +15 -15
  112. package/dist/components/embeds/index.js +14 -14
  113. package/dist/components/faq/index.cjs +16 -16
  114. package/dist/components/faq/index.js +15 -15
  115. package/dist/components/features/index.cjs +14 -14
  116. package/dist/components/features/index.js +13 -13
  117. package/dist/components/help-center-pages/index.cjs +37 -37
  118. package/dist/components/help-center-pages/index.js +28 -28
  119. package/dist/components/icons/index.cjs +3 -3
  120. package/dist/components/icons/index.js +2 -2
  121. package/dist/components/index.cjs +115 -115
  122. package/dist/components/index.cjs.map +1 -1
  123. package/dist/components/index.js +31 -31
  124. package/dist/components/index.js.map +1 -1
  125. package/dist/components/meeting-scheduler/index.cjs +119 -119
  126. package/dist/components/meeting-scheduler/index.js +15 -15
  127. package/dist/components/navigation/index.cjs +17 -17
  128. package/dist/components/navigation/index.js +16 -16
  129. package/dist/components/onboarding-guides/index.cjs +18 -18
  130. package/dist/components/onboarding-guides/index.js +17 -17
  131. package/dist/components/related-content/index.cjs +10 -10
  132. package/dist/components/related-content/index.js +9 -9
  133. package/dist/components/resizable.d.ts +1 -1
  134. package/dist/components/tickets/index.cjs +19 -19
  135. package/dist/components/tickets/index.js +18 -18
  136. package/dist/components/ui/file-manager/index.cjs +57 -57
  137. package/dist/components/ui/file-manager/index.js +4 -4
  138. package/dist/components/ui/index.cjs +14 -14
  139. package/dist/components/ui/index.js +13 -13
  140. package/dist/contexts/chat-runtime-context.d.ts +1 -1
  141. package/dist/contexts/index.cjs +2 -2
  142. package/dist/contexts/index.js +1 -1
  143. package/dist/hooks/index.cjs +7 -7
  144. package/dist/hooks/index.js +6 -6
  145. package/dist/index.cjs +36 -28
  146. package/dist/index.cjs.map +1 -1
  147. package/dist/index.js +30 -22
  148. package/dist/index.js.map +1 -1
  149. package/dist/platform-domains.cjs +43 -0
  150. package/dist/platform-domains.cjs.map +1 -1
  151. package/dist/platform-domains.d.ts +59 -4
  152. package/dist/platform-domains.d.ts.map +1 -1
  153. package/dist/platform-domains.js +39 -1
  154. package/dist/platform-domains.js.map +1 -1
  155. package/dist/types/index.cjs +0 -104
  156. package/dist/types/index.cjs.map +1 -1
  157. package/dist/types/index.js +0 -104
  158. package/dist/types/index.js.map +1 -1
  159. package/dist/utils/cn.d.ts +0 -21
  160. package/dist/utils/cn.d.ts.map +1 -1
  161. package/dist/utils/index.cjs +53 -25
  162. package/dist/utils/index.cjs.map +1 -1
  163. package/dist/utils/index.d.ts +1 -2
  164. package/dist/utils/index.d.ts.map +1 -1
  165. package/dist/utils/index.js +49 -25
  166. package/dist/utils/index.js.map +1 -1
  167. package/package.json +1 -1
  168. package/src/__tests__/platform-domains.test.ts +116 -0
  169. package/src/components/chat/embeddable-chat.tsx +2 -2
  170. package/src/components/chat/utils/__tests__/source-row-cta.test.ts +2 -2
  171. package/src/components/chat/utils/source-row-cta.ts +4 -4
  172. package/src/components/made-with-love.tsx +2 -2
  173. package/src/contexts/chat-runtime-context.tsx +1 -1
  174. package/src/platform-domains.ts +96 -4
  175. package/src/utils/.cn.md +3 -23
  176. package/src/utils/cn.ts +0 -47
  177. package/src/utils/index.ts +9 -2
  178. package/dist/chunk-23V5BSHD.cjs +0 -169
  179. package/dist/chunk-23V5BSHD.cjs.map +0 -1
  180. package/dist/chunk-CBXZSTAG.cjs.map +0 -1
  181. package/dist/chunk-I57XLISO.js.map +0 -1
  182. package/dist/chunk-O4MCCKKN.js +0 -169
  183. package/dist/chunk-O4MCCKKN.js.map +0 -1
  184. /package/dist/{chunk-IXD6SHQ6.js.map → chunk-2SNL36JV.js.map} +0 -0
  185. /package/dist/{chunk-FOSIR4QF.js.map → chunk-3DWDJ54N.js.map} +0 -0
  186. /package/dist/{chunk-4EEUB62O.js.map → chunk-4HVWGYHI.js.map} +0 -0
  187. /package/dist/{chunk-G5U4JP45.js.map → chunk-5ONM3FHQ.js.map} +0 -0
  188. /package/dist/{chunk-KJWPAJRT.js.map → chunk-7EI3NES7.js.map} +0 -0
  189. /package/dist/{chunk-27RD5XTP.js.map → chunk-CYXV5HPV.js.map} +0 -0
  190. /package/dist/{chunk-4WVWRFGP.js.map → chunk-DEIYPXGD.js.map} +0 -0
  191. /package/dist/{chunk-TTVOBWAH.js.map → chunk-EADBLRNF.js.map} +0 -0
  192. /package/dist/{chunk-MRIOYSXH.js.map → chunk-EBDCDHOT.js.map} +0 -0
  193. /package/dist/{chunk-RNMGKAS6.js.map → chunk-EDNZ2HN3.js.map} +0 -0
  194. /package/dist/{chunk-KEKN76JR.js.map → chunk-FRQ2DE5Z.js.map} +0 -0
  195. /package/dist/{chunk-JOV64HW5.js.map → chunk-GRBZC5N3.js.map} +0 -0
  196. /package/dist/{chunk-LPMDCQLL.js.map → chunk-H3EJDISW.js.map} +0 -0
  197. /package/dist/{chunk-3DGRXC74.js.map → chunk-HQBC7YRF.js.map} +0 -0
  198. /package/dist/{chunk-VE52MSYC.js.map → chunk-IERXOVIS.js.map} +0 -0
  199. /package/dist/{chunk-KOLVBEW5.js.map → chunk-IWISVG4P.js.map} +0 -0
  200. /package/dist/{chunk-F2KBCLUG.js.map → chunk-KKSSA4CS.js.map} +0 -0
  201. /package/dist/{chunk-FKBM6U43.js.map → chunk-LZLT67PE.js.map} +0 -0
  202. /package/dist/{chunk-B3Z3RJRW.js.map → chunk-M4AD2PHE.js.map} +0 -0
  203. /package/dist/{chunk-BVQEU5JB.js.map → chunk-MT5A25AX.js.map} +0 -0
  204. /package/dist/{chunk-UEXIMEVU.js.map → chunk-N7IAE3DN.js.map} +0 -0
  205. /package/dist/{chunk-HOGOQA2X.js.map → chunk-O7LA444D.js.map} +0 -0
  206. /package/dist/{chunk-PFV4DAX5.js.map → chunk-OBBAT4AU.js.map} +0 -0
  207. /package/dist/{chunk-SKABQX44.js.map → chunk-QP7Z4EN7.js.map} +0 -0
  208. /package/dist/{chunk-HPWLIYRL.js.map → chunk-REDPQ7F6.js.map} +0 -0
  209. /package/dist/{chunk-7Q5XXPCB.js.map → chunk-UF5VXOVZ.js.map} +0 -0
  210. /package/dist/{chunk-S2KMNFFN.js.map → chunk-WWPANZTL.js.map} +0 -0
  211. /package/dist/{chunk-5JUTGEZE.js.map → chunk-XBTZOO74.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-2219.6362.1",
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,117 @@ 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', () => {
237
+ expect(getRequestOrigin(headers({ host: 'www.flamingo.run' }))).toBe('https://www.flamingo.run');
238
+ expect(getRequestOrigin(headers({ host: 'localhost:3000' }))).toBe('http://localhost:3000');
239
+ expect(getRequestOrigin(headers({ host: '[::1]:3000' }))).toBe('http://[::1]:3000');
240
+ expect(getRequestOrigin(headers({ host: 'x.vercel.app', 'x-forwarded-proto': 'https' }))).toBe(
241
+ 'https://x.vercel.app',
242
+ );
243
+ expect(getRequestOrigin(headers({ host: 'www.flamingo.run', 'x-forwarded-host': 'evil.example' }))).toBe(
244
+ 'https://www.flamingo.run',
245
+ );
246
+ expect(getRequestOrigin(headers({}))).toBeNull();
247
+ });
248
+
249
+ it.each([
250
+ ['http://localhost:3000', true],
251
+ ['http://127.0.0.1:3000/x', true],
252
+ ['http://0.0.0.0', true],
253
+ ['http://[::1]:3000', true],
254
+ ['https://www.flamingo.run', false],
255
+ ['https://localhost.example.com', false],
256
+ ['http://127.evil.example', false],
257
+ ['not a url', false],
258
+ ])('isLocalUrl(%s) → %s', (url, local) => expect(isLocalUrl(url)).toBe(local));
259
+
260
+ it('resolves same-origin paths and passes explicit absolute URLs through', () => {
261
+ const origin = 'https://flamingo-abc123-flamingocx.vercel.app';
262
+ expect(resolveRedirectTarget(origin, '/admin/x?y=1').href).toBe(`${origin}/admin/x?y=1`);
263
+ expect(resolveRedirectTarget(origin, 'auth/callback-client').href).toBe(`${origin}/auth/callback-client`);
264
+ expect(resolveRedirectTarget(origin, 'https://www.flamingo.run/blog').href).toBe('https://www.flamingo.run/blog');
265
+ });
266
+
267
+ it.each(['//evil.example/path', '/\\evil.example/path', '\\\\evil.example', '\\/evil.example'])(
268
+ 'refuses %s, which would leave the origin',
269
+ target => {
270
+ expect(() => resolveRedirectTarget('https://www.flamingo.run', target)).toThrow('is not a same-origin path');
271
+ },
272
+ );
273
+ });
274
+
159
275
  describe('registry integrity', () => {
160
276
  it('byKey resolves every key and openframe-dashboard is pseudo', () => {
161
277
  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).
@@ -1439,7 +1439,7 @@ function EmbeddableChatInner({
1439
1439
  // doesn't host an in-app doc viewer should NOT pass an empty baseRoute (that just
1440
1440
  // falls back to the platform default here) — instead it sets a truthy baseRoute +
1441
1441
  // `chipBasePlatform` so doc chips with no externalUrl resolve cross-platform to that
1442
- // platform's public knowledge hub (`getBaseUrl(chipBasePlatform)/knowledge-base/…`),
1442
+ // platform's public knowledge hub (`getPlatformUrl(chipBasePlatform)/knowledge-base/…`),
1443
1443
  // exactly like the hub's openframe config (baseRoute:'/', chipBasePlatform:'openframe').
1444
1444
  const resolvedBaseRoute = baseRoute || (source === 'flamingo' ? '/knowledge-base' : '/data-room');
1445
1445
 
@@ -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,99 @@ 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
+ * `null` when there is no Host header; the caller decides the fallback.
213
+ */
214
+ export function getRequestOrigin(headers: { get(name: string): string | null }): string | null {
215
+ const host = headers.get('host');
216
+ if (!host) return null;
217
+ const local = LOCAL_HOSTNAME.test(host.replace(/:\d+$/, ''));
218
+ const proto = headers.get('x-forwarded-proto')?.split(',')[0].trim() || (local ? 'http' : 'https');
219
+ return `${proto}://${host}`;
220
+ }
221
+
222
+ /**
223
+ * Where a redirect goes: a path resolves against `origin`; an explicit absolute
224
+ * `http(s)://` URL is used as is. THROWS when a relative target resolves to another
225
+ * origin (`//evil.example`, `/\\evil.example`), so a shared redirect helper built on it
226
+ * can never be an open redirect.
227
+ */
228
+ export function resolveRedirectTarget(origin: string, target: string): URL {
229
+ const url = new URL(target, origin);
230
+ if (!/^https?:\/\//i.test(target) && url.origin !== new URL(origin).origin) {
231
+ throw new Error(`resolveRedirectTarget: "${target}" is not a same-origin path`);
232
+ }
233
+ return url;
234
+ }
235
+
144
236
  // ── Single-owner host primitives ──
145
237
 
146
238
  /** 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';
@@ -1,169 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
-
3
- // src/platform-domains.ts
4
- var PLATFORM_DOMAINS = [
5
- { key: "marketing-hub", defaultUrl: "https://marketing-hub.flamingo.so", envVar: "NEXT_PUBLIC_MARKETING_HUB_URL" },
6
- { key: "company-hub", defaultUrl: "https://company-hub.flamingo.so", envVar: "NEXT_PUBLIC_COMPANY_HUB_URL" },
7
- { key: "product-hub", defaultUrl: "https://product-hub.flamingo.so", envVar: "NEXT_PUBLIC_PRODUCT_HUB_URL" },
8
- { key: "revenue-hub", defaultUrl: "https://revenue-hub.flamingo.so", envVar: "NEXT_PUBLIC_REVENUE_HUB_URL" },
9
- { key: "people-hub", defaultUrl: "https://people-hub.flamingo.so", envVar: "NEXT_PUBLIC_PEOPLE_HUB_URL" },
10
- { key: "openmsp", defaultUrl: "https://www.openmsp.ai", envVar: "NEXT_PUBLIC_OPENMSP_URL" },
11
- // ORDERING INVARIANT (first-wins, load-bearing): `flamingo` MUST precede `flamingo-teaser` + `universal`.
12
- // All three resolve to www.flamingo.run; the reverse index is first-wins → flamingo claims the shared host,
13
- // teaser keeps only its unique flamingo.cx aliases, universal contributes no unique host.
14
- // ⚠️ DO NOT REORDER — enforced by the module-load self-check at the bottom of this file.
15
- { key: "flamingo", defaultUrl: "https://www.flamingo.run", envVar: "NEXT_PUBLIC_FLAMINGO_URL" },
16
- { key: "tmcg", defaultUrl: "https://www.tmcg.miami", envVar: "NEXT_PUBLIC_TMCG_URL" },
17
- { key: "mlg", defaultUrl: "https://www.mlg.soccer", envVar: "NEXT_PUBLIC_MLG_URL" },
18
- {
19
- key: "flamingo-teaser",
20
- defaultUrl: "https://www.flamingo.run",
21
- envVar: "NEXT_PUBLIC_FLAMINGO_URL",
22
- aliasHostnames: ["flamingo.cx", "www.flamingo.cx"]
23
- },
24
- {
25
- key: "openframe",
26
- defaultUrl: "https://openframe.ai",
27
- envVar: "NEXT_PUBLIC_OPENFRAME_URL",
28
- aliasHostnames: ["openframe.ai", "www.openframe.ai", "hub.openframe.ai"]
29
- },
30
- {
31
- key: "openframe-dashboard",
32
- defaultUrl: "https://openframe.ai",
33
- envVar: "NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL",
34
- pseudo: true
35
- },
36
- { key: "universal", defaultUrl: "https://www.flamingo.run", envVar: "NEXT_PUBLIC_FLAMINGO_URL" }
37
- ];
38
- var ENV_OVERRIDES = {
39
- NEXT_PUBLIC_MARKETING_HUB_URL: process.env.NEXT_PUBLIC_MARKETING_HUB_URL,
40
- NEXT_PUBLIC_COMPANY_HUB_URL: process.env.NEXT_PUBLIC_COMPANY_HUB_URL,
41
- NEXT_PUBLIC_PRODUCT_HUB_URL: process.env.NEXT_PUBLIC_PRODUCT_HUB_URL,
42
- NEXT_PUBLIC_REVENUE_HUB_URL: process.env.NEXT_PUBLIC_REVENUE_HUB_URL,
43
- NEXT_PUBLIC_PEOPLE_HUB_URL: process.env.NEXT_PUBLIC_PEOPLE_HUB_URL,
44
- NEXT_PUBLIC_OPENMSP_URL: process.env.NEXT_PUBLIC_OPENMSP_URL,
45
- NEXT_PUBLIC_FLAMINGO_URL: process.env.NEXT_PUBLIC_FLAMINGO_URL,
46
- NEXT_PUBLIC_TMCG_URL: process.env.NEXT_PUBLIC_TMCG_URL,
47
- NEXT_PUBLIC_MLG_URL: process.env.NEXT_PUBLIC_MLG_URL,
48
- NEXT_PUBLIC_OPENFRAME_URL: process.env.NEXT_PUBLIC_OPENFRAME_URL,
49
- NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL: process.env.NEXT_PUBLIC_OPENFRAME_DASHBOARD_URL
50
- };
51
- function byKey(key) {
52
- return PLATFORM_DOMAINS.find((e) => e.key === key);
53
- }
54
- function envOverrideFor(key) {
55
- const envVar = _optionalChain([byKey, 'call', _ => _(key), 'optionalAccess', _2 => _2.envVar]);
56
- if (!envVar) return null;
57
- return ENV_OVERRIDES[envVar] || null;
58
- }
59
- function ensureScheme(url) {
60
- const trimmed = url.trim();
61
- if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) return trimmed;
62
- return `https://${trimmed.replace(/^\/+/, "")}`;
63
- }
64
- function getPlatformProductionUrl(platform) {
65
- const resolved = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(envOverrideFor(platform), () => ( _optionalChain([byKey, 'call', _3 => _3(platform), 'optionalAccess', _4 => _4.defaultUrl]))), () => ( envOverrideFor("flamingo"))), () => ( "https://www.flamingo.run"));
66
- return ensureScheme(resolved);
67
- }
68
- function hostOf(value) {
69
- if (!value) return null;
70
- try {
71
- return new URL(value).hostname.toLowerCase();
72
- } catch (e2) {
73
- return null;
74
- }
75
- }
76
- function expandWwwApex(host) {
77
- if (host.startsWith("www.")) return [host, host.slice(4)];
78
- if (host.split(".").length === 2) return [host, `www.${host}`];
79
- return [host];
80
- }
81
- function toRegistrableBaseDomain(host) {
82
- const parts = host.split(".");
83
- if (parts.length >= 2) return parts.slice(-2).join(".");
84
- return void 0;
85
- }
86
- function aliasHostsOf(key) {
87
- return _nullishCoalesce(_optionalChain([byKey, 'call', _5 => _5(key), 'optionalAccess', _6 => _6.aliasHostnames]), () => ( []));
88
- }
89
- function hostsForEntry(entry, opts) {
90
- const resolved = hostOf(getPlatformProductionUrl(entry.key));
91
- const hosts = resolved ? expandWwwApex(resolved) : [];
92
- if (opts.includeAliases) hosts.push(...aliasHostsOf(entry.key));
93
- return hosts;
94
- }
95
- function getPlatformByHostname(hostname) {
96
- const host = hostname.toLowerCase();
97
- for (const entry of PLATFORM_DOMAINS) {
98
- if (entry.pseudo) continue;
99
- if (hostsForEntry(entry, { includeAliases: true }).includes(host)) return entry.key;
100
- }
101
- return null;
102
- }
103
- function isPreviewHost(hostname) {
104
- return hostname.endsWith(".vercel.app");
105
- }
106
- function getAllPlatformBaseDomains() {
107
- if (typeof window === "undefined") return [];
108
- const hostname = window.location.hostname;
109
- if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("127.")) {
110
- return [];
111
- }
112
- const previewEnv = process.env.VERCEL_ENV === "preview" || process.env.NEXT_PUBLIC_VERCEL_ENV === "preview" || isPreviewHost(hostname);
113
- if (previewEnv) {
114
- return [".vercel.app", "vercel.app"];
115
- }
116
- const baseDomains = /* @__PURE__ */ new Set();
117
- for (const entry of PLATFORM_DOMAINS) {
118
- if (entry.pseudo) continue;
119
- const host = hostOf(getPlatformProductionUrl(entry.key));
120
- if (!host) continue;
121
- const base = toRegistrableBaseDomain(host);
122
- if (base) {
123
- baseDomains.add(`.${base}`);
124
- baseDomains.add(base);
125
- }
126
- }
127
- return Array.from(baseDomains);
128
- }
129
- var _orderIdx = (k) => PLATFORM_DOMAINS.findIndex((e) => e.key === k);
130
- if (_orderIdx("flamingo") > _orderIdx("flamingo-teaser") || _orderIdx("flamingo") > _orderIdx("universal") || getPlatformByHostname("flamingo.cx") !== "flamingo-teaser" || getPlatformByHostname("hub.openframe.ai") !== "openframe") {
131
- console.error(
132
- "[platform-domains] \u26A0\uFE0F PLATFORM_DOMAINS ordering invariant violated \u2014 `flamingo` must precede `flamingo-teaser`/`universal`, and the openframe/teaser aliases must be intact. Do not reorder the table."
133
- );
134
- }
135
-
136
- // src/utils/cn.ts
137
- var _clsx = require('clsx');
138
- var _tailwindmerge = require('tailwind-merge');
139
- var twMerge = _tailwindmerge.extendTailwindMerge.call(void 0, {
140
- extend: {
141
- classGroups: {
142
- "ods-typography": ["text-h1", "text-h2", "text-h3", "text-h4", "text-h5", "text-h6", "text-code", "text-badge"]
143
- }
144
- }
145
- });
146
- function cn(...inputs) {
147
- return twMerge(_clsx.clsx.call(void 0, inputs));
148
- }
149
- function getBaseUrl(platform) {
150
- if (process.env.NODE_ENV !== "production") {
151
- return process.env.NEXT_PUBLIC_DEV_URL || "http://localhost:3000";
152
- }
153
- if (platform) {
154
- return getPlatformProductionUrl(platform);
155
- }
156
- if (process.env.VERCEL_PROJECT_PRODUCTION_URL) {
157
- return `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`;
158
- }
159
- return getPlatformProductionUrl(process.env.NEXT_PUBLIC_APP_TYPE || "openmsp");
160
- }
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
- exports.byKey = byKey; exports.getPlatformProductionUrl = getPlatformProductionUrl; exports.getAllPlatformBaseDomains = getAllPlatformBaseDomains; exports.cn = cn; exports.getBaseUrl = getBaseUrl;
169
- //# sourceMappingURL=chunk-23V5BSHD.cjs.map