Skip to content

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().

ts
import { Frame } from '@aspro-cloud/miniapp-jssdk'

Properties

Reference to the Modal class

ts
static Modal: typeof Modal

Sidepanel

Reference to the Sidepanel class

ts
static Sidepanel: typeof Sidepanel

Swal

Reference to the Swal class

ts
static Swal: typeof Swal

Toast

Reference to the Toast class

ts
static Toast: typeof Toast

domain

Current Аспро.Cloud account domain

ts
get domain(): string

events

EventCallbacks<FrameEventName> object with event handlers

ts
get events(): EventCallbacks
set events(value: EventCallbacks)

https

HTTPS connection flag

ts
get https(): boolean

language

Current platform interface language

ts
get language(): string

options

Options instance for managing application settings

ts
get options(): Options

rest

Rest instance for Rest API calls

ts
get rest(): Rest

targetOrigin

Parent window origin, calculated automatically

ts
get targetOrigin(): string

uniqid

Unique identifier of the application embedding placement

ts
get uniqid(): string

userOptions

UserOptions instance for managing current user settings

ts
get userOptions(): UserOptions

Methods

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()

ts
static async initialize(params?: FrameParams): Promise<Frame>
ParameterTypeDescription
paramsFrameParamsInitialization parameters

Method events initialize():

EventParameterTypeDescription
'onReady'Fired after iframe content is loaded (DOMContentLoaded), Frame is initialized and context is received, embedded content is displayed
contextFrameContextApplication 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()

ts
static getInstance(): Frame

destroy

Removes subscriptions and releases resources

ts
destroy(): void

getContext

Returns FrameContext — the current application context

ts
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

ts
async openHomepage(params: FrameOpenHomepageParams): Promise<any>
ParameterTypeDescription
paramsFrameOpenHomepageParamsParameters

Method events openHomepage():

EventParameterTypeDescription
'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

ts
async openUrl(params: FrameOpenUrlParams): Promise<any>
ParameterTypeDescription
paramsFrameOpenUrlParamsParameters

Method events openUrl():

EventParameterTypeDescription
'onOpen'URL successfully opened
'onCancel'User cancelled the action

Example

ts
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')
  }
})
js
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')
  }
});

Published under the MIT license.