@flamingo-stack/openframe-frontend-core 0.0.820 → 0.0.822

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 (73) hide show
  1. package/dist/build/export-map.json +1 -1
  2. package/dist/chat-protocol/citation-chip.d.ts +20 -0
  3. package/dist/chat-protocol/citation-chip.d.ts.map +1 -0
  4. package/dist/chat-protocol/citation-chip.js +25 -0
  5. package/dist/chat-protocol/index.cjs +25 -0
  6. package/dist/chat-protocol/index.d.ts +1 -0
  7. package/dist/chat-protocol/index.d.ts.map +1 -1
  8. package/dist/chat-protocol/index.js +1 -0
  9. package/dist/{chunk-OTGYA5F7.cjs → chunk-2LT2WR4O.cjs} +57 -46
  10. package/dist/{chunk-K5IICQNF.cjs → chunk-2YUWBIZM.cjs} +46 -46
  11. package/dist/{chunk-NSN3O47K.cjs → chunk-3BW6PEAB.cjs} +32 -32
  12. package/dist/{chunk-L55EVW33.cjs → chunk-6UVOL3ZF.cjs} +6 -6
  13. package/dist/{chunk-IJ3C4WL5.cjs → chunk-BN535RBR.cjs} +55 -55
  14. package/dist/{chunk-MOPDE3OA.cjs → chunk-D5JSCXSL.cjs} +13 -13
  15. package/dist/{chunk-JQ3JZLYS.cjs → chunk-DYSMAPSI.cjs} +4 -4
  16. package/dist/{chunk-7X7PHALX.cjs → chunk-ECLKFEZP.cjs} +11 -11
  17. package/dist/{chunk-DLQCSJTY.cjs → chunk-FQQDI3UN.cjs} +3 -3
  18. package/dist/{chunk-5GUQBNQF.cjs → chunk-GA2PYQLC.cjs} +63 -63
  19. package/dist/{chunk-UDLDXVY4.cjs → chunk-GBILLSRM.cjs} +4 -4
  20. package/dist/{chunk-BHJDQYUN.cjs → chunk-M6PCHMRI.cjs} +131 -131
  21. package/dist/{chunk-TYDSD3FV.cjs → chunk-N6X5H3JM.cjs} +4 -4
  22. package/dist/{chunk-TVOAFYT7.cjs → chunk-NSGD22VV.cjs} +39 -39
  23. package/dist/{chunk-IM366HS6.cjs → chunk-QCRJVO6Y.cjs} +78 -7
  24. package/dist/{chunk-YAY7Z42C.cjs → chunk-SBXL5EKE.cjs} +32 -97
  25. package/dist/{chunk-CJ7VHMPD.cjs → chunk-TJFVIJPV.cjs} +2 -2
  26. package/dist/{chunk-42K7MLVS.cjs → chunk-U643BWTQ.cjs} +30 -30
  27. package/dist/{chunk-STFOH6QU.cjs → chunk-U7CH53FT.cjs} +13 -13
  28. package/dist/{chunk-ADBZCDFX.cjs → chunk-UUFL4FDS.cjs} +14 -14
  29. package/dist/{chunk-LUID2IB3.cjs → chunk-XEIZL3I3.cjs} +2 -2
  30. package/dist/{chunk-2TEUAOUZ.cjs → chunk-YCWG63NR.cjs} +3 -3
  31. package/dist/{cloud-tenants-ENCHNOF2.cjs → cloud-tenants-AKMN4SU4.cjs} +6 -6
  32. package/dist/components/case-studies/index.cjs +20 -20
  33. package/dist/components/chat/index.cjs +5 -5
  34. package/dist/components/chat/remark-strip-citations.d.ts +3 -4
  35. package/dist/components/chat/remark-strip-citations.d.ts.map +1 -1
  36. package/dist/components/chat/remark-strip-citations.js +3 -13
  37. package/dist/components/chat/utils/cited-sources.d.ts.map +1 -1
  38. package/dist/components/chat/utils/cited-sources.js +2 -6
  39. package/dist/components/contact/index.cjs +7 -7
  40. package/dist/components/docs/index.cjs +10 -10
  41. package/dist/components/embeds/index.cjs +7 -7
  42. package/dist/components/faq/index.cjs +8 -8
  43. package/dist/components/features/index.cjs +6 -6
  44. package/dist/components/help-center-pages/index.cjs +80 -80
  45. package/dist/components/index.cjs +48 -48
  46. package/dist/components/meeting-scheduler/index.cjs +31 -31
  47. package/dist/components/navigation/index.cjs +9 -9
  48. package/dist/components/onboarding-guides/index.cjs +9 -9
  49. package/dist/components/product-demo/index.cjs +15 -15
  50. package/dist/components/related-content/index.cjs +4 -4
  51. package/dist/components/tickets/index.cjs +11 -11
  52. package/dist/components/ui/index.cjs +6 -6
  53. package/dist/contexts/chat-runtime-context.d.ts +4 -3
  54. package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
  55. package/dist/{devices-HRLHG4TR.cjs → devices-IHDA22KS.cjs} +7 -7
  56. package/dist/{embeddable-chat-ARMXVLUP.cjs → embeddable-chat-MQGYFYGX.cjs} +68 -72
  57. package/dist/index.cjs +17 -17
  58. package/dist/{knowledge-S2L5ZCAU.cjs → knowledge-JHSMUC6Y.cjs} +7 -7
  59. package/dist/{logs-UYQZSFS4.cjs → logs-7PMA2ARK.cjs} +14 -14
  60. package/dist/{policies-SMA4MW6L.cjs → policies-QNNZVXIS.cjs} +10 -10
  61. package/dist/{scripts-TZNXTFRR.cjs → scripts-LOMWOSQS.cjs} +11 -11
  62. package/dist/{software-update-YHDVBC7V.cjs → software-update-YF3VQIP4.cjs} +9 -9
  63. package/dist/utils/image-proxy.d.ts +3 -2
  64. package/dist/utils/image-proxy.d.ts.map +1 -1
  65. package/dist/utils/image-proxy.js +11 -4
  66. package/dist/utils/index.cjs +68 -62
  67. package/package.json +1 -1
  68. package/src/chat-protocol/citation-chip.ts +46 -0
  69. package/src/chat-protocol/index.ts +2 -0
  70. package/src/components/chat/remark-strip-citations.ts +7 -26
  71. package/src/components/chat/utils/cited-sources.ts +2 -8
  72. package/src/contexts/chat-runtime-context.tsx +4 -3
  73. package/src/utils/image-proxy.ts +17 -6
@@ -11,38 +11,23 @@
11
11
  *
12
12
  * Deliberately conservative:
13
13
  * - text leaves only (code/inline-code nodes are never visited);
14
- * - 1–2 digit indices, optionally comma-separated, and runs of them (`[1][2]`);
15
- * - the token must be delimiter-bounded on BOTH sides (start/whitespace
16
- * before; whitespace/punctuation/end after) so technical prose like
17
- * `array[1]` or `foo[12]bar` is untouched.
14
+ * - what counts as a citation is the chat protocol's one chip grammar
15
+ * (`chat-protocol/citation-chip.ts`), the same one the server writes, so
16
+ * technical prose like `array[1]` or `foo[12]bar` is untouched.
18
17
  */
19
18
 
20
19
  import type { Root, Text } from 'mdast';
21
20
  import type { Plugin } from 'unified';
22
21
  import { visit } from 'unist-util-visit';
23
-
24
- /** A run of citation markers (`[1]`, `[2, 3]`, `[1][2]`) bounded by whitespace or the start on the left and by
25
- * whitespace, punctuation or the end on the right. */
26
- const CITATION_REGEX = /(^|\s)(?:\[\d{1,2}(?:\s*,\s*\d{1,2})*\])+(?=[\s.,;:!?)\]]|$)/g;
27
-
28
- /** What a removed run leaves: nothing when punctuation or the end follows it (so "command [1]." reads "command."),
29
- * else the whitespace that preceded it. */
30
- function withoutRun(text: string): string {
31
- return text.replace(CITATION_REGEX, (run: string, lead: string, offset: number) => {
32
- const next = text.charAt(offset + run.length);
33
- return next === '' || /[.,;:!?)\]]/.test(next) ? '' : lead;
34
- });
35
- }
22
+ import { stripCitationChips } from '../../chat-protocol/citation-chip';
36
23
 
37
24
  export const remarkStripCitations: Plugin<[], Root> = () => {
38
25
  return (tree: Root) => {
39
26
  visit(tree, 'text', (node: Text, index, parent) => {
40
27
  if (!parent || typeof index !== 'number') return;
41
28
  if (!node.value || !node.value.includes('[')) return;
42
- const withoutCitations = withoutRun(node.value);
43
- // No citation matched → leave the node untouched, INCLUDING its
44
- // whitespace (collapsing unconditionally would rewrite deliberate
45
- // spacing in prose like `array[1] value`).
29
+ const withoutCitations = stripCitationChips(node.value);
30
+ // No citation matched → leave the node untouched.
46
31
  if (withoutCitations === node.value) return;
47
32
  // Replace the text node rather than editing `node.value` in place —
48
33
  // same idiom as remark-card-links / remark-mention-chips next door, and
@@ -50,11 +35,7 @@ export const remarkStripCitations: Plugin<[], Root> = () => {
50
35
  // `position` so source mapping survives. Length is unchanged, so the
51
36
  // walker needs no index steering: it has already captured the original
52
37
  // leaf and moves on to the next sibling, never re-entering this slot.
53
- parent.children.splice(index, 1, {
54
- ...node,
55
- // Collapse doubled spaces the removal can leave mid-sentence.
56
- value: withoutCitations.replace(/ {2,}/g, ' '),
57
- });
38
+ parent.children.splice(index, 1, { ...node, value: withoutCitations });
58
39
  });
59
40
  };
60
41
  };
@@ -1,4 +1,5 @@
1
1
  import { type CardReference, extractCardReferences } from '../../../chat-protocol/card-marker';
2
+ import { citedSourceNumbers } from '../../../chat-protocol/citation-chip';
2
3
  import { canonicalContentRefType } from '../../../utils/list-url';
3
4
  import { groupSourcesByTable } from '../../../utils/source-grouping';
4
5
  import type { ChatSource } from '../types/message.types';
@@ -14,9 +15,6 @@ export interface CitedSources {
14
15
  uncited: ChatSource[];
15
16
  }
16
17
 
17
- /** `[1]`, `[12]` — a citation marker in the answer body. */
18
- const CITATION = /\[(\d+)\]/g;
19
-
20
18
  /** Fenced blocks and inline code spans. */
21
19
  const CODE = /```[\s\S]*?```|~~~[\s\S]*?~~~|`[^`\n]*`/g;
22
20
 
@@ -63,11 +61,7 @@ export function splitCitedSources(sources: ChatSource[] | undefined, content: st
63
61
  const byCards = splitByCards(sources, extractCardReferences(withoutCode(content)));
64
62
  if (byCards.cited.length > 0) return byCards;
65
63
 
66
- const firstMentionAt = new Map<number, number>();
67
- for (const match of withoutCode(content).matchAll(CITATION)) {
68
- const index = Number.parseInt(match[1], 10);
69
- if (!firstMentionAt.has(index)) firstMentionAt.set(index, firstMentionAt.size);
70
- }
64
+ const firstMentionAt = new Map(citedSourceNumbers(withoutCode(content)).map((index, order) => [index, order]));
71
65
 
72
66
  const cited = sources
73
67
  .filter(source => firstMentionAt.has(source.index))
@@ -155,9 +155,10 @@ export interface ChatRuntime {
155
155
  * directly cross-origin (CORS-permitting). */
156
156
  imageProxyUrlPrefix?: string;
157
157
  /** Optional list of hostnames that should bypass the image proxy
158
- * (rendered direct). Hub uses ['openmsp.ai']; embedders typically
159
- * leave it unset. Matches the `skipDomains` parameter of
160
- * `getProxiedImageUrl`. */
158
+ * (rendered direct), each matching its exact host and its subdomains.
159
+ * Hub uses ['openmsp.ai', <its Supabase project host>]; an embedder
160
+ * that shows the hub's content lists the same project host. Matches
161
+ * the `skipDomains` parameter of `getProxiedImageUrl`. */
161
162
  imageProxySkipDomains?: string[];
162
163
  /** Optional base URL for the branded og-placeholder image route — the
163
164
  * DEFAULT cover-image fallback for entity cards with no image. The lib
@@ -11,6 +11,8 @@
11
11
  * proxy config through (typically from `ChatRuntime.endpoints.imageProxyUrlPrefix`).
12
12
  */
13
13
 
14
+ import { hostMatches } from './social-platforms';
15
+
14
16
  export type GetProxiedImageUrlOptions = {
15
17
  /**
16
18
  * URL prefix for the image proxy (`<prefix>?url=<encoded>`). When unset,
@@ -21,8 +23,9 @@ export type GetProxiedImageUrlOptions = {
21
23
  /**
22
24
  * Domains that should bypass the proxy (e.g. own-CDN hosts whose
23
25
  * `Content-Type` is reliable and that already serve CORS-permitting
24
- * headers). Matched as `imageUrl.includes(domain)` so subdomains
25
- * inherit. Default: `[]`.
26
+ * headers). Matched against the URL's host, exact or a subdomain of it
27
+ * (`hostMatches`), so a domain named anywhere else in the URL does not
28
+ * count. A `host:port` entry matches that port. Default: `[]`.
26
29
  */
27
30
  skipDomains?: string[];
28
31
  /**
@@ -34,6 +37,15 @@ export type GetProxiedImageUrlOptions = {
34
37
  directHttps?: boolean;
35
38
  };
36
39
 
40
+ /** The URL's `host` (with a non-default port, unlike `hostOf`), null when it does not parse. */
41
+ function urlHost(url: string): string | null {
42
+ try {
43
+ return new URL(url).host;
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+
37
49
  /**
38
50
  * Resolve an external image URL through (or around) the image proxy.
39
51
  *
@@ -78,10 +90,9 @@ export function getProxiedImageUrl(imageUrl: string | null, options?: GetProxied
78
90
  }
79
91
 
80
92
  // (5) Skip-list match.
81
- for (const domain of skipDomains) {
82
- if (imageUrl.includes(domain)) {
83
- return imageUrl;
84
- }
93
+ const host = urlHost(imageUrl);
94
+ if (skipDomains.some(domain => hostMatches(host, domain))) {
95
+ return imageUrl;
85
96
  }
86
97
 
87
98
  // (6) Proxy.