@thewhateverapp/tile-sdk 0.14.8 → 0.14.9
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneFromJson.d.ts","sourceRoot":"","sources":["../../src/scene/SceneFromJson.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC1E,4DAA4D;IAC5D,IAAI,EAAE,OAAO,CAAC;IACd,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACtC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,UAAiB,EACjB,OAAO,EACP,SAAkB,EAClB,GAAG,KAAK,EACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"SceneFromJson.d.ts","sourceRoot":"","sources":["../../src/scene/SceneFromJson.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC1E,4DAA4D;IAC5D,IAAI,EAAE,OAAO,CAAC;IACd,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACtC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,UAAiB,EACjB,OAAO,EACP,SAAkB,EAClB,GAAG,KAAK,EACT,EAAE,kBAAkB,qBAyIpB"}
|
|
@@ -26,6 +26,20 @@ export function SceneFromJson({ json, showErrors = true, onEvent, container = 't
|
|
|
26
26
|
setSceneRenderer(() => mod.SceneRenderer);
|
|
27
27
|
});
|
|
28
28
|
}, []);
|
|
29
|
+
// Wrap onEvent to forward to parent window via postMessage
|
|
30
|
+
const wrappedOnEvent = React.useCallback((event, data) => {
|
|
31
|
+
// Call user's onEvent handler
|
|
32
|
+
onEvent?.(event, data);
|
|
33
|
+
// Forward to parent window for tile containers to handle
|
|
34
|
+
if (typeof window !== 'undefined' && window.parent !== window) {
|
|
35
|
+
window.parent.postMessage({
|
|
36
|
+
type: 'tile:event',
|
|
37
|
+
payload: { event, data },
|
|
38
|
+
timestamp: Date.now(),
|
|
39
|
+
}, '*' // Allow any parent origin (tile containers validate origin)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}, [onEvent]);
|
|
29
43
|
// Container styles based on mode
|
|
30
44
|
const containerStyle = container === 'none'
|
|
31
45
|
? undefined
|
|
@@ -105,6 +119,6 @@ export function SceneFromJson({ json, showErrors = true, onEvent, container = 't
|
|
|
105
119
|
if (!isClient || !SceneRenderer) {
|
|
106
120
|
return containerStyle ? React.createElement("div", { style: containerStyle }, loadingPlaceholder) : loadingPlaceholder;
|
|
107
121
|
}
|
|
108
|
-
const sceneContent = (React.createElement(SceneRenderer, { spec: json, onEvent:
|
|
122
|
+
const sceneContent = (React.createElement(SceneRenderer, { spec: json, onEvent: wrappedOnEvent, ...props }));
|
|
109
123
|
return containerStyle ? React.createElement("div", { style: containerStyle }, sceneContent) : sceneContent;
|
|
110
124
|
}
|