Skip to content

gi-nx


gi-nx / openAppPanel

ts
function openAppPanel(this: RpcCallContext, options?: OpenAppPanelOptions): Promise<{
  appInstanceId: string;
  iframeName: string;
  panelId: string;
  panelKey: string;
  placement: PanelPlacement;
}>;

Open a second view of the calling app in its own panel, anchored to an existing panel. The panel runs the same app in a fresh iframe. It receives the same state events and can call the same RPC functions.

The panel URL must be same-origin with the app; omit it to reuse the app's own URL. These panels are never written into a saved layout, and they close with the app.

Once open, track where the panel went with the appPanels state event, or read it on demand with getAppPanels. Inside the panel, window.name is the iframeName returned here, so the page can tell which panel it is.

Parameters ​

ParameterTypeDescription
thisRpcCallContext-
optionsOpenAppPanelOptionsurl for the page to load (defaults to the app URL), placement for where it goes relative to the anchor, anchorAppKey for the panel to anchor to ('map', or a panelKey this app already opened), and icon for the tab glyph.

Returns ​

Promise<{ appInstanceId: string; iframeName: string; panelId: string; panelKey: string; placement: PanelPlacement; }>

The panelKey and panelId needed to address the panel later.

Throws ​

If the URL or icon is not same-origin, the placement is invalid, the anchor is not owned by the caller, the app already has 8 panels open, or the panel cannot open.

Examples ​

typescript
import { rpc } from '@gi-nx/iframe-sdk';

const { panelKey, panelId } = await rpc.invoke('openAppPanel', [{
  url: '/panel.html',
  placement: { position: 'right', size: 0.3 },
  icon: '/tab-icon.svg'
}]);
typescript
const first = await rpc.invoke('openAppPanel', [{ placement: { position: 'right', size: 0.3 } }]);
await rpc.invoke('openAppPanel', [{
  placement: { position: 'bottom', size: 0.4 },
  anchorAppKey: first.panelKey
}]);