@persona/layout-editor-remote-module 0.7.0 → 0.8.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 CHANGED
@@ -115,6 +115,11 @@ cannot derive itself:
115
115
  - `isReadOnly` — the host object is locked for edits
116
116
  - `isInEditor` — the module is rendered inside the layout editor rather than on a live record
117
117
  - `isUsingStubData` — the host is feeding placeholder/stub data instead of a real record
118
+ - `dynamicHeight` — whether the host sizes the iframe to the height the bridge reports
119
+ (`RemoteModuleFrame`'s `dynamicHeight`). A module that fills a fixed-height iframe with viewport
120
+ units (`100vh`) should size to its content when it's set, or the reported height just follows the
121
+ iframe. `RemoteModuleFrame` sets it from its `dynamicHeight` prop, overriding any value in the
122
+ `context` prop.
118
123
 
119
124
  `context` is sent with `init` and pushed again whenever it changes, just like `data`; inside the
120
125
  iframe it arrives through `ready()`, `getContext()`, and the `context` render prop (all
@@ -1,4 +1,4 @@
1
- import { n as Json, t as RemoteModuleContext } from "./protocol-BljV-Zhi.mjs";
1
+ import { n as Json, t as RemoteModuleContext } from "./protocol-Dqnl8JTs.mjs";
2
2
  import { ReactNode } from "react";
3
3
 
4
4
  //#region src/bridge/origin.d.ts
@@ -1,4 +1,4 @@
1
- import { c as resolveAllowedHostOrigins, n as SOURCE, o as candidateParentOrigin, r as parseHostToModuleMessage, s as personaDashboardHostOrigins, t as PROTOCOL_VERSION } from "./protocol-Dr_M54Kt.mjs";
1
+ import { c as resolveAllowedHostOrigins, n as SOURCE, o as candidateParentOrigin, r as parseHostToModuleMessage, s as personaDashboardHostOrigins, t as PROTOCOL_VERSION } from "./protocol-D_pdVZjs.mjs";
2
2
  import { Component, useEffect, useRef, useState } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as Json, t as RemoteModuleContext } from "./protocol-BljV-Zhi.mjs";
1
+ import { n as Json, t as RemoteModuleContext } from "./protocol-Dqnl8JTs.mjs";
2
2
  import { CSSProperties, ReactNode } from "react";
3
3
 
4
4
  //#region src/bridge/host/buildModuleSrc.d.ts
@@ -1,4 +1,4 @@
1
- import { a as assertNotSelfOrigin, i as parseModuleToHostMessage, n as SOURCE, t as PROTOCOL_VERSION } from "./protocol-Dr_M54Kt.mjs";
1
+ import { a as assertNotSelfOrigin, i as parseModuleToHostMessage, n as SOURCE, t as PROTOCOL_VERSION } from "./protocol-D_pdVZjs.mjs";
2
2
  import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
@@ -139,16 +139,23 @@ function createHostBridge({ iframe, moduleOrigin, getData, getContext, resolveDa
139
139
 
140
140
  //#endregion
141
141
  //#region src/bridge/host/RemoteModuleFrame.tsx
142
+ function withDynamicHeight(context, dynamicHeight) {
143
+ return {
144
+ ...context,
145
+ dynamicHeight
146
+ };
147
+ }
142
148
  function RemoteModuleFrame({ documentUrl, moduleOrigin, accessToken, environmentId, locale, extraParams, title, sandbox, referrerPolicy = "no-referrer", initRetryMs, initRetryTimeoutMs, dynamicHeight = false, heightOffset = 0, minHeight, className, style, data, context, resolveDataPath, onRenderError }) {
143
149
  const iframeRef = useRef(null);
144
150
  const dataRef = useRef(data);
145
- const contextRef = useRef(context);
151
+ const contextRef = useRef(withDynamicHeight(context, dynamicHeight));
146
152
  const onRenderErrorRef = useRef(onRenderError);
147
153
  const resolveDataPathRef = useRef(resolveDataPath);
148
154
  const bridgeRef = useRef(void 0);
149
155
  const [height, setHeight] = useState();
156
+ const hostContext = useMemo(() => withDynamicHeight(context, dynamicHeight), [context, dynamicHeight]);
150
157
  dataRef.current = data;
151
- contextRef.current = context;
158
+ contextRef.current = hostContext;
152
159
  onRenderErrorRef.current = onRenderError;
153
160
  resolveDataPathRef.current = resolveDataPath;
154
161
  const src = useMemo(() => buildModuleSrc(documentUrl, {
@@ -194,8 +201,8 @@ function RemoteModuleFrame({ documentUrl, moduleOrigin, accessToken, environment
194
201
  bridgeRef.current?.pushData(data);
195
202
  }, [data]);
196
203
  useEffect(() => {
197
- bridgeRef.current?.pushContext(context);
198
- }, [context]);
204
+ bridgeRef.current?.pushContext(hostContext);
205
+ }, [hostContext]);
199
206
  const computedHeight = dynamicHeight && height !== void 0 ? `${Math.max(height + heightOffset, minHeight ?? 0)}px` : minHeight === void 0 ? "100%" : `${minHeight}px`;
200
207
  return /* @__PURE__ */ jsx("iframe", {
201
208
  ref: iframeRef,
@@ -156,7 +156,8 @@ const remoteModuleContextSchema = z.object({
156
156
  layoutObjectId: z.string().nullable(),
157
157
  isReadOnly: z.boolean(),
158
158
  isInEditor: z.boolean(),
159
- isUsingStubData: z.boolean()
159
+ isUsingStubData: z.boolean(),
160
+ dynamicHeight: z.boolean().optional()
160
161
  });
161
162
  const moduleToHostMessageSchema = z.discriminatedUnion("type", [
162
163
  readySchema,
@@ -20,6 +20,7 @@ declare const remoteModuleContextSchema: z.ZodObject<{
20
20
  isReadOnly: z.ZodBoolean;
21
21
  isInEditor: z.ZodBoolean;
22
22
  isUsingStubData: z.ZodBoolean;
23
+ dynamicHeight: z.ZodOptional<z.ZodBoolean>;
23
24
  }, z.core.$strip>;
24
25
  type RemoteModuleContext = z.infer<typeof remoteModuleContextSchema>;
25
26
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@persona/layout-editor-remote-module",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Shared manifest format, Vite plugin, and host/iframe bridge for remotely-defined dashboard layout modules in Persona dashboard apps.",
5
5
  "license": "SEE LICENSE",
6
6
  "type": "module",