BaseAPI
baseAPI
The BaseAPI
class provides asynchronous methods to interact with the Pyloid backend via window.__PYLOID__
. All methods automatically wait for Pyloid initialization before executing.baseAPI
is an singleton instance of the BaseAPI
class.
Methods
getData
Description: Retrieves generic data passed from the Pyloid backend during initialization.
Returns:
Promise<any>
- A promise that resolves with the data.Example:
getWindowId
Description: Gets the unique identifier for the current window.
Returns:
Promise<string>
- A promise that resolves with the window ID string.Example:
getWindowProperties
Description: Retrieves properties associated with the current window.
Returns:
Promise<WindowProperties>
- A promise that resolves with an object containing window properties.Example:
close
Description: Closes the current window.
Returns:
Promise<void>
- A promise that resolves when the close operation is initiated.Example:
hide
Description: Hides the current window.
Returns:
Promise<void>
- A promise that resolves when the hide operation is initiated.Example:
show
Description: Shows the current window if it is hidden.
Returns:
Promise<void>
- A promise that resolves when the show operation is initiated.Example:
focus
Description: Brings the current window to the foreground and gives it focus.
Returns:
Promise<void>
- A promise that resolves when the focus operation is initiated.Example:
showAndFocus
Description: Shows the window (if hidden) and brings it to the foreground with focus.
Returns:
Promise<void>
- A promise that resolves when the operation is initiated.Example:
fullscreen
Description: Makes the current window fullscreen.
Returns:
Promise<void>
- A promise that resolves when the fullscreen operation is initiated.Example:
toggleFullscreen
Description: Toggles the fullscreen state of the current window.
Returns:
Promise<void>
- A promise that resolves when the toggle operation is initiated.Example:
minimize
Description: Minimizes the current window.
Returns:
Promise<void>
- A promise that resolves when the minimize operation is initiated.Example:
maximize
Description: Maximizes the current window.
Returns:
Promise<void>
- A promise that resolves when the maximize operation is initiated.Example:
unmaximize
Description: Restores the window from a maximized state.
Returns:
Promise<void>
- A promise that resolves when the unmaximize operation is initiated.Example:
toggleMaximize
Description: Toggles the maximized state of the current window.
Returns:
Promise<void>
- A promise that resolves when the toggle operation is initiated.Example:
isFullscreen
Description: Checks if the current window is in fullscreen mode.
Returns:
Promise<boolean>
- A promise that resolves with true if fullscreen, false otherwise.Example:
isMaximized
Description: Checks if the current window is maximized.
Returns:
Promise<boolean>
- A promise that resolves with true if maximized, false otherwise.Example:
setTitle
Description: Sets the title of the current window.
Parameters:
title: string
- The new title for the window.Returns:
Promise<void>
- A promise that resolves when the title is set.Example:
setSize
Description: Sets the size (width and height) of the current window.
Parameters:
width: number
- The desired width in pixels.height: number
- The desired height in pixels.
Returns:
Promise<void>
- A promise that resolves when the size is set.Example:
setPosition
Description: Sets the position (x and y coordinates) of the current window.
Parameters:
x: number
- The desired x-coordinate.y: number
- The desired y-coordinate.
Returns:
Promise<void>
- A promise that resolves when the position is set.Example:
setFrame
Description: Sets whether the window should have a standard OS frame.
Parameters:
frame: boolean
- True to show the frame, false to hide it.Returns:
Promise<void>
- A promise that resolves when the frame state is set.Example:
getFrame
Description: Gets the current frame state of the window.
Returns:
Promise<boolean>
- A promise that resolves with true if the frame is visible, false otherwise.Example:
getTitle
Description: Gets the current title of the window.
Returns:
Promise<string>
- A promise that resolves with the window title string.Example:
getSize
Description: Gets the current size (width and height) of the window.
Returns:
Promise<Size>
- A promise that resolves with an object containing the width and height.Example:
getPosition
Description: Gets the current position (x and y coordinates) of the window.
Returns:
Promise<Position>
- A promise that resolves with an object containing the x and y coordinates.Example:
setClipboardText
Description: Sets the system clipboard text content.
Parameters:
text: string
- The text to write to the clipboard.Returns:
Promise<void>
- A promise that resolves when the clipboard text is set.Example:
getClipboardText
Description: Gets the current text content from the system clipboard.
Returns:
Promise<string>
- A promise that resolves with the clipboard text.Example:
setClipboardImage
Description: Sets the system clipboard image content from a file path.
Parameters:
imagePath: string
- The path to the image file.format: string
- The format of the image (e.g., 'png', 'jpeg').
Returns:
Promise<void>
- A promise that resolves when the clipboard image is set.Example:
getClipboardImage
Description: Gets the current image content from the system clipboard.
Returns:
Promise<string>
- A promise that resolves with the clipboard image data.Example:
quit
Description: Quits the entire application.
Returns:
Promise<void>
- A promise that resolves when the quit operation is initiated.Example:
getPlatform
Description: Gets the underlying operating system platform.
Returns:
Promise<Platform>
- A promise that resolves with the platform name ('windows', 'linux', or 'macos').Example:
isProduction
Description: Checks if the application is running in production mode.
Returns:
Promise<boolean>
- A promise that resolves with true if in production, false otherwise.Example:
getProductionPath
Description: Resolves a relative path to an absolute path within the application's production build directory.
Parameters:
path: string
- The relative path within the production build.Returns:
Promise<string>
- A promise that resolves with the absolute path.Example:
getRpcUrl
Description: Retrieves the RPC URL.
Returns:
Promise<string>
- A promise that resolves with the RPC URL.Example:
Usage Example
Last updated
Was this helpful?