@seibert/frame-bridge
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -12,3 +12,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log("!!!!!onNavigationToConfluenceContentHost", event); | ||
const message = { | ||
@@ -15,0 +14,0 @@ invocationId: event.data.invocationId, |
@@ -6,3 +6,3 @@ { | ||
"description": "A lightweight JavaScript library for seamless communication between a website and embedded iframes. frame-bridge simplifies the integration process by providing a secure and efficient way to exchange messages using the PostMessage API.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "UNLICENSED", | ||
@@ -9,0 +9,0 @@ "main": "out/index.js", |
# Frame Bridge | ||
## Usage | ||
### Validate if in spacecraft | ||
## Usage top level frame | ||
### Start host listener | ||
``` | ||
isEmbeddedInSpacecraft: () => Promise<boolean> | ||
startHostListener: (navigation: NavigationFn) => void | ||
``` | ||
Call function isEmbeddedInSpacecraft, which returns true if currently in spacecraft | ||
Initialize host listener with navigation function. The navigation function is called when a navigation event is triggered. | ||
It must be of type NavigationFn. | ||
``` | ||
import { isEmbeddedInSpacecraft } from "@seibert/spacecraft-bridge"; | ||
export type NavigateFn = ({ contentId, spaceKey }: { contentId: string; spaceKey?: string }) => Promise<boolean>; | ||
``` | ||
``` | ||
import { startHostListener } from "@seibert/frame-bridge"; | ||
startHostListener(onNavigate) | ||
``` | ||
### | ||
## Usage embedded frame | ||
### Validate if top level frame started host listener | ||
``` | ||
isHostListening: () => Promise<boolean> | ||
``` | ||
Call function isHostListening, which returns true if host is listening | ||
``` | ||
import { isHostListening } from "@seibert/frame-bridge"; | ||
(async () => { | ||
const isEmbedded = await isEmbeddedInSpacecraft(); | ||
console.log("Is embedded in spacecraft?", isEmbedded); | ||
const isListening = await isHostListening(); | ||
console.log("Is host listening?", isListening); | ||
})() | ||
``` | ||
### Check if spacecraft handles navigation | ||
### Check if top level frame handled navigation | ||
``` | ||
onNavigationToConfluenceContent: ({ contentId, spaceKey }: { contentId: string; spaceKey?: string }) => Promise<{ isResponsible: boolean }> | ||
``` | ||
Call function onNavigationToConfluenceContent with contentId and spaceKey of the Space to navigate to. | ||
Call function onNavigationToConfluenceContent with contentId and spaceKey of the space to navigate to. | ||
It returns { isResponsible: true } if top level frame handled navigation. | ||
``` | ||
import { onNavigationToConfluenceContent } from "@seibert/spacecraft-bridge"; | ||
import { onNavigationToConfluenceContent } from "@seibert/frame-bridge"; | ||
onNavigationToConfluenceContent({ | ||
@@ -25,0 +43,0 @@ contentId: "1933581", |
Sorry, the diff of this file is not supported yet
15697
50
220