@matterfact/embed 0.11.2 → 0.12.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.
- package/README.md +7 -4
- package/dist/{chunk-AANODHBV.js → chunk-C4XGE6BO.js} +71 -42
- package/dist/chunk-C4XGE6BO.js.map +1 -0
- package/dist/chunk-M5TS546Z.js +2 -0
- package/dist/chunk-SR4ZNUAN.js +3 -0
- package/dist/chunk-SR4ZNUAN.js.map +7 -0
- package/dist/{chunk-JO3GWFMJ.js → chunk-WAUSVV7Y.js} +2 -2
- package/dist/{chunk-CTZEDOH7.js → chunk-ZXMJWCQV.js} +72 -44
- package/dist/chunk-ZXMJWCQV.js.map +1 -0
- package/dist/{context-FR7VFENN.js → context-4LP3EDXL.js} +3 -3
- package/dist/{context-FR7VFENN.js.map → context-4LP3EDXL.js.map} +1 -1
- package/dist/{context-IK5MECUW.js → context-ZSPDZWIB.js} +4 -2
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +3 -3
- package/dist/index.cjs +110 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +102 -45
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +26 -5
- package/dist/react.js.map +1 -1
- package/dist/{snapshot-2V5SDSH2.js → snapshot-OR5SVEUD.js} +2 -2
- package/dist/{snapshot-Y5BF2UJR.js → snapshot-X6FPP3HF.js} +3 -3
- package/dist/{snapshot-Y5BF2UJR.js.map → snapshot-X6FPP3HF.js.map} +1 -1
- package/examples/embed-demo/.env.example +7 -3
- package/examples/embed-demo/README.md +25 -4
- package/examples/embed-demo/src/App.tsx +67 -7
- package/examples/embed-demo/src/styles.css +52 -0
- package/examples/embed-demo/vite.config.ts +3 -2
- package/package.json +1 -1
- package/dist/chunk-AANODHBV.js.map +0 -1
- package/dist/chunk-CTZEDOH7.js.map +0 -1
- package/dist/chunk-SKJFF7RD.js +0 -2
- package/dist/chunk-Y7I25VHL.js +0 -3
- package/dist/chunk-Y7I25VHL.js.map +0 -7
- /package/dist/{chunk-SKJFF7RD.js.map → chunk-M5TS546Z.js.map} +0 -0
- /package/dist/{chunk-JO3GWFMJ.js.map → chunk-WAUSVV7Y.js.map} +0 -0
- /package/dist/{context-IK5MECUW.js.map → context-ZSPDZWIB.js.map} +0 -0
- /package/dist/{snapshot-2V5SDSH2.js.map → snapshot-OR5SVEUD.js.map} +0 -0
package/dist/react.d.cts
CHANGED
|
@@ -255,7 +255,7 @@ interface MatterfactAgentProps {
|
|
|
255
255
|
* Default `true`. Pass `false` for a host that wants agent chat with nothing
|
|
256
256
|
* about the page ever reaching it.
|
|
257
257
|
*/
|
|
258
|
-
pageContext?: boolean;
|
|
258
|
+
pageContext?: boolean | 'full' | 'declared' | 'off';
|
|
259
259
|
/**
|
|
260
260
|
* Force dev mode programmatically. The URL trigger (`?mfdev=1`, see `loader.ts`)
|
|
261
261
|
* still works unchanged — this is the React-prop equivalent, and the two are
|
package/dist/react.d.ts
CHANGED
|
@@ -255,7 +255,7 @@ interface MatterfactAgentProps {
|
|
|
255
255
|
* Default `true`. Pass `false` for a host that wants agent chat with nothing
|
|
256
256
|
* about the page ever reaching it.
|
|
257
257
|
*/
|
|
258
|
-
pageContext?: boolean;
|
|
258
|
+
pageContext?: boolean | 'full' | 'declared' | 'off';
|
|
259
259
|
/**
|
|
260
260
|
* Force dev mode programmatically. The URL trigger (`?mfdev=1`, see `loader.ts`)
|
|
261
261
|
* still works unchanged — this is the React-prop equivalent, and the two are
|
package/dist/react.js
CHANGED
|
@@ -229,11 +229,19 @@ function dockBox(g, vw, _vh) {
|
|
|
229
229
|
// src/loader.ts
|
|
230
230
|
function devRequested() {
|
|
231
231
|
try {
|
|
232
|
-
|
|
232
|
+
if (new URLSearchParams(location.search).get("mfdev") === "1") return true;
|
|
233
|
+
try {
|
|
234
|
+
return localStorage.getItem("mfdev") === "1";
|
|
235
|
+
} catch {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
233
238
|
} catch {
|
|
234
239
|
return false;
|
|
235
240
|
}
|
|
236
241
|
}
|
|
242
|
+
function alog(m, x) {
|
|
243
|
+
if (devRequested()) console.info("[embed auth] host: " + m, x ?? "");
|
|
244
|
+
}
|
|
237
245
|
var POS_KEY = "mf.embed.pos";
|
|
238
246
|
var EmbedHost = class {
|
|
239
247
|
constructor(config) {
|
|
@@ -495,6 +503,11 @@ var EmbedHost = class {
|
|
|
495
503
|
case "widget.requestContext":
|
|
496
504
|
void this.loadContext().then((m) => m.provideContext());
|
|
497
505
|
break;
|
|
506
|
+
case "widget.pageContextMax":
|
|
507
|
+
void this.loadContext().then((m) => {
|
|
508
|
+
m.setPageContextMax(msg.mode);
|
|
509
|
+
});
|
|
510
|
+
break;
|
|
498
511
|
case "widget.requestSnapshot":
|
|
499
512
|
void this.loadContext().then((m) => m.sendSnapshot(this.send));
|
|
500
513
|
break;
|
|
@@ -707,18 +720,26 @@ var EmbedHost = class {
|
|
|
707
720
|
*/
|
|
708
721
|
async provideAuth() {
|
|
709
722
|
const provider = this.config.authTokenProvider ?? globalThis.matterfact?.getEmbedAuthToken;
|
|
710
|
-
if (!provider)
|
|
711
|
-
|
|
723
|
+
if (!provider) {
|
|
724
|
+
alog("no provider");
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (++this.ac > 5) {
|
|
728
|
+
alog("storm cap");
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
712
731
|
try {
|
|
713
732
|
const token = await provider();
|
|
714
733
|
if (token) this.send({ type: "host.auth", token, expiresAt: 0 });
|
|
715
734
|
this.emit({ type: "auth", phase: token ? "granted" : "failed" });
|
|
716
|
-
|
|
735
|
+
alog(token ? "token" : "empty");
|
|
736
|
+
} catch (e) {
|
|
717
737
|
this.emit({ type: "auth", phase: "failed" });
|
|
738
|
+
alog("threw", e);
|
|
718
739
|
}
|
|
719
740
|
}
|
|
720
741
|
loadContext() {
|
|
721
|
-
this.context ?? (this.context = import("./context-
|
|
742
|
+
this.context ?? (this.context = import("./context-ZSPDZWIB.js").then((m) => {
|
|
722
743
|
m.start(
|
|
723
744
|
this.send,
|
|
724
745
|
this.config.origin,
|