@matterfact/embed 0.8.0 → 0.9.0

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 (40) hide show
  1. package/README.md +72 -0
  2. package/dist/{chunk-PNSYFXXU.js → chunk-6EM7T2JV.js} +27 -2
  3. package/dist/chunk-6EM7T2JV.js.map +1 -0
  4. package/dist/{chunk-UD7CAQXV.js → chunk-BKKXHSYU.js} +2 -2
  5. package/dist/chunk-FEXG4LQJ.js +3 -0
  6. package/dist/chunk-FEXG4LQJ.js.map +7 -0
  7. package/dist/chunk-NWNMS34P.js +2 -0
  8. package/dist/{chunk-R2ZEJARX.js → chunk-URGQBG4I.js} +28 -4
  9. package/dist/chunk-URGQBG4I.js.map +1 -0
  10. package/dist/context-ACFBWIFH.js +3 -0
  11. package/dist/{context-ARBB2XD6.js.map → context-ACFBWIFH.js.map} +1 -1
  12. package/dist/{context-MVGSYIMB.js → context-U2HJJN2S.js} +4 -2
  13. package/dist/embed.js +1 -1
  14. package/dist/embed.js.map +2 -2
  15. package/dist/index.cjs +29 -1
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +60 -2
  18. package/dist/index.d.ts +60 -2
  19. package/dist/index.js +5 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/react.cjs +40 -2
  22. package/dist/react.cjs.map +1 -1
  23. package/dist/react.d.cts +49 -1
  24. package/dist/react.d.ts +49 -1
  25. package/dist/react.js +16 -3
  26. package/dist/react.js.map +1 -1
  27. package/dist/{snapshot-UGTXZVB6.js → snapshot-4GXT6PKZ.js} +2 -2
  28. package/dist/{snapshot-GL4YBMXD.js → snapshot-Y75SCGCM.js} +3 -3
  29. package/dist/{snapshot-GL4YBMXD.js.map → snapshot-Y75SCGCM.js.map} +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-PNSYFXXU.js.map +0 -1
  32. package/dist/chunk-R2ZEJARX.js.map +0 -1
  33. package/dist/chunk-UQCETVRF.js +0 -2
  34. package/dist/chunk-W52Q7G4J.js +0 -3
  35. package/dist/chunk-W52Q7G4J.js.map +0 -7
  36. package/dist/context-ARBB2XD6.js +0 -3
  37. /package/dist/{chunk-UD7CAQXV.js.map → chunk-BKKXHSYU.js.map} +0 -0
  38. /package/dist/{chunk-UQCETVRF.js.map → chunk-NWNMS34P.js.map} +0 -0
  39. /package/dist/{context-MVGSYIMB.js.map → context-U2HJJN2S.js.map} +0 -0
  40. /package/dist/{snapshot-UGTXZVB6.js.map → snapshot-4GXT6PKZ.js.map} +0 -0
package/dist/react.d.cts CHANGED
@@ -24,6 +24,43 @@ interface PageEntity {
24
24
  text?: string;
25
25
  data?: Record<string, unknown>;
26
26
  }
27
+ /**
28
+ * How a route's content is classified, for the annotated site map.
29
+ *
30
+ * The host DECORATES the site map we auto-derive (see `SiteMapEntry`) so the agent
31
+ * knows which routes carry MATTERFACT content and of what kind — app-wide awareness
32
+ * it can navigate toward. This is CLASSIFICATION only: no per-instance ids, and never
33
+ * a capability token. The concrete artifact/document on the CURRENT page still arrives
34
+ * via `host.context` entities / `host.artifactGrants`, resolved per page.
35
+ *
36
+ * - `mf-artifact` — a co-embedded matterfact artifact (its slug); the token stays on
37
+ * the live iframe / grant, never here.
38
+ * - `mf-document` — a matterfact document (dossier/report), resolved to an MF_DOC_ID
39
+ * host-side per page.
40
+ * - `host-data` — the host's own data; not a matterfact entity.
41
+ */
42
+ type ContentClass = {
43
+ kind: 'mf-artifact';
44
+ slug: string;
45
+ } | {
46
+ kind: 'mf-document';
47
+ doctype: string;
48
+ } | {
49
+ kind: 'host-data';
50
+ };
51
+ /**
52
+ * One route in the annotated site map: the path pattern + label we derived, plus the
53
+ * host's content classification. `current` marks the route the user is on.
54
+ */
55
+ interface SiteMapEntry {
56
+ /** Route pattern or path, e.g. '/app/company/:ticker/dossier'. */
57
+ path: string;
58
+ /** Human label for the route ('Company Dossier'). */
59
+ label?: string;
60
+ /** The host's classification of this route's content, when it annotated it. */
61
+ content?: ContentClass;
62
+ current?: boolean;
63
+ }
27
64
 
28
65
  /**
29
66
  * The Hoist adapter — a pure transform from a `HoistRuntime` (already read out of
@@ -108,8 +145,19 @@ interface MatterfactAgentProps {
108
145
  * carry. See `writeActionsGlobal` below.
109
146
  */
110
147
  actions?: HoistActionsConfig;
148
+ /**
149
+ * The app's site map, annotated with each route's content class — so the agent knows
150
+ * which routes carry matterfact content (a co-embedded artifact, a document/report) or
151
+ * the host's own data, and can navigate toward them.
152
+ *
153
+ * Classification only: give the route pattern + label + a `content` tag; NEVER a
154
+ * capability token (the concrete artifact/document on the current page arrives via page
155
+ * context / the live iframe). Sugar over `window.matterfact.sitemap`, read by the loader
156
+ * on load and on navigation.
157
+ */
158
+ sitemap?: SiteMapEntry[];
111
159
  }
112
- declare function MatterfactAgent({ publishableKey, widgetOrigin, surface, theme, getAuthToken, getPageContext, inline, className, style, pageContext, dev, actions, }: MatterfactAgentProps): react_jsx_runtime.JSX.Element | null;
160
+ declare function MatterfactAgent({ publishableKey, widgetOrigin, surface, theme, getAuthToken, getPageContext, inline, className, style, pageContext, dev, actions, sitemap, }: MatterfactAgentProps): react_jsx_runtime.JSX.Element | null;
113
161
  interface MatterfactArtifactProps {
114
162
  /** The artifact's slug/name. */
115
163
  slug: string;
package/dist/react.d.ts CHANGED
@@ -24,6 +24,43 @@ interface PageEntity {
24
24
  text?: string;
25
25
  data?: Record<string, unknown>;
26
26
  }
27
+ /**
28
+ * How a route's content is classified, for the annotated site map.
29
+ *
30
+ * The host DECORATES the site map we auto-derive (see `SiteMapEntry`) so the agent
31
+ * knows which routes carry MATTERFACT content and of what kind — app-wide awareness
32
+ * it can navigate toward. This is CLASSIFICATION only: no per-instance ids, and never
33
+ * a capability token. The concrete artifact/document on the CURRENT page still arrives
34
+ * via `host.context` entities / `host.artifactGrants`, resolved per page.
35
+ *
36
+ * - `mf-artifact` — a co-embedded matterfact artifact (its slug); the token stays on
37
+ * the live iframe / grant, never here.
38
+ * - `mf-document` — a matterfact document (dossier/report), resolved to an MF_DOC_ID
39
+ * host-side per page.
40
+ * - `host-data` — the host's own data; not a matterfact entity.
41
+ */
42
+ type ContentClass = {
43
+ kind: 'mf-artifact';
44
+ slug: string;
45
+ } | {
46
+ kind: 'mf-document';
47
+ doctype: string;
48
+ } | {
49
+ kind: 'host-data';
50
+ };
51
+ /**
52
+ * One route in the annotated site map: the path pattern + label we derived, plus the
53
+ * host's content classification. `current` marks the route the user is on.
54
+ */
55
+ interface SiteMapEntry {
56
+ /** Route pattern or path, e.g. '/app/company/:ticker/dossier'. */
57
+ path: string;
58
+ /** Human label for the route ('Company Dossier'). */
59
+ label?: string;
60
+ /** The host's classification of this route's content, when it annotated it. */
61
+ content?: ContentClass;
62
+ current?: boolean;
63
+ }
27
64
 
28
65
  /**
29
66
  * The Hoist adapter — a pure transform from a `HoistRuntime` (already read out of
@@ -108,8 +145,19 @@ interface MatterfactAgentProps {
108
145
  * carry. See `writeActionsGlobal` below.
109
146
  */
110
147
  actions?: HoistActionsConfig;
148
+ /**
149
+ * The app's site map, annotated with each route's content class — so the agent knows
150
+ * which routes carry matterfact content (a co-embedded artifact, a document/report) or
151
+ * the host's own data, and can navigate toward them.
152
+ *
153
+ * Classification only: give the route pattern + label + a `content` tag; NEVER a
154
+ * capability token (the concrete artifact/document on the current page arrives via page
155
+ * context / the live iframe). Sugar over `window.matterfact.sitemap`, read by the loader
156
+ * on load and on navigation.
157
+ */
158
+ sitemap?: SiteMapEntry[];
111
159
  }
112
- declare function MatterfactAgent({ publishableKey, widgetOrigin, surface, theme, getAuthToken, getPageContext, inline, className, style, pageContext, dev, actions, }: MatterfactAgentProps): react_jsx_runtime.JSX.Element | null;
160
+ declare function MatterfactAgent({ publishableKey, widgetOrigin, surface, theme, getAuthToken, getPageContext, inline, className, style, pageContext, dev, actions, sitemap, }: MatterfactAgentProps): react_jsx_runtime.JSX.Element | null;
113
161
  interface MatterfactArtifactProps {
114
162
  /** The artifact's slug/name. */
115
163
  slug: string;
package/dist/react.js CHANGED
@@ -5,7 +5,7 @@
5
5
  import { useEffect, useRef } from "react";
6
6
 
7
7
  // src/protocol.ts
8
- var PROTOCOL_VERSION = 2;
8
+ var PROTOCOL_VERSION = 3;
9
9
  var CHANNEL = "mf-embed";
10
10
  function envelope(payload, id) {
11
11
  return {
@@ -575,6 +575,9 @@ var EmbedHost = class {
575
575
  case "widget.needsAuth":
576
576
  void this.provideAuth();
577
577
  break;
578
+ case "widget.navigate":
579
+ void this.loadContext().then((m) => m.navigateHost(msg.href));
580
+ break;
578
581
  }
579
582
  }
580
583
  /**
@@ -691,7 +694,7 @@ var EmbedHost = class {
691
694
  }
692
695
  }
693
696
  loadContext() {
694
- this.context ?? (this.context = import("./context-MVGSYIMB.js").then((m) => {
697
+ this.context ?? (this.context = import("./context-U2HJJN2S.js").then((m) => {
695
698
  m.start(
696
699
  this.send,
697
700
  this.config.origin,
@@ -739,6 +742,11 @@ function writeActionsGlobal(actions) {
739
742
  const mf = w.matterfact ?? (w.matterfact = {});
740
743
  mf.hoist = { ...mf.hoist, actions: actions ?? { navigate: "off" } };
741
744
  }
745
+ function writeSitemapGlobal(sitemap) {
746
+ if (typeof window === "undefined" || sitemap === void 0) return;
747
+ const w = window;
748
+ (w.matterfact ?? (w.matterfact = {})).sitemap = sitemap;
749
+ }
742
750
  function MatterfactAgent({
743
751
  publishableKey,
744
752
  widgetOrigin,
@@ -751,7 +759,8 @@ function MatterfactAgent({
751
759
  style,
752
760
  pageContext,
753
761
  dev,
754
- actions
762
+ actions,
763
+ sitemap
755
764
  }) {
756
765
  const authRef = useRef(getAuthToken);
757
766
  authRef.current = getAuthToken;
@@ -761,6 +770,10 @@ function MatterfactAgent({
761
770
  actionsRef.current = actions;
762
771
  const actionsKey = JSON.stringify(actions ?? null);
763
772
  const slot = useRef(null);
773
+ const sitemapKey = JSON.stringify(sitemap ?? null);
774
+ useEffect(() => {
775
+ writeSitemapGlobal(sitemap);
776
+ }, [sitemapKey]);
764
777
  useEffect(() => {
765
778
  if (typeof window === "undefined") return;
766
779
  if (inline && !slot.current) return;