Frame
Frame — the main SDK object representing the current mini‑application inside the Аспро.Cloud platform iframe. It is a singleton — created once via initialize() or the wrapper App.initializeFrame().
import { Frame } from '@aspro-cloud/miniapp-jssdk'Properties
Modal
Reference to the Modal class
static Modal: typeof ModalSidepanel
Reference to the Sidepanel class
static Sidepanel: typeof SidepanelSwal
Reference to the Swal class
static Swal: typeof SwalToast
Reference to the Toast class
static Toast: typeof Toastdomain
Current Аспро.Cloud account domain
get domain(): stringevents
EventCallbacks<FrameEventName> object with event handlers
get events(): EventCallbacks
set events(value: EventCallbacks)https
HTTPS connection flag
get https(): booleanlanguage
Current platform interface language
get language(): stringoptions
Options instance for managing application settings
get options(): Optionsrest
Rest instance for Rest API calls
get rest(): ResttargetOrigin
Parent window origin, calculated automatically
get targetOrigin(): stringuniqid
Unique identifier of the application embedding placement
get uniqid(): stringuserOptions
UserOptions instance for managing current user settings
get userOptions(): UserOptionsMethods
initialize
Initializes a mini‑application inside the Аспро.Cloud platform iframe and returns a singleton instance of Frame. It is recommended to use the wrapper App.initializeFrame()
static async initialize(params?: FrameParams): Promise<Frame>| Parameter | Type | Description |
|---|---|---|
params | FrameParams | Initialization parameters |
Method events initialize():
| Event | Parameter | Type | Description |
|---|---|---|---|
'onReady' | Fired after iframe content is loaded (DOMContentLoaded), Frame is initialized and context is received, embedded content is displayed | ||
context | FrameContext | Application context |
Errors
The method will throw an error if:
- the application is not running in a browser
- the application is not inside an iframe
- the platform account domain could not be determined
getInstance
Returns the current singleton instance of Frame. Call only after initialize()
static getInstance(): Framedestroy
Removes subscriptions and releases resources
destroy(): voidgetContext
Returns FrameContext — the current application context
async getContext(): Promise<FrameContext>openHomepage
Opens the application homepage in the platform interface if the homepage is listed in the embedding placements of the manifest for the currently installed application version
async openHomepage(params: FrameOpenHomepageParams): Promise<any>| Parameter | Type | Description |
|---|---|---|
params | FrameOpenHomepageParams | Parameters |
Method events openHomepage():
| Event | Parameter | Type | Description |
|---|---|---|---|
'onOpen' | Application homepage opened | ||
'onCancel' | Opening cancelled |
openUrl
Opens a URL in the platform interface. When navigating to an external resource, the platform will ask the user for confirmation and open the link in a new browser tab
async openUrl(params: FrameOpenUrlParams): Promise<any>| Parameter | Type | Description |
|---|---|---|
params | FrameOpenUrlParams | Parameters |
Method events openUrl():
| Event | Parameter | Type | Description |
|---|---|---|---|
'onOpen' | URL successfully opened | ||
'onCancel' | User cancelled the action |
Example
import { App, Toast } from '@aspro-cloud/miniapp-jssdk'
const frame = await App.initializeFrame({
events: {
onReady: (context) => {
console.log(`Application is ready, received context: ${context}`)
}
}
})
// navigate to a page inside the platform
await frame.openUrl({
url: '/_module/crm/view/account_view/47547'
})
// navigate to an external resource (opens in a new tab with confirmation)
await frame.openUrl({
url: 'https://aspro.cloud',
events: {
onOpen: () => console.log('Navigation completed'),
onCancel: () => console.log('User cancelled navigation')
}
})const App = window.ACloudMiniApp
const frame = await App.initializeFrame({
events: {
onReady: (context) => {
console.log(`Application is ready, received context: ${context}`);
}
}
});
// navigate to a page inside the platform
await frame.openUrl({
url: '/_module/crm/view/account_view/47547'
});
// navigate to an external resource (opens in a new tab with confirmation)
await frame.openUrl({
url: 'https://aspro.cloud',
events: {
onOpen: () => console.log('Navigation completed'),
onCancel: () => console.log('User cancelled navigation')
}
});