@womp/mcp-ui 0.1.13 → 0.1.14
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/dist/index.js +8 -8
- package/dist/openai-camera/index.html +6 -6
- package/package.json +1 -1
- package/src/openai-camera/main.ts +12 -2
package/package.json
CHANGED
|
@@ -204,8 +204,17 @@ function flatten(scripts: unknown): Record<string, number> {
|
|
|
204
204
|
return out;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Where the viewer's messages come from. A host that frames the card on an
|
|
209
|
+
* opaque origin (a sandbox without allow-same-origin) passes that sandbox down
|
|
210
|
+
* to the viewer's frame, which then speaks as "null" — still our frame, as
|
|
211
|
+
* `event.source` proves.
|
|
212
|
+
*/
|
|
213
|
+
const fromViewer = (event: MessageEvent, d: Design) =>
|
|
214
|
+
event.source === viewer.contentWindow && (event.origin === d.viewerOrigin || event.origin === "null");
|
|
215
|
+
|
|
207
216
|
window.addEventListener("message", (event) => {
|
|
208
|
-
if (!design || event
|
|
217
|
+
if (!design || !fromViewer(event, design)) return;
|
|
209
218
|
const msg = event.data as { type?: string; scripts?: unknown };
|
|
210
219
|
if (msg?.type === "kakapo:ready") {
|
|
211
220
|
viewerReady = true;
|
|
@@ -225,7 +234,8 @@ window.addEventListener("message", (event) => {
|
|
|
225
234
|
// The viewer has no change event, so read its knobs on an interval while visible.
|
|
226
235
|
window.setInterval(() => {
|
|
227
236
|
if (!design || !viewerReady || document.visibilityState !== "visible") return;
|
|
228
|
-
|
|
237
|
+
// "*": under an opaque host the viewer's origin is "null", which no target origin can name. The request carries nothing.
|
|
238
|
+
viewer.contentWindow?.postMessage({ type: "kakapo:getParams" }, "*");
|
|
229
239
|
}, 1_500);
|
|
230
240
|
|
|
231
241
|
function onViewerParams(params: Record<string, number>) {
|